1. #41
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    392
    Vote Rating
    13
    devtig will become famous soon enough

      2  

    Thumbs up


    I'm done. My improvements:
    • Allow for language change after language change after language change etc.
    • Go back to original language using initialConfig
    • Localizable grid values through column renderers!
    • When components need tooltips, I usually add them as a tip property to the same component. That tooltip can be translated as well.
    • Prevention against word wraps after translation that I have seen occuring.
    • upgrade to latest build of SA (442)
    • Use ExtJS from cdn.sencha.io
    • renamed locale file to js, because IIS for example can't read .json files by default. (just to make it easy to test run this)
    Most of my comments and changes are described in the commits and code. Code is mostly equal to what ssamayoa has posted.

    This is work in progress and needs further optimization. Specially in the area of configurability.

    Check it out, improve it and update it on Git . I will too. Thanks.

    https://github.com/devotis/Ext.ux.Localizer

  2. #42
    Sencha User thesilentman's Avatar
    Join Date
    Apr 2007
    Location
    Athens, Greece
    Posts
    232
    Vote Rating
    2
    thesilentman is on a distinguished road

      0  

    Default


    Awesome!! As soon as I find a minute I'll check it out. Thanks!!

  3. #43
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,323
    Vote Rating
    185
    ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold

      0  

    Default


    Excellent!

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  4. #44
    Sencha User
    Join Date
    Dec 2012
    Location
    Spain
    Posts
    7
    Vote Rating
    0
    Zeigon is on a distinguished road

      0  

    Default


    Hi, it's already been a little while since the last reply to this post but I'd like to share what I did in this regard (Localization) with my project.

    I started referring to all the localizable strings by a variable name:

    Code:
    var header = Ext.create( 'Ext.TitleBar', 
        { 
            id: 'header', docked: 'top', title: titleName, cls: '', html: htmlHeaderContent
        });
    And then I created a file for every language in the application with the translations:

    Code:
    //file eng_us.js
    var titleName="English title";
    var htmlHeaderContent="Html content in English";
    
    //file spa_es.js
    var titleName="Título español";
    var htmlHeaderContent="Contenido en español";
    Then in the html file I can either check the language of the browser, or create a language selection screen, and decide which file to load.

    I find this way pretty easy to use and maintain.

  5. #45
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    583
    Vote Rating
    9
    Dumas will become famous soon enough

      0  

    Default


    Hello,

    the basic concept is quite good, but you are poluting the namespace by defining lots of global variables, this is not good. So I would recommend you the above posted solution using the Localizer.

    Best regards,
    Roland

  6. #46
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    392
    Vote Rating
    13
    devtig will become famous soon enough

      0  

    Default


    The namespace pollution alone is not a valid argument to use Localizer. He might as well use Ext.translations.titleName="Título español";

  7. #47
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,323
    Vote Rating
    185
    ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold

      0  

    Default


    Quote Originally Posted by devtig View Post
    The namespace pollution alone is not a valid argument to use Localizer. He might as well use Ext.translations.titleName="Título español";
    Yep.

    But Localizer is meant to be use with existing applications and with applications crafted with Sencha Architect.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  8. #48
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    392
    Vote Rating
    13
    devtig will become famous soon enough

      0  

    Default


    Yes, I agree. I still use Localizer with projects I create with Sencha Architect today.

  9. #49
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    583
    Vote Rating
    9
    Dumas will become famous soon enough

      0  

    Default


    Yeah, this is true. I keept my explanation a little short. I didn't wanted to specifically recommend Ext.ux.Localizer, I wanted to recommend the concept of a localizer.

    I believe it's a more elegant way to have a text file which maps english strings to localized strings instead of using variables. This is a common an very successful pattern. You might want to look at gettext. There are many implementation of this in other languages, e.g. CakePHP has its implementation, and also JavaScript has multiple implementation, e.g. Jed.

    Since I'm using CakePHP as a backend I have my own implementation in Bancha. I have a shell task which collects all translatable strings and writes them all in a pot file (A catalog of all translatable strings, supported by a lot of fancy translation tools). When I then open my WebApp the localizer pulls the correct language translations, afterwards each call of Banacha.t('Hello %s, good to see you', name) will be translated and returns the localized version.

    Besides the advantage of having very readable code and having good tools to update and manage translations over time, I'm able to outsource specific translations.

    Best regards,
    Roland

  10. #50
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Olney, MD
    Posts
    1,953
    Vote Rating
    65
    Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice

      0  

    Default


    Sencha Architect 2.2 (coming soon) will include a new feature called process config.

    This allows you to integrate ideas like Localizer much more easily. More details to come from the author of this feature.
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team