Search code examples
internationalizationtitaniumappceleratortss

how to re-use a language file in multiple languages without doubling of files with Titanium


So I'm using a language file in Titanium to serve TSS properties I want to re-use throughout the entire app at different locations. These language file variables should be used in the themes folder (or any other TSS file for that matter).

Currently it works with a single language, but my app has multiple languages. But I don't want to duplicate the language file for all languages. Can I re-use the same file in multiple languages without having to copy the file somewhere?


Solution

  • It appears it is not possible to reuse a language file without copying it to all languages. However, the best solution to create a global go-to for parameters to be used in TSS files is to add a section to the config.json file.

    A proper way to do this is:

    "global": {
        "design": {
            "primaryColor": "red"
        }
    },
    

    This can then be used by accessing Alloy.CFG.design.primaryColor.

    The benefit for using the config.json file is that you can also theme the files, as described by Fokke Zandbergen.

    This way, it is even better than using language files, because those couldn't be themed.