Skip to content

Instantly share code, notes, and snippets.

@alexandre-mbm
Last active December 9, 2015 01:19
Show Gist options
  • Select an option

  • Save alexandre-mbm/bd5a51177da8df883f82 to your computer and use it in GitHub Desktop.

Select an option

Save alexandre-mbm/bd5a51177da8df883f82 to your computer and use it in GitHub Desktop.
Query helpers for translation of JOSM's presets

The first use was:

$ ./cmp-trans.sh > test.txt

In most cases it will be sufficient to consult test.txt (and last error.txt).

To check differences (if necessary):

  • josm_josm-pt_BR.po ‒ the JOSM's original file
  • for_translation_presets_presetpot_pt_BR.po ‒ the SIMON's file (first numbers of line)

At end of import, the credits are for all: importers and original translators that have worked josm_josm-pt_BR.po at Launchpad.


Update

change-file.sh was used to generate a new for_translation_presets_presetpot_pt_BR.po and the untrans.txt.

$ ./change-file.sh

The import of legacy translations had been a successful!


Update 2

But Simon Poole rejected the result. He want new translations non-tained by GPL:

While mainly intended for use in Vespucci, the translations benefit everybody using the openstreetmap transifex organisation by improving suggestions and making the translations more consistent.

We consider the translations as CC0 licenced and free to use for any purpose, do not translate this project if you do not agree and particularly do not bulk import translations from other, more restrictively licenced sources, for example from the JOSM repository. Note the individual preset strings are clearly as such not a creative work and are in most cases descriptive and simply copied from the OSM wiki.

Even so if you want understand the scripts, see the files one commit ago.

#!/bin/bash
FILE_SIMON=for_translation_presets_presetpot_pt_BR.po
FILE_JOSM=josm_josm-pt_BR.po
FILE_RESULT=test.txt
(awk -vRS= -vFS="\n" '{print $1"|"$3}' $FILE_RESULT ) | while read LINE; do
L1=$(echo "$LINE" | cut -d"|" -f1)
L2=$(echo "$LINE" | cut -d"|" -f2)
N1=$(echo "$L1" | cut -d":" -f1)
N2=$(echo "$L2" | cut -d":" -f1)
S1=$(echo "$L1" | cut -d":" -f2-)
S2=$(echo "$L2" | cut -d":" -f2-)
V1=$(echo "$S1" | cut -d" " -f2-)
V2=$(echo "$S2" | cut -d" " -f2-)
NUMBER=$(expr $N1 + 1)
if [ "$V1" == "$V2" ]; then
echo "$L1" >> untrans.txt
else
sed -i "${NUMBER}s/.*/$S2/g" $FILE_SIMON
fi
done
#!/bin/bash
FILE_SIMON=for_translation_presets_presetpot_pt_BR.po
FILE_JOSM=josm_josm-pt_BR.po
( grep -n msgid $FILE_SIMON ) | while read LINE; do
VALUE=$(echo "$LINE" | cut -d"\"" -f2)
HERE=$(grep -n msgid $FILE_JOSM | grep "\"$VALUE\"" | grep -v "\"\"")
if [ -n "$HERE" ]; then
NUMBER=$(echo "$HERE" | cut -d: -f1)
#echo "$LINE"
#echo "$HERE"
if [ "$NUMBER" -eq "$NUMBER" ] 2>/dev/null
then
NUMBER=$(expr "$NUMBER" + 1)
echo "$LINE"
echo "$HERE"
echo -n "$NUMBER:"; sed -n "${NUMBER}p" $FILE_JOSM
echo
else
echo "$LINE" >> error.txt
echo "$HERE" >> error.txt
echo >> error.txt
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment