Results 1 to 2 of 2

Thread: Localizations and const files

  1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Scotland
    Posts
    111
    Answers
    7

    Default Localizations and const files

    I'm using Architect and I'm trying to load a file that contains constants and also another file for localizations.
    So for example I wish to have a file that will contain the custom event names so that when I use custom events and if at some point I need to change the event name I only have to change it in one place.

    this will let me do myView.fireEvent( MY_CUSTOM_EVENTNAME_HERE, ... )

    Also I wish to have a localization file.
    So any labels etc will refer to the constants in the localization/property file. this file at the moment will not need to be swapped at runtime - although that would be nice. Will have a default file, but will no doubt load the correct property file using a parameter in URL or similar.

    Any pointers or help?
    (I'm using Ext JS 4.2.2 if that makes any difference to possible soloutions)
    Thanks.

  2. #2
    Sencha User Arg0n's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    122
    Answers
    12

    Default

    I made a singleton language class a while ago: https://github.com/4rg0n/poe_orb_cal...brary/language

    I
    t uses a xml file for the translations:

    https://github.com/4rg0n/poe_orb_calc/blob/master/js/ext/app/data/lang.xml

    It can be easily used in any project by calling

    Code:
    MyApp.Language.translate('String to translate');
    It also supports simple template stuff:

    Code:
    MyApp.Language.translate('Hello my name is {0}', ['Foo']);
    
    //OR
    
    MyApp.Language.translate('Hello my name is {name}', {name: 'Foo'});
    It also can set the current language as cookie or it will try to read the browser settings. It is not the best, but maybe it helps =D

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •