Results 1 to 10 of 55

Thread: Ext.LocaleManager

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default Ext.LocaleManager

    Want to dynamically load locale files? Ext.LocaleManager can load a JS script tag on the fly.

    Want to refer to locale text easily in your application? Ext.LocaleManager has a simple get method that you can use to access locale text even if the text is nested.

    https://github.com/mitchellsimoens/Ext.LocaleManager

    Easy to setup and use:

    Code:
    Ext.LocaleManager.setConfig({
        language : 'en',      //default is 'en'
        ns       : 'locale',  //default is 'locale'
        path     : '/locale'  //default is 'locale'
    });
    
    Ext.onReady(function() {
        var callback = function(manager) {
            console.log(manager.get('helpText'));
            console.log(manager.get('button.action'));
        };
    
        Ext.LocaleManager.loadLocale(callback);
    });
    Sample locale looks like:

    Code:
    {
        helpText : 'Click me for help',
        buttons  : {
            action : 'Action'
        }
    }
    On my wishlist:

    • Get into the Ext JS 4.x framework
    • Support Ajax loading, not just script tag loading (Added 8/5/11)
    • More advanced locale settings like date differences


    Updated (8/5/11):

    • Ajax support! (need feedback)
    • Default text parameter on get method
    • New Ajax example
    • Update Simple example to show default text usage
    • Updated MVC app example to have a language ComboBox
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    754

    Default

    Nice! I will implement this in my application...

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    754

    Default

    just an idea... it will better to have a default value like this...

    Code:
        Ext.LocaleManager.get('fields.title', 'My Title');

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    I like that idea. Tonight I will be working on this some more to include Ajax support and will fold this in. This suggestion to add will not hard at all

    Keep up the suggestions! So far this is very simplistic but very needed IMO.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Here are some changes I just made:

    • Ajax support! (need feedback)
    • Default text parameter on get method
    • New Ajax example
    • Update Simple example to show default text usage
    • Updated MVC app example to have a language ComboBox


    As always, let me know so I can keep improving!
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  6. #6

    Default

    Hi,

    here is another way that I use in v3.3:

    Translation of general text used in controllers is done in the browser by adding a javascript file with the appropriate language:

    Code:
    1. A simple javascript translate file are included in the main page:
    
    function i18n(translate) {            
     switch (translate) {                 
                                          
      case 'Search'   : return 'Sg';    
      case 'Search:'  : return 'Sg:';  
      case 'Create'   : return 'Opret';   
    .....
                                       
      // Return Default Value          
      default : return translate;      
     }                                 
    }                                  
    
    
    2. Example of code in the Controller:
    
    {xtype:'label'
       ,text: i18n('Search:')
       ,cls: 'ytb-text'
    }
    For i18n translation of text in forms, grids, combo's and even data, dateformats and punctuation is done on the server because I use templates and metadata and all view's are generated "on the fly" by the server based on what language the user selected on the session, what design the user has been set up to and the rules for the user or the user group he belongs to:

    http://216.109.205.54/pextcgi/pxdctemp.pgm?template=date

    The server can be set in collection mode and will collect all text used by an application in a table where it can be "raw" translated using google translate api and then afterwards manually adjusted.

Posting Permissions

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