[1812] Update Docs and Fix Compat Layer

This commit is contained in:
David Sangrey committed 2024-04-22 19:18:01 -04:00
1 parent 10be2c2031
commit 91e4e7998b
2 files changed
+15 -7

No files matched your search

+12 -4
View File
@@ -1193,19 +1193,27 @@ widget if you need to display routine status information.
## Localisation
You can localise your plugin to one of the languages that EDMarketConnector
itself supports. Add the following import near the top of each source
itself supports. Add the following boilerplate near the top of the source
file that contains strings that needs translating:
```python
from l10n import translations as tr
import l10n
import functools
plugin_tl = functools.partial(l10n.translations.tl, context=__file__)
```
Wrap each string that needs translating with the `tr.tl()` function, e.g.:
Wrap each string that needs translating with the `plugin_tl()` function, e.g.:
```python
somewidget["text"] = tr.tl("Happy!")
somewidget["text"] = plugin_tl("Happy!")
```
Note that you can name the "plugin_tl" function whatever you want - just make sure to stay consistent!
Many plugins use `_` as the singleton name. We discourage that in versions 5.11 onward, but it should still work.
If your plugin has multiple files that need translations, simply import the `plugin_tl` function to that location.
You should only need to add the boilerplate once.
If you display localized strings in EDMarketConnector's main window you should
refresh them in your `prefs_changed` function in case the user has changed
their preferred language.