how to make a plugin use its own translation

  • I apologize for the silly question. :(

    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 ;)


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


    Python
    from . import _

    Oh of course.... ;)

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

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


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