Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4881] Request for default i18n strings file

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTiAPI
Labelscb-tooling, i18n, locale, localization
ReporterMatthew O'Riordan
AssigneeChris Barber
Created2011-08-03T09:57:47.000+0000
Updated2018-08-01T23:10:31.000+0000

Description

I have just started using the i18N localisation features, and feel that there is a sorely needed feature which is to have a default locale. I realise you can get a default value by simply using the hints, but I feel this is an inadequate solution because it means you still have to embed your default text inside your standard JS code/view files, something I am trying to avoid. What I propose should happen is that there should be a folder/file structure like this: /i18n/strings.xml (or possibly i18n/default/strings.xml) /i18n/en/strings.xml /i18n/es/strings.xml Then when you call L('my_key') it will default to the value in the default strings.xml if there is no match on locale. This solution is far more elegant than the current solution where you have to pass in a hint. In the mean time, I am building a simple workaround solution which uses JSON with a default JSON file instead. Matt

Comments

  1. Matthew O'Riordan 2011-08-03

    For those of you that are interested, I have created a library for my workaround solution so that others can use it. It's based entirely on JSON, it's way more flexible than the Titanium solution, and it supports sensible defaulting without hints. https://github.com/mattheworiordan/json.i18n-for-Titanium-Mobile. Please use it and provide feedback / contribute.
  2. Gavin Cooper 2011-11-07

    Any ideas on when this will be implemented?
  3. glenn losentes 2012-03-26

    Hi Matthew, is your workaround solution works on SDK v1.8.xx? It seems not to work on my Android Emulator.
  4. Dário Marcelino 2014-02-10

    @Ingo, is it possible to re-prioritise this? This is an old shortcoming in Titanium and a default strings.xml file would make developer's life much easier. Please check the below 3 year old thread where this has been discussed: https://developer.appcelerator.com/question/121180/localization-with-i18n---default-language Current behaviour is defaulting the language to english but that is not always the best choice. Thanks, Dário
  5. Fokke Zandbergen 2014-02-10

  6. Ingo Muschenetz 2014-02-10

    We'll take a look. Thanks!
  7. Dário Marcelino 2014-02-11

    @Ingo, thank you. @Fokke, unfortunately my issue is with Android. For iOS I used the workaround of creating an "aa" locale. When the locale is not matched iOS uses the first in alphabetical order. For android, I've tried explicitly creating a platform/android/res/values/strings.xml file but Titanium is either ignoring it or overwriting it with the en one. Frustrating...
  8. Fokke Zandbergen 2014-04-28

    [~warchild], Titanium is overwriting it. [~ingo], This should be an easy fix. Just add a tiapp.xml option to determine which language should be used as the source for build/android/res/values/strings.xml

JSON Source