Skip to content

Commit 16b7b67

Browse files
committed
Fixed problem with % processing on .po files. Fixed quote ' processing on I18N lib.
1 parent 3394f61 commit 16b7b67

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

app/src/processing/app/I18n.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,29 @@ static protected void init (String language) {
4646
}
4747

4848
public static String _(String s) {
49+
String res;
4950
try {
50-
return i18n.getString(s);
51-
}
52-
catch (MissingResourceException e) {
53-
return s;
51+
res = i18n.getString(s);
52+
} catch (MissingResourceException e) {
53+
res = s;
5454
}
55+
56+
// The single % is the arguments selector in .PO files.
57+
// We must put double %% inside the translations to avoid
58+
// getting .PO processing in the way.
59+
res = res.replace("%%", "%");
60+
61+
return res;
5562
}
5663

5764
public static String format(String fmt, Object ... args) {
65+
// Single quote is used to escape curly bracket arguments.
66+
67+
// - Prevents strings fixed at translation time to be fixed again
68+
fmt = fmt.replace("''", "'");
69+
// - Replace ' with the escaped version ''
70+
fmt = fmt.replace("'", "''");
71+
5872
return MessageFormat.format(fmt, args);
5973
}
6074

app/src/processing/app/Sketch.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1634,12 +1634,12 @@ protected void size(PreferencesMap prefs) throws RunnerException {
16341634
long textSize = sizes[0];
16351635
long dataSize = sizes[1];
16361636
System.out.println(I18n
1637-
.format(_("Binary sketch size: {0} bytes (of a {1} byte maximum) - {2}% used"),
1637+
.format(_("Binary sketch size: {0} bytes (of a {1} byte maximum) - {2}%% used"),
16381638
textSize, maxTextSize, textSize * 100 / maxTextSize));
16391639
if (dataSize >= 0) {
16401640
if (maxDataSize > 0) {
16411641
System.out.println(I18n.format(
1642-
_("Minimum Memory usage: {0} bytes (of a {1} byte maximum) - {2}% used"),
1642+
_("Minimum Memory usage: {0} bytes (of a {1} byte maximum) - {2}%% used"),
16431643
dataSize, maxDataSize, dataSize * 100 / maxDataSize));
16441644
} else {
16451645
System.out.println(I18n.format(_("Minimum Memory usage: {0} bytes"), dataSize));

0 commit comments

Comments
 (0)