How can I mark a text for localization in Glade?

Hi, I want to create some UI using glade, I’m using gettext() to convert strings when I set them to labels and button, how do I convert strings that are located in a ui file?

When you click the little pen button on the right of the text area you wrote your label’s text to, a dialog window opens and you can tick the box to enable it (though it seems already translatable by default). Note that you need to add your ui files to the POTFILES.in or it won’t even look for translatable strings.

1 Like

Additionally, if you’re hand-editing the UI description files, you can use the translatable="yes" attribute to the <property> element.

1 Like

THX! Does the translatable property work the same way for text in widgets? I mean: If I set the translatable property of a label or a button, will its text get translated? Does it replace calling gettext() explicitly?

No, it’ll only translate the text you have in your ui file, not automatically for subsequent changes using gtk_label_set_text. You’ll have to pass _("my text") as a label text when doing it in the code. Basically in the ui file it means that this particular text is to be translated (when setting the label property).

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.