D-Rats icon indicating copy to clipboard operation
D-Rats copied to clipboard

Localization completion - forcing reload of menu translations

Open maurizioandreotti opened this issue 2 years ago • 2 comments

Reporting here as a reminder the piece of code for forcing the reload of the menu labels from .pot files

Before moving on to other stuff, as I spent some time to came to find a solution to complete the menu translation I'd like to see it here, at least commented, thanks.

I am referring to this code:

       #Reapply gettext configuration to have UI labels translated
        gettext.bindtextdomain('D-RATS', "locale")
        gettext.textdomain('D-RATS')
        _ = gettext.gettext

        self._application = application
        self._window = self._wtree.get_object("mainwindow")

        # Retrieve other translatable objects and set their text
        self.logger.info(" Forcing UI labels translation:")

        label_from_builder = wtree.get_object("mnu_tools")
        label_from_builder.set_label(_("Tools"))
        label_from_builder = wtree.get_object("main_menu_importmsg")
        label_from_builder.set_label(_("Import Message"))
        label_from_builder = wtree.get_object("main_menu_exportmsg")
        label_from_builder.set_label(_("Export Message"))
        label_from_builder = wtree.get_object("main_menu_msgtemplates") 

        label_from_builder.set_label(_("Message Templates"))
        label_from_builder = wtree.get_object("main_menu_ping")
        label_from_builder.set_label(_("Ping Station"))
        label_from_builder = wtree.get_object("main_menu_conninet")
        label_from_builder.set_label(_("Connected to Internet"))
        label_from_builder = wtree.get_object("menuitem3")
        label_from_builder.set_label(_("_View"))

        label_from_builder = wtree.get_object("menuitem4")
        label_from_builder.set_label(_("_Help"))
        label_from_builder = wtree.get_object("main_menu_debuglog")
        label_from_builder.set_label(_("Show debug log"))
        label_from_builder = wtree.get_object("main_menu_about")
        label_from_builder.set_label(_("About"))

        label_from_builder = wtree.get_object("tab_label_msg")
        #label_from_builder.set_text(_("Messages"))

        #Event Log Tab
        label_from_builder = wtree.get_object("label6")
        label_from_builder.set_label(_("Show event type:"))
        label_from_builder = wtree.get_object("label7")
        label_from_builder.set_label(_("Containing text:"))

        #------------

maurizioandreotti avatar Oct 25 '23 06:10 maurizioandreotti

I thought that was in the last merge, but I did notice that it may not be working in a quick test.

The current algorithm has a list of widget IDs to look up. For each widget, the current text is looked up, and then it is translated and the text on the label updated.

Where it fails is:

  • when the widget does not have an initial text, which I had to fix on a few widgets.
  • Wrong widget ID for the text was being looked up.
  • Translation missing from the compiled message catalog, possibly because if it missing / disabled in the po file.

wb8tyw avatar Oct 25 '23 13:10 wb8tyw

Just rechecked and the italian translation apperar in 50% of the labels (in red italian, in yellow "untranslated english" ) image

Also tools should be "strumenti",...

maurizioandreotti avatar Nov 14 '23 15:11 maurizioandreotti