Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12960] TiAPI: Cannot add a whitespace at the end of string in i18n strings.xml

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-11-15T00:16:25.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2013 Sprint 18 Core, 2013 Sprint 18, 2013 Sprint 23, 2013 Sprint 23 Core, Release 3.2.0
ComponentsAndroid, iOS
Labelsandroidbuild, cb-verified, exalture, ios, mobilesdk, module_label, qe-testadded
ReporterMeenakshi Pathak
AssigneeChris Barber
Created2013-03-05T11:58:54.000+0000
Updated2013-12-04T00:08:53.000+0000

Description

Use the following xml in the i18n en strings.xml file:
<string name="share">There should be space </string>
<string name="share2"> of that thing.</string>
And use the following in app js:
var win = Ti.UI.createWindow({
    layout: "vertical"
});
// build a string from the strings file that has built-in space.
var s = L("share") + "!on each side!" + L("share2");
alert(s);
The result is different in 3.0 vs 2.1.3. In 3.0, it seems all whitespaces from strings from the language file are trimmed. The same behavior is seen in Android also.

Attachments

FileDateSize
androidNoSpaces.png2013-10-18T09:45:54.000+000031121

Comments

  1. Sunila 2013-04-30

    For Android, one could use unicode \u0020 to add space
  2. Sunila 2013-05-07

    Need a workaround or fix in IOS
  3. Soumya Kanti Kar 2013-05-08

    Also facing the same issue. We are using 3.1.0GA. This issue is happening for both Android and iOS. In Android for space we need to add \u0020 but for iOS we need to add \U0020. This workaround is also of no use, cause \u0020 is not understood in iOS.
  4. Chris Barber 2013-08-27

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/4612
  5. Priya Agarwal 2013-10-18

    Reopening the issue as issue not fixed for android. Verified the fix with: Appc-Studio: 3.2.0.201310170829 Sdk:3.2.0.v20131017152001 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processor:1.0.3 Device:Google Nexus 7(v4.3),iPhone Simulator(v7.0) Xcode: 5 WhiteSpace successfully being added from i18n strings.xml file for iOS. But for android no space are being added/reflected. Code used: app.js
       var win = Ti.UI.createWindow({
       backgroundColor:"white"
       });
       // build a string from the strings file that has built-in space.
       var s = L("share") + "!on each side!" + L("share2");
       var lbl=Ti.UI.createLabel({text:s,backgroundColor:'white',top:'30dp',color:'black',font:{fontSize: 32}});
       win.add(lbl);
       win.open();
       
    strings.xml file There should be space of that thing. Screenshot attached for android.
  6. Chris Barber 2013-10-18

    [~pagarwal] This is fixed in the new Android build, but it hasn't been merged into master yet.
  7. Allen Yeung 2013-10-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/4781
  8. Priya Agarwal 2013-11-14

    Reopening the issue as issue is still reproducible for android. Still not getting whitespace for string when declared in strings.xml file. Tested Environment: Appcelerator Studio: 3.2.0.201311122338 SDK:3.2.0.v20131113183932 alloy: 1.3.0 acs: 1.0.7 npm: 1.3.2 titanium: 3.2.0 titanium-code-processor: 1.1.0 Xcode:5.0.2 Device: Google Nexus 7(v4.3) OS: Mac OSX 10.9
  9. Chris Barber 2013-11-14

    This is NOT a CLI issue. The strings are being written to the res/values/strings.xml file correctly. The problem is in the Ti.Locale.getString() function and also affects L().
  10. Hieu Pham 2013-11-14

    It looks like native Android is trimming spaces. One workaround is to denote a space as '\u0020' in strings.xml (http://stackoverflow.com/questions/1587056/android-string-concatenate-how-to-keep-the-spaces-at-the-end-and-or-beginnin)
  11. Chris Barber 2013-11-14

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/4970
  12. Priya Agarwal 2013-11-15

    Able to get whitespace at the end of strings from i18 strings xml file. Closing as fixed and verified. Tested Environment: Appcelerator Studio: 3.2.0.201311140721 SDK:3.2.0.v20131114184328 alloy: 1.3.0 acs: 1.0.7 npm: 1.3.2 titanium: 3.2.0 titanium-code-processor: 1.1.0 Xcode:5.0.2 Device: Iphone 5s(v7.0.2), Google Nexus7(v4.3) OS: Mac OSX 10.9

JSON Source