Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6339] Localization Format bug

GitHub Issuen/a
TypeBug
Priorityn/a
StatusIn Progress
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
Reporterjosh.mocek
AssigneeRiduanul Islam
Created2019-08-20T14:50:20.000+0000
Updated2019-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

FileDateSize
app.tss2019-09-13T18:48:16.000+0000780
IMG_1113.PNG2019-12-25T23:17:31.000+000039981
index.js2019-08-20T14:50:15.000+00001074
index.tss2019-09-13T18:48:11.000+0000155
index.xml2019-09-13T18:48:05.000+0000114
strings.xml2019-08-20T14:50:15.000+0000188

Comments

  1. Sharif AbuDarda 2019-09-11

    Hello, Please send the index.xml and index.tss file here. Thanks.
  2. josh.mocek 2019-09-13

    I added them
  3. Rakhi Mitro 2019-09-29

    Hello [~josh.mocek], Are you using 8.2.0.GA?
  4. josh.mocek 2019-09-30

    This was on 8.0.0GA
  5. Rakhi Mitro 2019-10-04

    [~josh.mocek], Can you please test this issue on 8.2.0.GA and let us know the results?
  6. Riduanul Islam 2019-12-25

    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:
       [WARN]  My test 1, test same param 1
       [WARN]  My test 1, test same param 1
       [WARN]  My test 1, test same param 1
       [WARN]  My test 1, test same param 1
       
    !IMG_1113.PNG|thumbnail! My test environment was:
       Operating System
         Name                        = Mac OS X
         Version                     = 10.14.6
         Architecture                = 64bit
         # CPUs                      = 4
         Memory                      = 8589934592
       
       Node.js
         Node.js Version             = 8.9.4
         npm Version                 = 6.5.0
       
       Titanium CLI
         CLI Version                 = 5.2.2
       
       Titanium SDK
         SDK Version                 = 8.3.0.GA
         Target Platform             = iphone 5S
       
       [INFO]  Building using iOS SDK: 13.2
       

JSON Source