Page 4 of 6 FirstFirst ... 23456 LastLast
Results 31 to 40 of 55

Thread: Ext.LocaleManager

  1. #31
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,166

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Loading script tags after the fact isn't going to be sync. You would have to do a sync Ajax call to the JS file. Unless you know of a way to load a script tag sync
    Would be posible load json file in "loadAjaxRequest" and separate locale managment of server side language. What do you think?

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

    Default

    If you want locale to be sync... the only way I see to do it is via Ajax
    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

  3. #33
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,166

    Default

    Quote Originally Posted by mitchellsimoens View Post
    If you want locale to be sync... the only way I see to do it is via Ajax
    Done. You can view in action in: www.jadacosta.es

    I use JSON locale files and work fine!

    T
    hanks for your help!!

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

    Default

    Seems to work great! Fantastic! Keep suggestions coming! Or you can fork the GitHub repo and do pull requests
    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. #35
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,166

    Default

    Only one suggestion. I would add specific configutation in your component if you want load JSON files intead JS files. Now I use this configuraton:

    PHP Code:
    lm.setConfig({
         
    ajaxConfig : {
           
    method 'GET',
           
    async  false
         
    },
         
    path       :  lParam 'locale/locale_' lParam '.js' 'locale/locale_es.js',
         
    type       'ajax'
      
    }); 
    Would be great if I could use this one:

    PHP Code:
      lm.setConfig({
         
    ajaxConfig : {
           
    method 'GET',
           
    async  false
         
    },
         
    path       :  '/locale',
         
    type       'ajax',
        
    language:  lParam
      
    }); 
    In "loadAjaxRequest" mode you cant define "language" and "file" type mode.

    I think would be more clean.

    Thanks and greetings,

  6. #36
    Sencha User
    Join Date
    Mar 2010
    Posts
    51

    Default

    Hi,

    What would be very nice is the ability to dynamically change the locale without any need to restart the application.

    The idea of having a Ext.LocaleManager is great, but this manager should have a "change" event that is raised when the locale is changed. This LocaleManager should also provide methods methods in order to retrieved and set locale.

    Like this every component would be able to add an event listener to the "change" event on the LocaleManager and then change its translation.

    An instance of the LocaleManager should by created by default by the app, so like this all the ExtJs components that require translation (like datePicker) could be translated automatically, but we should keep in mind to be able to have multiple LocaleManager instances inside of our application in order to avoid key collision.

    This is definitely something that has to be added in ExtJs if we want to be able to dynamically change the locale of the application, which is a must have !

    Best
    Daniel

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

    Default

    I have been brainstorming about this but I am worried about performance but I think I have something that may work at least.
    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

  8. #38
    Sencha User
    Join Date
    Mar 2010
    Posts
    51

    Default

    Hi Mitchell,

    I've bee working like this for years now with an other framework (bindows, not to mention), and they have a great BiStringBundle component that does the work.

    Performances are not an issue at all and switching from one language to another is just instantaneous.
    The only thing to keep in mind is to keep string bundles (locale dictionary) not too big, that's why we need to be able to create as many StringBundles or LocaleBundle as needed.

    If I would do the component myself I would do it like this :

    One Ext.LocaleManager which is a singleton. This LocaleManager is just in charge of keeping track of the loaded locale (language / country codes) and raising the "change" event when the locale changes.

    Then have a StringBundle class or LocaleBundle, that is just a dictionary key/value, with a set of useful methods, like getString or getFormattedString (same thing, but with parameters)

    The LocaleManager should have a collection o LocaleBundle that can be accessed by a getter and setter method.

    Like this it would be easy to have something like this :

    Code:
    Ext.LocaleManager.get('Ext') // This will return the LocaleBundle stored under the "Ext" key
    
    Ext.LocaleManager.addEventListener("change", ..... ); // The method will be called when the locale changes
    
    // Be able to do the same directly on the LocaleBundle
    Ext.LocaleManager.get('Ext').addEventListener("change", ..... );
    
    // To store a new LocaleBundle
    Ext.LocaleManager.add('myKey', new Ext.LocaleBundle(...));
    The LocaleManager should also raise an event when we try to access to a LocaleBundle that is not loaded/defined. Like this, we can easily handle the loading of the LocaleBundle. Ideally a proxy should by defined in the LocaleManager, which would be in charge of loading the LocaleBundle from the server. Of course this proxy could be replaced in order to fit everybody's needs.


    Hope to have helped you with this input and if you need any feedback, I would be happy to help.

    Best
    Daniel

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

    Default

    What do you mean a "bundle"? Like using the getter, it will return an Object of locale strings?

    Using events is something that I hadn't thought of, amazingly. So the Component adds a change event and when fired, updates all the Component's things that need locale?
    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

  10. #40
    Sencha User
    Join Date
    Mar 2010
    Posts
    51

    Default

    Hi Mitchell,

    For be a bundle is just a dictionary component that provide a "change" event and two methods "getString" and "getFormattedString" (same method as getString, but takes parameters for injections within the translated string)

    That's exactly how it works ! Events are fired and the components refresh their translations.

    One important thing, is that the translation loading needs to be "on demand".
    In order to perform this the LocaleManager is in charge of creating the LocaleBundle when requested and load asynchronously the translation regarding the locale. During this phase (when the translations are not loaded), the "getString" and "getFormattedString" method of the LocaleBundle return a default text (that should be present in the main LocalBundle for instance), like "Loading...". Then when the content of the LocaleBundle is loaded the "change" event should also be fired on this LocaleBundle object, so that the components who access to those translations can update themselves.

    I thought a little bit about it this week end, and I think that we definitely need to have a proxy and a reader (a little bit like for the data package). Like this we can personalize the way the translations are received (use a webservice/json-rpc, etc...), and the way they are formatted (ini, json, etc...)

    So basically, we should have 4 distinct classes. A Ext.LocaleManager, Ext.LocaleBundle, Ext.LocaleProxy and Ext.LocaleReader. (change the names accordingly of course)

    Best regards
    Daniel

Page 4 of 6 FirstFirst ... 23456 LastLast

Posting Permissions

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