ham-radio-software / D-Rats

D-Rats program for D-Star Ham Radios
https://iz2lxi.jimdofree.com/
Other
44 stars 13 forks source link

Localization completion - forcing reload of menu translations #267

Open maurizioandreotti opened 1 year ago

maurizioandreotti commented 1 year ago

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:"))

        #------------
wb8tyw commented 1 year ago

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:

maurizioandreotti commented 1 year ago

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",...