[TIMOB-4881] Request for default i18n strings file
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | TiAPI |
Labels | cb-tooling, i18n, locale, localization |
Reporter | Matthew O'Riordan |
Assignee | Chris Barber |
Created | 2011-08-03T09:57:47.000+0000 |
Updated | 2018-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
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.
Any ideas on when this will be implemented?
Hi Matthew, is your workaround solution works on SDK v1.8.xx? It seems not to work on my Android Emulator.
@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
We'll take a look. Thanks!
@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...
[~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 forbuild/android/res/values/strings.xml