1. #1
    Ext User
    Join Date
    Jun 2010
    Posts
    13
    Vote Rating
    0
    Lobo is on a distinguished road

      0  

    Default i18n / multi-lingual support

    i18n / multi-lingual support


    I have a big project coming that requires internationalization (i18n), only multi-language for now (nothing else about the cultures).

    I would use the latest version of ExtJs, so I need an ExtJs (or compatible) solution that works fully on the client side, without any processing on the server but just loading language-specific javascript files (pre-generated in a certain format).

    What would be the best approach in order to be able to change the text in all ExtJs widgets (labels, grid columns, buttons, etc.) when the user changes his language from a drop-down list?.

    Is there anything already implemented for ExtJs to accomplish this?.

    Thanks in advance,

    Lobo

  2. #2
    crysfel's Avatar
    Join Date
    Feb 2008
    Location
    New York, USA
    Posts
    216
    Vote Rating
    8
    crysfel will become famous soon enough

      0  

    Default


    I usually create a class with a "msg" object that contains all the messages and text that I want to show in my components.

    mymodule.js
    Code:
    var App.mymodule.Main = {
           msg  : {
                  title        : "Welcome to this module",
                  name      : "Name",
                  lastname :"Last Name",
                 .......
           },
    
          init : function(){
    
                  var win = new Ext.Window({
                         title     : this.msg.title,
                         .......
                  })
    
                  win.show();
           }
    
    }
    When I want to select another language I just override the msg object including a file with the translations, like this:

    mymodule-es.js
    Code:
    Ext.override(App.mymodule.Main,{
    
           msg    : {
                  title  : "Bienvenido a este modulo",
                  name: "Nombre",
                  lastname: "Apellido",
                  .....
           }
    
    });
    This file only contain the translations

    I hope you can understand the main idea, my English is no so good

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    15
    Vote Rating
    0
    lethalpunch is on a distinguished road

      0  

    Default


    but how can you do that.
    plz share the code.

  4. #4
    Sencha Premium Member aiky.cc's Avatar
    Join Date
    Aug 2012
    Location
    Novosibirsk, Russia
    Posts
    26
    Vote Rating
    0
    aiky.cc is on a distinguished road

      0  

    Wink


    Code:
    var myLocale = function(sid){
        return myLocale.data[sid][myLocale.current];
    };
    
    myLocale.current = 0;
    myLocale.data = {
        'sid0':['russianWord0','englishWord0'],
        'sid1':['russianWord1','englishWord1']
        .....
    }
    
    var grid = Ext.create('Ext.grid.Panel',{
       'columns':[
           {'text':myLocale('sid0')},
           {'text':myLocale('sid1')}
        ]
    })

Similar Threads

  1. [INFOREQ] Bug Multi-language support.
    By edward in forum Ext Designer: Bugs
    Replies: 4
    Last Post: 5 Apr 2010, 3:55 AM
  2. Multi-sort support
    By leonate in forum Community Discussion
    Replies: 5
    Last Post: 26 Aug 2008, 5:11 PM
  3. Support for Multi Column Sorting in Grid?
    By sethladd in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 24 Dec 2007, 3:44 PM

Thread Participants: 3

Tags for this Thread