|
|
El 9/12/21 a las 22:01, 'melcher....@googlemail.com' via fltk.coredev
escribió:
Looking at STR 3289, I don't know much about adding another language
to an app, neither with POSIX catguts, nor GNU gettext. Both seem to
be in use, but can anyone give me a hint on how these are applied
across our supported platforms?
I can give you advice for gettext as I am using it in my player.
Can anyone give me pointers on how these tools work cross platform,
and how this could be integrated without breaking anything?
xgettext extracts all marked text on a platform. Normally, this means
all text enclosed in gettext() calls, but this is usually shortened to a
macro like _("untranslated string"). Currently there is an issue with
fluid's menus that get created as a static table, where the gettext()
function cannot be used, so ALL strings need to be extracted which is messy.
What you would do (AFAICT) in a real application is:
(1) extract all translatable strings out of the source/header files
(*NOT* the .fl files), likely using xgettext. This creates a .pot
translation table.
(2) build a translation table ( .po ) for any language by copying the
.pot file and replacing all second strings.
(3) The translations (.po) files are compiled into .mo files using
msgmerge and msgfmt,
(4) the program accesses the translation table at startup and whenever a
source string needs to be translated.
Here's a CMakeLists.txt file with the macros for the process:
SET( _absPotFile "${CMAKE_CURRENT_SOURCE_DIR}/po/messages.pot" )
##
The command below should not use -a as it extracts all strings. It is
needed for fluid's menus not having a gettext (_) function.
##
ADD_CUSTOM_COMMAND( OUTPUT "${_absPotFile}"
COMMAND xgettext
ARGS --package-name=mrViewer --package-version="$VERSION"
--copyright-holder="Film Aura, LLC" -a
--msgid-bugs-address=ggarra13@gmail.com -d mrViewer -s -c++ -k_
${SOURCES} -o po/messages.pot
DEPENDS mrViewer
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
SET( LANGUAGES "es" ) # Only Spanish for now
SET( output_files "${_absPotFile}" )
FOREACH( lang ${LANGUAGES} )
SET( _moDir "${ROOT_DIR}/share/locale/${lang}/LC_MESSAGES/" )
SET( _moFile "${_moDir}/${PROJECT_NAME}${SHORTVERSION}.mo" )
SET( output_files ${output_files} ${_moFile} )
FILE( REMOVE_RECURSE "${_moDir}" ) # Remove dir to remove old .mo files
FILE( MAKE_DIRECTORY "${_moDir}" ) # Recreate dir to place new .mo file
SET( _absFile "${CMAKE_CURRENT_SOURCE_DIR}/po/${lang}.po" )
ADD_CUSTOM_COMMAND( OUTPUT "${_moFile}"
COMMAND msgmerge --quiet --update --backup=none
"${_absFile}" "${_absPotFile}"
COMMAND msgfmt -v "${_absFile}" -o "${_moFile}"
DEPENDS ${_absFile} ${_absPotFile}
)
ENDFOREACH( lang )
ADD_CUSTOM_TARGET(
"translations" ALL
DEPENDS ${output_files} ${PROJECT_NAME}
)
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/68c562f6-ab1f-ab16-9219-4b170c1f1f83%40gmail.com.
[ Direct Link to Message ] | |
|
| |