[AC-6339] Localization Format bug
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | In Progress |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | josh.mocek |
Assignee | Riduanul Islam |
Created | 2019-08-20T14:50:20.000+0000 |
Updated | 2019-12-25T23:19:29.000+0000 |
Description
Using localization with a localized string defined like this:
<resources>
<string name="myTestLabel1">My test %1$s, test same param %1$s</string>
<string name="myTestLabel2" formatted="false">My test %1$s, test same param %1$s</string>
</resources>
Copy the above code into your app/i18n/en/strings.xml
file.
Then paste this code into the index:
var count = 0;
function doClick(e) {
count++;
let override = false;
let localizedString = '';
let label2 = undefined;
let description = ${count} -
;
switch (count) {
case 1:
description += 'formatted=undefined & 1';
localizedString = 'myTestLabel1';
break;
case 2:
description += 'formatted=undefined & 2';
localizedString = 'myTestLabel1';
label2 = '2';
break;
case 3:
description += 'formatted=false & 1';
localizedString = 'myTestLabel2';
break;
case 4:
description += 'formatted=false & 2';
localizedString = 'myTestLabel2';
label2 = '2';
break;
case 5:
description += 'passing 1 undefined param & 2';
localizedString = 'myTestLabel2';
override = true;
count = 0;
break;
}
let formattedString;
if (label2 != undefined || override) {
formattedString = String.format(L(localizedString), '1', label2);
} else {
formattedString = String.format(L(localizedString), '1');
}
alert(${description} param(s) passed\n--\n${formattedString}
);
}
$.index.open();
You will notice that every odd case has a problem. Ideally case 1 should not output the @. Here is what they look like:
case 1:
Actual: "My test 1, test same param %1$@"
Expected: "My test 1, test same param 1"
case 2:
Actual: "My test 1, test same param 2"
Expected: "My test 1, test same param 2"
case 3:
Actual: "My test 1, test same param %1$@"
Expected: "My test 1, test same param 1"
case 4:
Actual: "My test 1, test same param 2"
Expected: "My test 1, test same param 2"
case 5:
Actual: "My test 1"
Expected: "My test 1, test same param 1"
Attachments
File | Date | Size |
---|---|---|
app.tss | 2019-09-13T18:48:16.000+0000 | 780 |
IMG_1113.PNG | 2019-12-25T23:17:31.000+0000 | 39981 |
index.js | 2019-08-20T14:50:15.000+0000 | 1074 |
index.tss | 2019-09-13T18:48:11.000+0000 | 155 |
index.xml | 2019-09-13T18:48:05.000+0000 | 114 |
strings.xml | 2019-08-20T14:50:15.000+0000 | 188 |
Hello, Please send the index.xml and index.tss file here. Thanks.
I added them
Hello [~josh.mocek], Are you using 8.2.0.GA?
This was on 8.0.0GA
[~josh.mocek], Can you please test this issue on 8.2.0.GA and let us know the results?
Thanks for reaching. I can't reproduce this issue. Rather I got only this "My test 1, test same param 1" line. See the below output and image:
!IMG_1113.PNG|thumbnail! My test environment was: