Permalink
Browse files

Fixup translation support

* Use `bash updatepo.sh` instead of `make pot`. `make pot` will
  cause absolute paths to appear in hardinfo.pot of whomever last
  ran it.
* C_() and NC_() support added for contexts

Signed-off-by: Burt P <pburt0@gmail.com>
  • Loading branch information...
bp0 authored and lpereira committed Jul 12, 2017
1 parent f1e867b commit 223f339eedaec9a97de59305d58f4ff9dd7df225
Showing with 40 additions and 5 deletions.
  1. +1 −2 cmake/Translations.cmake
  2. +3 −1 includes/hardinfo.h
  3. +15 −2 po/HOWTO.txt
  4. +21 −0 po/updatepo.sh
View
@@ -20,7 +20,6 @@ macro(add_translations_catalog NLS_PACKAGE)
add_custom_target (pot COMMENT “Building translation catalog.”)
find_program (XGETTEXT_EXECUTABLE xgettext)
set(C_SOURCE "")
foreach(FILES_INPUT ${ARGN})
@@ -36,6 +35,6 @@ macro(add_translations_catalog NLS_PACKAGE)
add_custom_command (TARGET pot COMMAND
${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-8
${VALA_SOURCE} ${C_SOURCE} -k_ -kN_ -kC_:1c,2 -kNC_:1c,2 -c/ --from-code=UTF-8
)
endmacro()
View
@@ -25,8 +25,10 @@
#include "vendor.h"
#include <libintl.h>
#include <locale.h>
#define _(STRING) gettext(STRING)
#define _(STRING) gettext(STRING)
#define N_(STRING) (STRING)
#define C_(CTX, STRING) pgettext(CTX, STRING)
#define NC_(CTX, STRING) (STRING)
typedef enum {
MODULE_FLAG_NONE = 0,
View
@@ -1,2 +1,15 @@
update .pot : make pot in build/
update .po files after .pot update : msgmerge -N XX.po hardinfo.pot > XX_.po && mv XX_.po XX.po
To update the .pot and existing translations use:
bash updatepo.sh
-----
update .pot :
--don't!-- make pot in build/
absolute paths will appear in the .pot
try :
xgettext -d hardinfo -o hardinfo.pot -k_ -kN_ -kC_:1c,2 -kNC_:1c,2 -c/ --from-code=UTF-8 ...
update .po files after .pot update :
msgmerge -N XX.po hardinfo.pot > XX_.po && mv XX_.po XX.po
View
@@ -1,3 +1,24 @@
#!bash
echo "Update gettext translation files."
DER=`pwd`
if [ ! -e "updatepo.sh" ]
then
echo "Error: Run from po/, the location of hardinfo.pot and XX.po files."
exit 1
fi
mv hardinfo.pot hardinfo.pot.old
echo "" > hardinfo.pot # empty existing file to join (-j) with
for d in shell/ modules/ hardinfo/;
do
# work form hardinfo root to get reasonable file reference comments
cd ..
echo -n `pwd`; echo "/$d ..."
find "$d" -type f -name "*.c" -print | xargs xgettext -j -d hardinfo -o "$DER/hardinfo.pot" -k_ -kN_ -kC_:1c,2 -kNC_:1c,2 -c/ --from-code=UTF-8
cd "$DER"
done;
for f in *.po
do

0 comments on commit 223f339

Please sign in to comment.