mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-19 09:42:11 +03:00
Fixed problem with % processing on .po files. Fixed quote ' processing on I18N lib.
This commit is contained in:
@ -46,15 +46,29 @@ public class I18n {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String _(String s) {
|
public static String _(String s) {
|
||||||
|
String res;
|
||||||
try {
|
try {
|
||||||
return i18n.getString(s);
|
res = i18n.getString(s);
|
||||||
}
|
} catch (MissingResourceException e) {
|
||||||
catch (MissingResourceException e) {
|
res = s;
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The single % is the arguments selector in .PO files.
|
||||||
|
// We must put double %% inside the translations to avoid
|
||||||
|
// getting .PO processing in the way.
|
||||||
|
res = res.replace("%%", "%");
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(String fmt, Object ... args) {
|
public static String format(String fmt, Object ... args) {
|
||||||
|
// Single quote is used to escape curly bracket arguments.
|
||||||
|
|
||||||
|
// - Prevents strings fixed at translation time to be fixed again
|
||||||
|
fmt = fmt.replace("''", "'");
|
||||||
|
// - Replace ' with the escaped version ''
|
||||||
|
fmt = fmt.replace("'", "''");
|
||||||
|
|
||||||
return MessageFormat.format(fmt, args);
|
return MessageFormat.format(fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1634,12 +1634,12 @@ public class Sketch {
|
|||||||
long textSize = sizes[0];
|
long textSize = sizes[0];
|
||||||
long dataSize = sizes[1];
|
long dataSize = sizes[1];
|
||||||
System.out.println(I18n
|
System.out.println(I18n
|
||||||
.format(_("Binary sketch size: {0} bytes (of a {1} byte maximum) - {2}% used"),
|
.format(_("Binary sketch size: {0} bytes (of a {1} byte maximum) - {2}%% used"),
|
||||||
textSize, maxTextSize, textSize * 100 / maxTextSize));
|
textSize, maxTextSize, textSize * 100 / maxTextSize));
|
||||||
if (dataSize >= 0) {
|
if (dataSize >= 0) {
|
||||||
if (maxDataSize > 0) {
|
if (maxDataSize > 0) {
|
||||||
System.out.println(I18n.format(
|
System.out.println(I18n.format(
|
||||||
_("Minimum Memory usage: {0} bytes (of a {1} byte maximum) - {2}% used"),
|
_("Minimum Memory usage: {0} bytes (of a {1} byte maximum) - {2}%% used"),
|
||||||
dataSize, maxDataSize, dataSize * 100 / maxDataSize));
|
dataSize, maxDataSize, dataSize * 100 / maxDataSize));
|
||||||
} else {
|
} else {
|
||||||
System.out.println(I18n.format(_("Minimum Memory usage: {0} bytes"), dataSize));
|
System.out.println(I18n.format(_("Minimum Memory usage: {0} bytes"), dataSize));
|
||||||
|
Reference in New Issue
Block a user