Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15628] Android: i18n strings.xml lose the formatted=false attr after compiling

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-11-08T21:57:41.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2013 Sprint 23, 2013 Sprint 23 Core, Release 3.2.0
ComponentsAndroid
Labelsandroid, androidbuild, module_android, qe-manualtest, qe-testadded, triage
ReporterDan Tamas
AssigneeChris Barber
Created2013-10-31T13:44:46.000+0000
Updated2014-11-19T18:26:30.000+0000

Description

I need to use this version of the sdk as it fixes some big bugs, but the strings.xml don't seem to keep the attributes - formatted="false" - so the build will fail :(
[ERROR] Failed to package application:
[ERROR]   
[ERROR] /Volumes/Work/clients/tobias_group_time/TEAMWIRE/gt/build/android/res/values/strings.xml:49: error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
[ERROR] /Volumes/Work/clients/tobias_group_time/TEAMWIRE/gt/build/android/res/values/strings.xml:49: error: Unexpected end tag string
[ERROR] /Volumes/Work/clients/tobias_group_time/TEAMWIRE/gt/build/android/res/values-de/strings.xml:19: error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
[ERROR] /Volumes/Work/clients/tobias_group_time/TEAMWIRE/gt/build/android/res/values-de/strings.xml:19: error: Unexpected end tag string

Comments

  1. Chris Barber 2013-10-31

    @Dan, do your strings contain a single quote? Can you send me a sample strings.xml file (preferably from the i18n folder)? Can you do this soon?
  2. Dan Tamas 2013-11-01

    Another issue seems to be that the *values-de* folder is not being created. I cleaned the project and got this:
       [INFO]  Compiling localization files
       [DEBUG] Processing i18n file: de/strings.xml
       [DEBUG] Processing i18n file: en/strings.xml
       [DEBUG] Writing de strings => /Volumes/Work/clients/tobias_group_time/TEAMWIRE/gt/build/android/res/values-de/strings.xml
       
       fs.js:427
         return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                        ^
       Error: ENOENT, no such file or directory '/Volumes/Work/clients/tobias_group_time/TEAMWIRE/gt/build/android/res/values-de/strings.xml'
       
       
  3. Dan Tamas 2013-11-01

    @Chris - yes it does have a single quote. Please download the i18n folder from here (no idea how to attach it in Jira) https://www.dropbox.com/s/jh8t4al6xv6fhtb/i18n_dan_tamas.zip I cleaned all the ' in the files but it does the same. A hacky solution is to check in _build.js in generateI18N function if the string has some substitution parts and add formatted false to the node (inside the forEach loop)
           data[locale].strings[name].match(/%[s,d,i]/g) && node.setAttribute('formatted', 'false');
       
    (I only test for s/d/i)
  4. Stephen Feather 2013-11-01

    We experienced the ENOENT error when we tested 3.2.x two nights ago. Project still had the default en and ja language string files in place. Removed, project built just fine. Just a reference point.
  5. Dan Tamas 2013-11-01

    If I add after the first failed build the folder in place, and build without cleaning it will go through.
  6. Dan Tamas 2013-11-01

    Medium ? :(
  7. Dan Tamas 2013-11-01

    Thank you @Ingo :)
  8. Chris Barber 2013-11-07

    [~rborn] I did some thinking and talked about it with the other guys and we have come to the conclusion to set formatted="false" on ALL strings in strings.xml. For strings that don't have a %, it should be fine. Then we don't have to do any funky regular expressions. We are not clear yet if this is going to cause other issues, specifically with older Android target SDKs, but I suppose we'll find out soon enough. :)
  9. Chris Barber 2013-11-07

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/4927
  10. Dan Tamas 2013-11-08

    Not a bad idea, I guess :) But what happens with the strings that have % ? In this case we would need to have '%%' to show the % char, and this might break the ios version - just throwing questions here, didn't test it.
  11. Chris Barber 2013-11-08

    If a string has %, nothing happens. Nothing is formatted. You can have a bunch of % and it'll be fine. :)
  12. Dan Tamas 2013-11-08

    Neh, ignore me, was thinking the wrong case (no formatting=false) but I have the perfect excuse: didn't drink my coffee yet :P
  13. Samuel Dowse 2013-11-14

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201311140700 Titanium SDK, build: 3.2.0.v20131114120849 CLI: 3.2.0 Alloy: 1.3.0 Android Emulator : 2.3.3, 4.4 Localization file doesn't lose formatted=false attribute after compilation. i18n folder used from comments. Closing.

JSON Source