Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-1488

XDate locales could not be initialized correctly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Expired
    • Affects Version/s: OpenIDM 3.0.0
    • Fix Version/s: None
    • Component/s: Module - Web UI
    • Labels:

      Description

      In i18nManager.js, XDate locales is initialized by translated month and day name.
      But $.t("…") function cannot translate at this mooment because loading i18next's traslation file doesn't finish.

      i18nManager.js
      $.i18n.(language);
      obj.language = language;
      
      mNames = $.t("config.dates.monthNames").replace(/ ,/g,',').replace(/, /g,',').split(',');
      mNamesShort = $.t("config.dates.monthNamesShort").replace(/ ,/g,',').replace(/, /g,',').split(',');
      dNames = $.t("config.dates.dayNames").replace(/ ,/g,',').replace(/, /g,',').split(',');
      dNamesShort = $.t("config.dates.dayNamesShort").replace(/ ,/g,',').replace(/, /g,',').split(',');
      
      …
         
         XDate.locales[language] = {
             monthNames: mNames,
             monthNamesShort: mNamesShort,
             dayNames: dNames,
             dayNamesShort: dNamesShort
         };
         
         XDate.defaultLocale = language;
      }
      

      According to i18next documentation, we must add callback function as 2nd argument for processing after loading done.

      i18next documentation: http://i18next.com/pages/doc_init.html

      So it seems that the solution is using callback function as below.

      Fixed i18nManager.js
      $.i18n.setLng(language, function() {
          
          mNames = $.t("config.dates.monthNames").replace(/ ,/g,',').replace(/, /g,',').split(',');
          mNamesShort = $.t("config.dates.monthNamesShort").replace(/ ,/g,',').replace(/, /g,',').split(',');
          dNames = $.t("config.dates.dayNames").replace(/ ,/g,',').replace(/, /g,',').split(',');
          dNamesShort = $.t("config.dates.dayNamesShort").replace(/ ,/g,',').replace(/, /g,',').split(',');
          
      
           …
              IXDate.locales[language] = {
                  monthNames: mNames,
                  monthNamesShort: mNamesShort,
                  dayNames: dNames,
                  dayNamesShort: dNamesShort
              };
              
              XDate.defaultLocale = language;
          }
      });
      

        Attachments

          Activity

            People

            • Assignee:
              jake.feasel Jake Feasel
              Reporter:
              wadahiro wadahiro
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: