Converting from gettext to Qt translation files
-
I'm trying to convert from gettext .po files to .ts files. But after lupdate, the old translations without classnames are vanished, and new ones are added, so I'm losing existing translations.
Command I use to convert the .po file is.:
lconvert6 -locations relative src/translations/es_ES.po -o src/translations/strawberry_es_ES.ts
The sections within context looks like this, everything is added within a blank name.
<name></name> <message> <source>All Files (*)</source> <translation>Todos los archivos (*)</translation> </message>
When I run
make update_translations
, type is added with vanished to the nameless sections, and new sections are added with class names.old section:
<name></name> <message> <source>All Files (*)</source> <translation type="vanished">Todos los archivos (*)</translation> </message>
new section:
<message> <source>All Files (*)</source> <translation type="unfinished">Todos los archivos (*)</translation> </message>
CMake code for lupdate/lrelease:
if(HAVE_TRANSLATIONS) file(GLOB_RECURSE ts_files src/translations/*.ts) set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/data") qt_add_lupdate(strawberry TS_FILES ${ts_files} OPTIONS -no-sort -no-ui-lines -locations none) qt_add_lrelease(strawberry TS_FILES ${ts_files} QM_FILES_OUTPUT_VARIABLE INSTALL_TRANSLATIONS_FILES) if(NOT INSTALL_TRANSLATIONS) qt_add_resources(strawberry "translations" PREFIX "/i18n" BASE "${CMAKE_CURRENT_BINARY_DIR}/data" FILES "${INSTALL_TRANSLATIONS_FILES}") endif() endif()
-
And what's wrong? gettext doesn't provide the context as it seems so it has to be added later on.
-
The problem is that lupdate adds a new context section which is unfinished for each class instead of updating the existing nameless ones, or adding the class names to the existing entries that are already translated.
I see I have no file:line comments in the existing .po files, because I've used xgettext with
--no-location
, could that be the reason, or is there no way to convert translations from gettext without manually editing? -
Never mind I think it works when adding "-no-obsolete" to remove the old entries.
I'm a bit curious about whattype="unfinished
means. -
J Jonas Kvinge has marked this topic as solved on
-
Never mind I think it works when adding "-no-obsolete" to remove the old entries.
I'm a bit curious about whattype="unfinished
means.@Jonas-Kvinge from memory it's when not all strings have been translated and marked as done.