Reorganize the translations to work with msgfmt executable

The -d option for the msgfmt executable requires that all
the locales have their po files in the same directory
and be named LOCALE.po.
This commit is contained in:
Ian McInerney 2021-01-16 18:08:19 +00:00
parent e9fa9f68b2
commit 1a025ae7ba
33 changed files with 8 additions and 8 deletions

View File

@ -134,7 +134,7 @@ function( translate_language LANG OUT_FILE)
add_custom_command(
OUTPUT ${OUT_FILE}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${LANG}/kicad.po
${CMAKE_CURRENT_SOURCE_DIR}/pofiles/${LANG}.po
-o ${OUT_FILE}
COMMENT "Building translation library for ${LANG}"
)

View File

@ -7,7 +7,7 @@ else()
CACHE PATH "Location of KiCad i18n files." )
endif()
file(STRINGS LINGUAS LANG_ARRAY REGEX "^[^#].*")
file(STRINGS pofiles/LINGUAS LANG_ARRAY REGEX "^[^#].*")
# Add the commands to translate each language file
foreach( LANG ${LANG_ARRAY} )

View File

@ -65,7 +65,7 @@ find $POTDIRS -name '*.cpp' -or -name '*.h' |
sort |
xgettext -f- -k_ -k_HKI -kwxPLURAL:1,2 --force-po --from-code utf-8 -o $LOCALDIR/kicad.pot
LINGUAS=`cat $LOCALDIR/LINGUAS|grep -v '^#'|grep -v '^\s*$'` #Read file without comment and empty lines
LINGUAS=`cat $LOCALDIR/pofiles/LINGUAS|grep -v '^#'|grep -v '^\s*$'` #Read file without comment and empty lines
#check if present in locale list
validate() { echo $LINGUAS | grep -F -q -w "$1"; }
@ -94,11 +94,11 @@ do
echo "## $i"
if [ "$i" = "en" ] ; then
msgmerge --no-location --no-fuzzy-matching --force-po $LOCALDIR/$i/kicad.po $LOCALDIR/kicad.pot -o $LOCALDIR/$i/kicad.po 2> /dev/null
msgen $LOCALDIR/$i/kicad.po -o $LOCALDIR/$i/kicad.po.tmp && mv $LOCALDIR/$i/kicad.po.tmp $LOCALDIR/$i/kicad.po
msgen $LOCALDIR/pofiles/$i.po -o $LOCALDIR/pofiles/$i.po.tmp && mv $LOCALDIR/pofiles/$i.po.tmp $LOCALDIR/pofiles/$i.po
else
msgmerge --force-po $LOCALDIR/$i/kicad.po $LOCALDIR/kicad.pot -o $LOCALDIR/$i/kicad.po 2> /dev/null
msgmerge --force-po $LOCALDIR/pofiles/$i.po $LOCALDIR/pofiles/kicad.pot -o $LOCALDIR/pofiles/$i.po 2> /dev/null
fi
msgfmt --statistics $LOCALDIR/$i/kicad.po -o $LOCALDIR/messages.mo 2>&1 >>/dev/null |
msgfmt --statistics $LOCALDIR/pofiles/$i.po -o $LOCALDIR/pofiles/messages.mo 2>&1 >>/dev/null |
while IFS=",." read A B C D ; do
echo $A
echo $B
@ -127,7 +127,7 @@ do
done
echo "$i;${TRANSLATED};${FUZZY};${UNTRANSLATED}">>"${CSVFILE}"
done
rm $LOCALDIR/messages.mo
rm $LOCALDIR/pofiles/messages.mo
done
if [ "$PLOT" = "1" ]; then
@ -136,5 +136,5 @@ if [ "$PLOT" = "1" ]; then
fi
if [ ! "$KEEP" = "1" ]; then
rm $LOCALDIR/kicad.pot
rm $LOCALDIR/pofiles/kicad.pot
fi