Announcement

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

    When are strings loaded for fmt-internationalization of .ds files?

    I dug around a bit today and looked at the smartGWT i18n doc-page, but couldn't wrap my head around it, so asking here:

    Normal GWT i18n uses deferred binding, i.e. it compiles the permutations so that they can be served as a static file from the server. With the <fmt>-strings when localizing the ds fields, i was wondering how the datasource resource fetch is processed on the server. Are they evaluated and generated on a per-request basis or are they pre-compiled so that there is one static datasource-version per language supported? If the datasource info is generated per request, are strings read from the resource file every time or are they at least cached in-memory?

    Hope my question makes sense.

    #2
    GWT's system is based on the needs of a system that has to compile Java to JavaScript in advance. Our server environment is much more normal, and simply resolves the title as the DataSource is requested and gets serialized to the browser.

    Comment


      #3
      hey thanks for quick response.

      OK. So that means that each time a client is to load all my datasource, the fmt-tags will be evaluated and filled with the language-specific strings? Am i wrong in thinking that it would have been be pretty sweet if the datasource files were pre-rendered and served as static files? Am i missing something? (just trying to wrap my head around the performance implications)

      Comment


        #4
        Yes, fmt-tags are evaluated to language-specific strings on the fly, based on the locale of the request.

        No, preprocessing would have essentially no impact on overall performance - that's like taking a part of the system that contributes 0.05% of total load, and making it 0.04%, while introducing complexity and constraints on what can be done at runtime. A poor optimization.

        Comment


          #5
          Allright. Can i ask another question related to this. Your page on the internationalizeation (https://www.smartclient.com/smartgwt...alization.html)
          says:
          Code:
          It obtains the user's Locale from the servlet request, but you can override this if you want to force an application-specific locale, regardless of the user's operating system settings. To do this, specify a "locale" parameter on HTTP requests to the DataSourceLoader and IDACall servlets (the latter is typically done via actionURL).
          The DataSourceLoader part i understand, since that's the one providing the ds-data. I guess it means that i'll write a subclass to DataSourceLoader and set the locale parameter on the HTTPServletRequest. (i have an account setting that determines the locale rather than the browser setting). EDIT nvm i do it directly from the JSP page ofc.

          But i don't get why i need to do it on IDACall?
          Last edited by mathias; 24 Jun 2018, 14:01.

          Comment


            #6
            Because IDACall does not return DataSources. However, if you have application logic that calls getTitle() on DataSource instances, and you need the right title according to your application-specific means of setting the locale, then you would want to set the locale for IDACall as well.

            Comment


              #7
              OK, so if i don't use the titles of the datasources themselves, i don't need to localize it. Thanks.

              One more question - i could not find how to localize the enum values automatically through the fmt-tag. What i mean is that i *can* do it if i manually add an fmt-tag inside every enum value, but i could not find anything on if it's possible to populate them automatically, for example to have enumvalue.0, enumvalue.1 etc in the properties file. Is this possible?

              Comment


                #8
                Originally posted by mathias View Post
                But i don't get why i need to do it on IDACall?
                in addition to #6 of Isomorphic: This is also needed for l10n of serverside validation error messages, as these requests also go through IDACall.

                Best regards
                Blama

                Comment


                  #9
                  Originally posted by mathias View Post
                  One more question - i could not find how to localize the enum values automatically through the fmt-tag. What i mean is that i *can* do it if i manually add an fmt-tag inside every enum value, but i could not find anything on if it's possible to populate them automatically, for example to have enumvalue.0, enumvalue.1 etc in the properties file. Is this possible?
                  This is working for me, if that is what you mean by "enum":
                  Code:
                          <field name="DELIMITER" length="1" type="text" escapeHTML="true">
                              <title><fmt:message key="delimiter" /></title>
                              <valueMap>
                                  <value ID=";"><fmt:message key="delimiterSemicolon" /></value>
                                  <value ID=","><fmt:message key="delimiterComma" /></value>
                                  <value ID="T"><fmt:message key="delimiterTab" /></value>
                              </valueMap>
                          </field>
                  Best regards
                  Blama

                  Comment


                    #10
                    Yeah, thats what i ended up doing, thanks.

                    Comment


                      #11
                      Hi there! One final thing re. performance - all the language resources you read from property files on disk are only read once, right? They are cached in-memory after that?

                      Comment

                      Working...
                      X