Uploaded image for project: 'Nuxeo Elements'
  1. Nuxeo Elements
  2. ELEMENTS-1219

Fix error when refreshI18n is called

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.0
    • Fix Version/s: 2.4.32
    • Component/s: I18n
    • Release Notes Summary:
      The WebUI is refreshed without error when changing the language programmatically.
    • Backlog priority:
      500

      Description

      To force a locale globally in the Nuxeo WebUI, one has to use this code

      <script>
      window.nuxeo.I18n.language = 'en';
      window.nuxeo.I18n.loadLocale();
      </script>
      

      it works as expected but it generates an error in the console

      nuxeo-app.html?ts=1597058167177-240.js:126 Uncaught TypeError: this.i18n is not a function
          at HTMLElement._emptyLabel (nuxeo-app.html?ts=1597058167177-240.js:126)
          at runMethodEffect (nuxeo-app.html?ts=1597058167177-13.js:798)
          at Function._evaluateBinding (nuxeo-app.html?ts=1597058167177-13.js:2713)
          at Object.runBindingEffect [as fn] (nuxeo-app.html?ts=1597058167177-13.js:561)
          at runEffectsForProperty (nuxeo-app.html?ts=1597058167177-13.js:142)
          at runEffects (nuxeo-app.html?ts=1597058167177-13.js:108)
          at HTMLElement._propagatePropertyChanges (nuxeo-app.html?ts=1597058167177-13.js:1722)
          at HTMLElement._propertiesChanged (nuxeo-app.html?ts=1597058167177-13.js:1686)
          at HTMLElement._flushProperties (nuxeo-app.html?ts=1597058167177-10.js:327)
          at HTMLElement._flushProperties (nuxeo-app.html?ts=1597058167177-13.js:1540)
      

      It seems to come from the method refreshI18n which sets this.i18n to null

            refreshI18n() {
              this.i18n = null;
              this.set('i18n', window.nuxeo.I18n.translate);
            },
      

      Commenting the line which sets this.i18n = null which to fix the problem and the locale is still correctly applied

      Problem is probably not there in master as this line is already commented : https://github.com/nuxeo/nuxeo-ui-elements/blob/master/nuxeo-i18n-behavior.js#L134

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 45 minutes
                3h 45m