[MGNLCTS-62] Use IoC for SimpleTranslator in TranslationFileFormatOptionGroupFieldDefinition Created: 14/Aug/14  Updated: 17/Sep/14  Resolved: 17/Sep/14

Status: Closed
Project: Content Translation Support
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.0.2

Type: Bug Priority: Critical
Reporter: Natascha Desmarais Assignee: Peili Liang
Resolution: Fixed Votes: 0
Labels: maintenance, next, quickwin
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Tested with mgnl 5.3.1 with CTS 2.0


Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 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.


Generated at Mon Feb 12 00:32:50 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.