[CLOSED] Language switch

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Language switch

    I'm using Ext.Net in MVC2 as you know.

    Now i'm thinking on the right way to implement the language switch....

    For now it's done as directevent - but I'm experiencing some troubles with....

    viewport (runat="server" script section at the top"

     
    // Change culture 
    protected void ChangeCulture(object sender, DirectEventArgs e)
    {
    string myLanguage = e.ExtraParams["myLanguage"];
    ResourceManager.GetInstance(this).Locale = myLanguage;
    this.Session["Culture"] = new System.Globalization.CultureInfo(myLanguage);
    }
    viewport

     
    <ext:Menu runat="server">
    <Items>
    <ext:CheckMenuItem ID="LanguageGerman" Text="German" Group="Language">
    <DirectEvents>
    <Click OnEvent="ChangeCulture">
    <ExtraParams>
    <ext:Parameter Name="myLanguage" Value="de" />
    </ExtraParams>
    </Click>
    </DirectEvents>
    </ext:CheckMenuItem>
    <ext:CheckMenuItem ID="LanguageEnglish" Text="English" Group="Language">
    <DirectEvents>
    <Click OnEvent="ChangeCulture">
    <ExtraParams>
    <ext:Parameter Name="myLanguage" Value="en" />
    </ExtraParams>
    </Click>
    </DirectEvents>
    </ext:CheckMenuItem>
    </Items>
    </ext:Menu>
    Problems

    1. After load the default (preset) language isn't marked as active, but if I change the language it's always marked

    2. After changing the language, the screen doesn't refresh (except portal portlets)

    Questions

    - Which approach is preferable to switch language?

    - How can further elements be marked refreshable like the portlets?

    Cheers
    Last edited by Daniil; Oct 13, 2010 at 1:13 PM. Reason: [CLOSED]
  2. #2
    Hi tiramisu,

    I haven't run tests to confirm this, but if you change the Locale/Culture, I think you're going to have to do a complete refresh of the Page. Basically a hard postback.
    Geoffrey McGill
    Founder
  3. #3
    Hi tiramisu,

    Please clarify can this thread be marked as solved?
  4. #4
    Not yet, i'm still thinking how to implement it the right way.

    - As directmethod?
    - As controller-action having a redirecttoaction return?

    What is your advice?

    p.s.
    Which culture specific properties must be set in the ext.net toolkit?
  5. #5
    Hi,

    I don't think that using direct method to switch the language is good idea because many controls don't support change labels after rendering (like grid's headers menu labels)

    Therefore reload the page (postback?) is required. May be to use some localization route. There are many articles about localization under ASP.NET MVC
    http://stackoverflow.com/questions/1...lization-route
    http://stackoverflow.com/questions/1...vc-application
    http://geekswithblogs.net/shaunxu/ar...ion-1-day.aspx

    Which culture specific properties must be set in the ext.net toolkit?
    It is individually for each control. Many controls have properties which must be localized manually but many stabdard properties for Ext.Net controls are already localized for many languages. Please see
    https://examples1.ext.net/#/Miscellaneous/Locale/Basic/
    https://examples1.ext.net/#/Miscella...ined_Language/
    https://examples1.ext.net/#/Miscella...User_Language/
    Last edited by geoffrey.mcgill; Oct 11, 2010 at 1:48 PM.
    Vladimir Shcheglov
    Sr. Developer
  6. #6
    Thank you for all the external articles. My implementation does already implement localization as described there - but I'm not sure where I have to put the "ChangeCulture" Method. For now it is in the Page Header as Directmethod. Further question is also if it's enough for Ext-Net to define the language in the resource manager?

     
        // Change culture 
        protected void ChangeCulture(object sender, DirectEventArgs e)
        {
            string myLanguage = e.ExtraParams["myLanguage"];
            ResourceManager.GetInstance(this).Locale = myLanguage;
            this.Session["Culture"] = new System.Globalization.CultureInfo(myLanguage);
        }
  7. #7
    Hi,

    My implementation does already implement localization as described there - but I'm not sure where I have to put the "ChangeCulture" Method. For now it is in the Page Header as Directmethod.
    To change the language for Ext.Net it is required to reload the page (setting it during Ajax request (in the DirectMethod) handler doesn't work)

    Further question is also if it's enough for Ext-Net to define the language in the resource manager?
    The localization script is added to the page when you define the language in the ResourceManager. It is enough for many Ext.Net controls but there are few plugins and etc which has no localization and you have to set required localization text manually
    Vladimir Shcheglov
    Sr. Developer
  8. #8
    I'm still wondering why themes can be set dynamicly and locale not.


    Theme

    Click once: doesn't work > click twice: works
    ResourceManager.GetInstance(this).Theme = myTheme;

    Click once: works
    ResourceManager.GetInstance(this).SetTheme(myTheme );



    Locale

    Click once: doesn't work > click twice: works
    ResourceManager.GetInstance(this).Locale = myLanguage;


    Method doesn't exist
    ResourceManager.GetInstance(this).SetLocale(myLang uage);




    I have done some investigation on that - and the most components send the text-updates to their control.


    Is this feature (method) planed in future?

    Cheers
  9. #9
    Hi,

    I'm still wondering why themes can be set dynamicly and locale not.
    Localization just add localization javascript file. Localization file overrides text literals in prototypes of wigets (it is mean that already created widgets don't see changes, only new widgets can catch those changes)

    Theme is just css file. Browser apply new css rules automatically to the elments
    Vladimir Shcheglov
    Sr. Developer
  10. #10
    Quote Originally Posted by tiramisu View Post
    Is this feature (method) planed in future?
    No, because it's not practical. Adding more client-side JavaScript would be required.

    Changing the Locale/Culture is best done with a page refresh/postback. Refreshing all the culture dependent properties during a DirectEvent (ajax request) is not planned.

    Can you describe the use-case where dynamically changing the Language during an ajax request is required?
    Geoffrey McGill
    Founder
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: Jul 08, 2012, 9:58 PM
  2. switch to custom theme
    By angusbeare in forum 1.x Help
    Replies: 3
    Last Post: Mar 21, 2012, 1:31 PM
  3. Is possible to switch Store DataSourceID ?
    By Aod47 in forum 1.x Help
    Replies: 1
    Last Post: Mar 14, 2012, 5:46 AM
  4. [CLOSED] [1.2] Switch panels?
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 01, 2011, 4:57 PM
  5. Replies: 1
    Last Post: May 28, 2010, 7:52 AM

Tags for this Thread

Posting Permissions