how to make a plugin use its own translation

  • I apologize for the silly question. :frowning_face:

    Let's assume we have an untranslated enigma2 plugin (e.g. MyPlugin), and we want to equip it with one or more translations.

    Let's assume that the plugin syntax is correctly structured to make the strings we are interested in translatable.

    Just as an example:

    Code
    # plugin.py
    def print_some_strings():
        print(_("Hello world"))
        print(_("This is a translatable string"))
    if __name__=='__plugin__':
        print_some_strings()

    Let's assume that we have extracted all the translatable strings from the sources, created a .po file, translated the strings, and correctly compiled the .mo file that we are going to place in the right directory

    ...MyPlugin/locale/<language>/LC_MESSAGES/MyPlugin.mo

    Using the file __init__.py we provide the information necessary to associate the path of the translations

    Example:

    What else needs to be done for the plugin code to use the translations dedicated to it?

    Thanks in advance for the help :winking_face:

    DM 920UHD - DM Two - DM One - DM 7020HD-v2 - DM 7020HD

  • You've to import _ from __init__ into your plugin/module


    Python
    from . import _

    Oh of course.... :winking_face:

    Sorry again for the silly question, it was so simple and obvious but I was so stupid.... :nauseated_face:

    I'm getting too old for this stuff :sleeping_face:


    Thank you very much for the courtesy and the help :thumbs_up::thumbs_up:

    DM 920UHD - DM Two - DM One - DM 7020HD-v2 - DM 7020HD