Translation of strings in figure menus to user's locale

I’ve seen that the plot window in Octave does not appears with the language selected for the Octave GUI. Also, the strings are notpresent in the localization *.ts files. How can be translated such strings?

To be clear, which parts of the plot window aren’t translating? The window elements like the title “Figure 1”, the menu labels, or something else?

The menus are added with this .m file function:
octave: 2ad979f8c265 scripts/plot/util/private/add_default_menu.m (gnu.org)

Afaict, there is currently no method of localizing those labels.

EDIT (11/18/22): I’m also unaware of how strings in an m-file can be localized. Does Matlab have a solution? A quick Google search didn’t seem to indicate that there is not a way to write an application in Matlab that would automatically select the correct strings based on locale.

None of them, title nor menus

Right, we don’t have a way to do translations for any messages generated in .m files. Does Matlab?

We also only have translations for messages generated in the GUI parts of Octave that are written in C++ with Qt widgets. There are no translations for the interpreter or other parts of Octave that are not “the GUI”.

But I remember I translated the plot window strings some years ago, when I updated the Spanish translation. I’pretty sure they were in the *.ts file

A search gave these translations from @jgpallero :

Searching for Grid / Malla in es_ES.ts, I saw it was removed here:

Tagging @ttl who might know why that text was moved from the ts files elsewhere.

(Edited for accuracy).

Edit: After examining the logs, it looks like there was a significant effort around that time to move raw GUI strings into symbolic constants, likely for ease of maintenance. E.g. one of many: octave: b134fc61d89e

It’s possible that some strings couldn’t be moved. Either way, @ttl will know more about it.

All the translations come from Qt code. So whatever it was that you translated was implemented in that part of the Octave sources. As far as I can tell, none of the files in libgui/graphics currently use the tr function to tag messages for translation. And we have never done anything to allow translations of any other parts of the Octave sources.

You are right. The figure menus used to be implemented in Qt C++ code but they have now been moved to m-code as figure uimenu children. This was done for compatibility, but unfortunately the translations have disappeared in the move.

2 Likes

I don’t know if Matlab has localized versions of their GUI at all.

The libgui/graphics directory is definitely scanned for strings in C++ files for translation. Therefore, not translated text strings are either in m-files or are not used with the tr() method.

However, wouldn’t it be possible to define an environment variable that is used to select the correct translation in a global tr() function (or whatever name we choose for it)?