Re: [Qgis-user] Get the translation of a core string in Python
Hi Jürgen That's what I needed. Thank you very much. Michel -Oorspronkelijk bericht- Van: QGIS-User Namens Jürgen E. Fischer via QGIS-User Verzonden: donderdag 5 oktober 2023 18:52 Aan: qgis-user@lists.osgeo.org Onderwerp: Re: [Qgis-user] Get the translation of a core string in Python Moin Michel, On Tue, 03. Oct 2023 at 11:04:26 +, Michel Stuyts via QGIS-User wrote: > In for example the file "qgis_nl.ts" I found the translated value for > "Loading Plugins": You also need to know the context of the translation, ie.: QObject … > > > Loading Plugins > Plug-ins laden > > > But I want to use that translation in a Python plugin. Does anybody know > what the way is to get the translation of a core string using Python? >>> QCoreApplication.translate("QObject", "Loading Plugins") 'Plug-ins laden' Jürgen -- Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-31 Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50 Software Engineer D-26506 Nordenhttps://www.norbit.de QGIS release manager (PSC) Germany IRC: jef on Libera|OFTC ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Get the translation of a core string in Python
Moin Michel, On Tue, 03. Oct 2023 at 11:04:26 +, Michel Stuyts via QGIS-User wrote: > In for example the file "qgis_nl.ts" I found the translated value for > "Loading Plugins": You also need to know the context of the translation, ie.: QObject … > > > Loading Plugins > Plug-ins laden > > > But I want to use that translation in a Python plugin. Does anybody know > what the way is to get the translation of a core string using Python? >>> QCoreApplication.translate("QObject", "Loading Plugins") 'Plug-ins laden' Jürgen -- Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-31 Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50 Software Engineer D-26506 Nordenhttps://www.norbit.de QGIS release manager (PSC) Germany IRC: jef on Libera|OFTC signature.asc Description: PGP signature ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
[Qgis-user] Get the translation of a core string in Python
Hi Michel, I think the easiest way to use the translationdata would be a dictionary. You could try to parse the ts file and load the values from the source and translation tags into a dictionary (BeautifulSoup lxml parser for example) https://realpython.com/python-dicts/ Met vriendelijke groet, Reginald Carlier, Reginald Carlier Deskundige GIS Gemeente Ingelmunster, Oostrozebekestraat 4, 8770 Ingelmunster T+32 51 33 74 39www.ingelmunster.be 0207.485.473 (gemeente) - 0212.221.845 (OCMW) RPR Rechtbank van eerste aanleg West-Vlaanderen afdeling Kortrijk Wij werken enkel op afspraak Schrijf je in op onze nieuwsbrief! Raadpleeg onze disclaimer ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
[Qgis-user] Get the translation of a core string in Python
I am looking for a way in Python to get the translation of a string that is translated in QGIS core. I know how to create and use my own translation files in a QGIS plugin. But now I want to use a string that is already translated in QGIS core. In for example the file "qgis_nl.ts" I found the translated value for "Loading Plugins": Loading Plugins Plug-ins laden But I want to use that translation in a Python plugin. Does anybody know what the way is to get the translation of a core string using Python? Michel Stuyts ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user