Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dynamic Localization & SmartGWT

    Dear Support,

    We have localized our application using the Dynamic String Internationalization technique (without the need to compile permutations for each locale), as documented by Google:

    http://www.gwtproject.org/doc/latest/DevGuideI18n.html#DevGuideDynamicStringInternationalization

    Everything runs perfectly on our side but the SmartGWT strings remain in English, even if we add "&locale=fr" (e.g.) in the URL. Can you please advise us how we can switch/force the client locale in this case?

    Many thanks,

    Thomas

    #2
    This technique isn't related to or influenced by SmartGWT, however, if you read the docs you linked to, it tells you that the locale setting will have no effect.

    If you want to be able to switch URLs using the locale setting, you'll need to add code that looks at the URL and loads a different Dictionary.

    Comment


      #3
      Well, that's we we do, and it works well for our own Dictionary... but I meant the SmartGWT localization (validator errors, grid menus, etc...). How can we set the current locale in the SmartGWT framework?

      Comment


        #4
        GWT's normal mechanisms for locale setting work fine for SmartGWT, as you can readily see in the Showcase; the exact parameter you specified works as expected.

        We don't really have enough information yet to speculate as to how your app might have broken this..

        Comment


          #5
          Thanks for your feed-back.
          As we use dynamic string internationalization, we have NOT added locales to our module XML file, as we do not need it...

          In our XML we only have english, unlike this sample from GWT:

          Code:
          <module>
            <inherits name="com.google.gwt.user.User"/>
            <inherits name="com.google.gwt.i18n.I18N"/>
            
            <!-- French language, independent of country -->
            <extend-property name="locale" values="fr"/>
          
            <!-- French in France -->
            <extend-property name="locale" values="fr_FR"/>
          
            <!-- French in Canada -->
            <extend-property name="locale" values="fr_CA"/>
            
            <!-- English language, independent of country -->
            <extend-property name="locale" values="en"/>
          </module>
          Do we have to add the supported locales like this to support multiple languages in SmartGWT objects?

          Many thanks,

          Thomas

          Comment


            #6
            Yes, you need the locales. SmartGWT is using normal GWT localization for framework strings, so even if you use dynamic localization techniques for application strings, you can't just turn off all the locales - that would lead to exactly the result you're seeing.

            Comment


              #7
              Hi Isomorphic,

              I (perhaps) have difficulties to understand your last post:
              Originally posted by Isomorphic View Post
              Yes, you need the locales. SmartGWT is using normal GWT localization for framework strings, so even if you use dynamic localization techniques for application strings, you can't just turn off all the locales - that would lead to exactly the result you're seeing.
              Are you referring to the same locales, tgilbert is talking about (myproj.gwt.xml):
              Code:
              <extend-property name="locale" values="fr"/>
              or are you referring to your javascript locals like in the SmartClient i18n docs:
              Code:
              <SCRIPT SRC="isomorphic/locales/frameworkMessages_pt.properties"></SCRIPT>
              ?

              If it is the latter, I'm all clear.

              Best regards,
              Blama

              Comment


                #8
                You can indeed load the SmartClient locale files in SmartGWT if you're aware of this advanced technique and able to use it, and if you are not using GWT localization at the application level at all.

                Comment


                  #9
                  Hi Isomorphic,

                  I'm aware of it because you pointed the user in this thread to it.

                  Is it correct to state this about SmartClient Internationalization compared to GWT I18n (for framework+application):
                  • SmartClient Internationalization Pros:
                    • No permutation compilation per language
                    • Add and correct language files while deployed (no recompile)
                    • Possibility to precache localized strings (very minor)
                  • GWT Internationalization Pros:
                    • Automatic date/currency handling (no need for field type="localecurrency" (or localefloat, localeint)?)
                    • Pruning of unused application strings (very minor)
                  Is this list complete?

                  While reading for this I also hit this in the I18n docs:
                  Application Message Localization

                  String localization in SmartGWT is best done using standard GWT approaches.
                  Although GWT supports various ways of localizing strings, Isomorphic recommends the use of an approach based on Resource Bundles.
                  Other parts of SmartGWT - for example, .ds.xml files - are best localized using resource bundles, so using resource bundles makes it easier to share messages that are used both client and server side.
                  I think I'll go that way then if it is the recommended way, even if the "no permutation compilation per language" is very compelling.

                  Best regards,
                  Blama

                  Comment


                    #10
                    [*]GWT Internationalization Pros:[LIST][*]Automatic date/currency handling (no need for field type="localecurrency" (or localefloat, localeint)?)
                    You still need to use these special field types if you want the behaviors they provide (automatic formatting and parsing of input, using the conventions of the current locale). And this is what the docs say as well.

                    The rest of the list is basically correct, although the benefits you cite as very minor could be argued to be non-existent rather than just minor.

                    Comment


                      #11
                      Originally posted by Isomorphic View Post
                      You can indeed load the SmartClient locale files in SmartGWT if you're aware of this advanced technique and able to use it, and if you are not using GWT localization at the application level at all.
                      Can you please elaborate a bit more on this ?

                      We are also using dynamic Dictionary for our translations in our GWT app.
                      Now we want the build in texts of SmartGWT to be translated.

                      What I tried is the following :
                      - Removed all locale stuff from .gwt.xml as this is not needed
                      - Taken the file : frameworkMessages_fr.properties from smartclient and put in a js folder in our war directory
                      - Added a script tag to our .html file : <script src="js/frameworkMessages_fr.js"></script>


                      I can see in the network traffic that the frameWorkMessages_fr.js is loaded but all SmartGWT messages remain in English instead of French.

                      Are we missing something ?

                      If we can get this to work it is pretty easy to dynamically inject the correct .js file into the html when the user changes the language.

                      Comment


                        #12
                        Make sure your injection method causes the locale .js file to be loaded *after* ISC_Core.js and other .js files of the SmartClient runtime are loaded, and before any of your GWT-generated JavaScript application logic runs. That's it.

                        Comment


                          #13
                          Originally posted by Isomorphic View Post
                          Make sure your injection method causes the locale .js file to be loaded *after* ISC_Core.js and other .js files of the SmartClient runtime are loaded, and before any of your GWT-generated JavaScript application logic runs. That's it.
                          Thansk for the quick answer !
                          Got it working now :-)

                          Comment


                            #14
                            Hi Isomorphic,

                            I am facing the below issue while running the super dev mode for Smart GWT in my local.

                            Dictionary not loaded. Did you forget to add your instance of com.smartgwt.client.i18n.SmartGwtMessages to LocaleDymanicSupport.loadJSONs() in your module's onLoad?"
                            1. MissingResourceException_1_g$
                              1. $fa:true
                              2. className_3_g$:"com.smartgwt.client.i18n.SmartGwtMessages"
                              3. detailMessage_0_g$:"Dictionary not loaded. Did you forget to add your instance of com.smartgwt.client.i18n.SmartGwtMessages to LocaleDymanicSupport.loadJSONs() in your module's onLoad?"
                              4. key_1_g$:"ad"
                              5. stackTrace_1_g$:null
                              6. __gwt$backingJsError:Error: Dictionary not loaded. Did you forget to add your instance of com.smartgwt.client.i18n.SmartGwtMessages to LocaleDymanicSupport.loadJSONs() in your module's onLoad? at StackTraceCreator$CollectorModern_1_g$.collect_2_g$ [as collect_4_g$] (workbench-0.js:19000:38) at captureStackTrace_0_g$ (workbench-0.js:18826:18) at MissingResourceException_1_g$.fillInStackTrace_0_g$ [as fillInStackTrace_1_g$] (workbench-0.js:6802:3) at MissingResourceException_1_g$.Throwable_2_g$ (workbench-0.js:6748:8) at MissingResourceException_1_g$.Exception_2_g$ (workbench-0.js:6894:18) at MissingResourceException_1_g$.RuntimeException_2_g$ (workbench-0.js:15579:18) at new MissingResourceException_1_g$ (workbench-0.js:372687:25) at SmartGwtMessages_de_1_g$.getStringInternal_0_g$ [as getStringInternal_2_g$] (workbench-0.js:48748:11) at SmartGwtMessages_de_1_g$.dialog_OkButtonTitle_0_g$ [as dialog_OkButtonTitle_1_g$] (workbench-0.js:155773:15) at initMessages_0_g$ (workbench-0.js:185287:71) at init_9_g$ (workbench-0.js:185221:5) at SmartGwtSuperDevModeEntryPoint_1_g$.onModuleLoad_4_g$ [as onModuleLoad_7_g$] (workbench-0.js:145912:5) at SmartGwtSuperDevModeEntryPoint_1_g$.onModuleLoad_5_g$ [as onModuleLoad_7_g$] (workbench-0.js:146066:50) at Array.init_2_g$ (workbench-0.js:55023:66) at initializeModules_0_g$ (workbench-0.js:221:30) at apply_0_g$ (workbench-0.js:17848:28) at entry0_0_g$ (workbench-0.js:17918:14) at workbench-0.js:17884:14 at gwtOnLoad_0_g$ (workbench-0.js:234:40) at workbench-0.js:380892:1
                              7. __proto__:Object
                            Can you please give me some suggestion what steps need to take or any changes need to be done in GWT itself, because when i am running super dev mode in smart GWT without Tahoe theme, it's working fine but with Tahoe the above issue is coming.

                            Thank you

                            Comment


                              #15
                              As per FAQ, please specify the complete version (including release and date stamp) of your SmartGWT when reporting a bug.

                              What locale are you trying to use? What is the URL that you're hitting? What version of GWT are you using?

                              Comment

                              Working...
                              X