EDMarketConnector icon indicating copy to clipboard operation
EDMarketConnector copied to clipboard

[2188] Support Translation Language Override

Open aussig opened this issue 1 year ago • 2 comments

Description

The default l10n.Translations.translate() function only works with the language currently selected by the user and loaded in l10n.Translations.install(). This PR adds an additional optional lang parameter to translate() which, when passed will temporarily load an alternative language and translate the passed string using that language.

Type of change

Enhancement

Implementation notes

  • Some flake8 issues were flagged with the pre-existing imports. These were fixed.
  • Some flake8 issues were flagged with the Darwin imports. These were not fixed as Darwin will be removed in 2186.
  • The existing context parameter, passed to the function, was not well documented so this has been rewritten. Also, this parameter was modified inside the function, to strip it down to just the plugin name, and then used. IMHO this creates difficult to read code so I have introduced a new plugin_name variable to the existing code, to take this value, and the original context parameter is now left untouched.
  • I noted the comment "# TODO: There is probably a better way to go about this now." against the above extraction of the plugin name from context and would be happy to include a rework of this line if you can let me know what's the latest thinking on the approach.
  • Apologies for the automatic trailing space removals from PLUGINS.md, I didn't spot these on commit but they don't seem unreasonable as a cleanup?

How has this been tested?

By running EDMC in various languages and by modifying a plugin to use the new optional parameter.

Resolves #2188

aussig avatar Apr 01 '24 07:04 aussig

This in the pipe for review after #1812, @aussig this PR may require minor updates and edits after 1812 is merged due to potential conflicts.

Rixxan avatar Apr 27 '24 19:04 Rixxan

No problem @Rixxan, I'll await the merge on that. I took the opportunity to update this PR to the latest develop, resolving one conflict with imports caused by the removal of Darwin, I've used the latest imports from develop (I note you are ignoring Flake8 rule I001 - import alpha ordering - so I did the same)

aussig avatar Apr 28 '24 06:04 aussig

@aussig This is ready for a re-review given the new translation system. Just ping me when it's been given a once-over :)

Rixxan avatar May 11 '24 22:05 Rixxan

@Rixxan I've merged in the latest changes to develop, adding in the optional lang parameter to the new tl().

aussig avatar May 12 '24 14:05 aussig

Love it! Great work. Seems to test fine on my end.

Rixxan avatar May 13 '24 14:05 Rixxan