FLTK logo

Re: [fltk.coredev] STR 3289: i18n and Fluid, does anyone use cross platform internationalisation?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: STR 3289: i18n and Fluid, does anyone use cross platform internationalisation? Gonzalo Garramuño Dec 10, 2021  
 

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 ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.