50 minutes ago, nallath said:catalog = i18nCatalog("Cura")
That should probably be
catalog = i18nCatalog("cura")
50 minutes ago, nallath said:catalog = i18nCatalog("Cura")
That should probably be
catalog = i18nCatalog("cura")
Thanks for your help , None of these solutions seems to work, If it's just a word I've got a translation but a complex label is not translated.
Tested :
from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") untranslated_label = Application.getInstance().getGlobalContainerStack().getProperty("layer_height", "label") translated_label = catalog.i18n(untranslated_label)
and
from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") untranslated_label = Application.getInstance().getGlobalContainerStack().getProperty("layer_height", "label") translated_label = catalog.i18nc("@label", untranslated_label)
with the same result 😞
Edited by CuqI think I have tested every combination possible without success. but I never give up.
translated_label=catalog.i18n(key)
untranslated_label=stack.getProperty(key,"label") translated_label=catalog.i18n(untranslated_label)
definition_key=key + " label" untranslated_label=stack.getProperty(key,"label") translated_label=catalog.i18nc(definition_key, untranslated_label)
untranslated_label=stack.getProperty(key,"label") translated_label=catalog.i18nc("@label", untranslated_label)
untranslated_label=stack.getProperty(key,"label").capitalize() translated_label=catalog.i18nc("@label", untranslated_label)
untranslated_label=stack.getProperty(key,"label") translated_label=catalog.i18nc("@label", key)
untranslated_label=stack.getProperty(key,"label") translated_label=catalog.i18nc(key, untranslated_label)
Edited by Cuq
some help from : Uranium translation Guide
https://github.com/Ultimaker/Uranium/blob/master/docs/translations.md
https://github.com/Ultimaker/Uranium/blob/master/UM/i18n.py
def i18nc(self, context: str, text: str, *args: Any) -> str: """Mark a string as translatable and provide a context for translators. :param context: The context of the string, i.e. something that explains the use of the text. :param text: The text to mark translatable. :param args: Formatting arguments. These will replace formatting elements in the translated string. See python ``str.format()``. :return: The translated text or the untranslated text if it was not found in this catalog. """
Edited by Cuq
YES!!!! I finaly got the solution .
The printing parameters are not define in the cura.po file but in fdmprinter.def.json.po so the catalog must be specified as :
i18n_catalog = i18nCatalog("fdmprinter.def.json")
from UM.i18n import i18nCatalog
i18n_catalog = i18nCatalog("fdmprinter.def.json")
#: fdmprinter.def.json
# msgctxt "support_extruder_nr_layer_0 label" -> Context
# msgid "First Layer Support Extruder" -> Key
# msgstr "Extrudeuse de support de la première couche" -> translated text
definition_key=key + " label"
untranslated_label=stack.getProperty(key,"label")
translated_label=i18n_catalog.i18nc(definition_key, untranslated_label)
Edited by Cuq
Recommended Posts
nallath 1,125
Getting the label indeed gets the untranslated one. You can translate it by passing it though the localisation catalog (i18nCatalog)
It would look a bit like this (it's untested code, so it might not work)
Link to post
Share on other sites