Uploaded image for project: 'Content Translation Support'
  1. Content Translation Support
  2. MGNLCTS-62

Use IoC for SimpleTranslator in TranslationFileFormatOptionGroupFieldDefinition

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 2.0.2
    • 2.0
    • Tested with mgnl 5.3.1 with CTS 2.0

    Description

      Note

      This was put as a critical bug instead of normal improvement since this issue creates almost 10100 log lines for opening 1 dialog.

      Instead of creating a new SimpleTranslator on line 55 of info.magnolia.module.contenttranslationsupport.form.field.definition.TranslationFileFormatOptionGroupFieldDefinition

      SimpleTranslator translator = new SimpleTranslator(new TranslationServiceImpl(), new ContextLocaleProvider());
      

      you should rather inject it in the constructor and reuse it in the getOptions() function. Something along the lines of

      private final SimpleTranslator i18n;
      
      @Inject
      public TranslationFileFormatOptionGroupFieldDefinition(SimpleTranslator i18n) {
          this.i18n=i18n;
      }
      [...]
      //then on current line 64
      definition.setLabel(i18n.translate(operator.getValue().getLabel()));
      

      The problem right now is -as described in the note - that opening the "Export translation" dialog right now creates 10098 lines of log due to warnings coming from info.magnolia.i18nsystem.DefaultMessageBundlesLoader about duplicate keys. The SimpleTranslator seems to be instantiated 3 times for that dialog, so roughly 3k lines for each time. The actual issue lies within the new TranslationServiceImpl() in the current call, which leads to the call of

          protected DefaultMessageBundlesLoader setupMessageBundles() {
              return new DefaultMessageBundlesLoader();
          }
      

      which, in turn, triggers all that output.

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                peili.liang Peili Liang
                ndesmarais Natascha Desmarais
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD