1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    113
    Vote Rating
    0
    DiscoBoy is on a distinguished road

      0  

    Default Dynamic language updates (with Ext locales)

    Dynamic language updates (with Ext locales)


    Hi,

    i'm currently implementing a dynamic language change system in my MVC app:

    1) Works great so far with my own components (I listen for a custom "languagechanged" event in the controllers and apply component related update functions).

    2) Now i'm also loading Ext locales every time my language changes. This way Ext components like the date picker are always rendered in the newly set language
    .

    3) My problem is that this that this is only working for components which are created newly after the last languagechange

    4) Question: Is there any way to call an update function on exisiting components, for instance visibledatepicker.update() to trigger a template refresh of this component, etc.?

    Thanks for your ideas/input!

  2. #2
    Sencha User
    Join Date
    May 2009
    Posts
    113
    Vote Rating
    0
    DiscoBoy is on a distinguished road

      0  

    Default


    I'm currently trying to apply the new language strings to already rendered components, e.g. the date picker!

    The ExtJS Locales are being applied to the prototype of the component, so actually I would need to make the components reRender their content afterwards!
    Code:
    if(Ext.form.field.Date){
          Ext.apply(Ext.form.field.Date.prototype, {
            disabledDaysText  : "Disabled",
            disabledDatesText : "Disabled",
            minText           : "The date in this field must be after {0}",
            maxText           : "The date in this field must be before {0}",
            invalidText       : "{0} is not a valid date - it must be in the format {1}",
            format            : "m/d/y",
            altFormats        : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d"
          });
        }
    This seems to be a bit tricky. With a datefield for instance this works perfectly when I just call:
    Code:
    component.initComponent()
    The result is that the dateformat in the field changes on the fly!
    The same things works half way for the datepicker of the field, but not for an unfloating datepicker. Here I get a second datepicker inserted, but with all correct language strings applied!

    So my question is if there is any way to make the component reRender without side effects? Calling
    Code:
    component.onRender()
    produces errors if i don't put in the body as argument...but then my datepicker renders to the body...

    You can see that I'm a bit lost into trial and error here. So any help or good explanations about reRendering components flawlessly is very much appriciated!