Once more an updated patch. The convert-all script now does the complete initial conversion: both templates and PO files. The README and conversion procedure have been updated.
The console-data_en.patch should still be applied. Additional suggested changes for the en.po file: - de-latin1-nodeadkeys: add "(no dead keys)" for consistency with the mac variant (mac-usb-de-latin1-nodeadkeys) - mac-us-std, mac-us-ext, mac-de2-ext, mac-fr2-ext, mac-fr3: remove "Mac; " from the descriptions as other Mac keyboards don't have them either
commit 71ef142107b364390aa8c12a1df6aa0e2695e217 Author: Frans Pop <[EMAIL PROTECTED]> Date: Tue Mar 18 17:31:43 2008 +0100 Add template conversion scripts diff --git a/debian/template-convert/README b/debian/template-convert/README new file mode 100644 index 0000000..ddd2ee7 --- /dev/null +++ b/debian/template-convert/README @@ -0,0 +1,81 @@ +The scripts and file in this directory are temporary. +They are used to convert the keymap templates files from using keymap codes +in the Choices field to using keymap names. The keymap codes are still used +to identify a keymap, but are moved to the Choices-C field. + +This change also means that PO files need to be converted. + +Overview +======== +- convert-all: convert all console-keymaps-*.templates and PO files +- tconvert: does actual conversion for a single templates file +- po-convert: converts one or more PO files +- keymaplist: contains mapping from code to name used for PO file conversion + +Procedure +========= +Steps for the initial conversion: +- make sure translations are up-to-date as much as possible +- run debconf-updatepo +- build the package using the "old" template files + This is needed because the conversion uses the generated templates file in + console-keymaps-$i/DEBIAN as basis for sorting the English choices +- cd debian/ +- rm template-convert/keymaplist # Start clean +- ./template-convert/convert-all +- run debconf-updatepo to update the POT file + +Note that running tconvert will automatically add any not previously seen +keymaps to the keymaplist file, but will _not_ update existing entries. + +After the conversion the en.po file should be deleted (before building the +package for upload) as it is no longer needed. + +If a translation update (PO file) that still uses the old system is received +after the conversion, it can be converted individually: +- cd debian/ +- save the PO file in ./po/ as normal +- ./template-convert/po-convert po/<language>.po + +Comments +======== +The format of the keymaplist file is: +<keymap code><single tab><keymap name> + +The current sort-keymaps script only indexes Choices-$lang.UTF-8 fields. +This means that the English choices in the Choices field need to be +sorted manually (or at least kept sorted if keymaps are added). +In principle it should be possible to modify the script so that the Choices +field is indexed too. + +Because the use of keymap names as choices means that if a translation is +missing or fuzzy the English keyboard name will be used (and not the code), +the templates files now include the #flag:partial directive. +This means that translations will no longer be dropped completely if a +translation for just a single keymap is missing. + +It is probably wise to also add the "obsolete" keymaps (cf, mac-usb-euro) +in the keymaplist file so that those are converted as well. This has not +yet been done. + +Example +======= + +Current templates file for at +----------------------------- +Template: console-keymaps-at/keymap +Type: select +__Choices: by, bg, ca-multi, croat, cz-lat2, ... +_Description: Keymap to use: + +Templates file for at after conversion +-------------------------------------- +Template: console-keymaps-at/keymap +Choices-C: us, by, be2-latin1, br-abnt2, ... +#flag:partial +__Choices: American English, Belarusian, Belgian, Brazilian (ABNT2 layout), ... +_Description: Keymap to use: + + +Author: Frans Pop +Date: March 18, 2008 diff --git a/debian/template-convert/convert-all b/debian/template-convert/convert-all new file mode 100755 index 0000000..bbba4ec --- /dev/null +++ b/debian/template-convert/convert-all @@ -0,0 +1,23 @@ +#! /bin/bash + +echo +echo "Step 1: converting templates files..." + +for i in acorn amiga at atari dec mac sun usb; do + if [ ! -d console-keymaps-$i/DEBIAN ]; then + echo "You must run debuild first" >&2 + exit 1 + fi + ./template-convert/tconvert console-keymaps-$i/DEBIAN/templates \ + >console-keymaps-$i.templates +done + +echo +echo "Step2: converting all other PO files..." +./template-convert/po-convert po/*.po + +echo +echo "Conversion completed." +echo +echo "NOTE: the po/en.po file is now no longer used and should now be deleted!" +echo diff --git a/debian/template-convert/keymaplist b/debian/template-convert/keymaplist new file mode 100644 index 0000000..abc38c7 --- /dev/null +++ b/debian/template-convert/keymaplist @@ -0,0 +1,91 @@ +by Belarusian +bg Bulgarian +croat Croatian +cz-lat2 Czech +sg-latin1 Swiss German +de-latin1-nodeadkeys German +dk-latin1 Danish +us American English +uk British English +dvorak Dvorak +et Estonian +la-latin1 Latin American +es Spanish +fi-latin1 Finnish +fr-latin9 French +fr-latin1 French (obsolete) +be2-latin1 Belgian +ca-multi Canadian Multilingual +fr_CH-latin1 Swiss French +gr Greek +hebrew Hebrew +hu Hungarian +is-latin1 Icelandic +it Italian +lt Lithuanian +lv-latin4 Latvian +jp106 Japanese +mk Macedonian +no-latin1 Norwegian +nl Dutch +pl Polish +pt-latin1 Portuguese +br-abnt2 Brazilian (ABNT2 layout) +br-latin1 Brazilian (EUA layout) +ro Romanian +ru Russian +sk-qwerty Slovakian +slovene Slovene +sr-cy Serbian (Cyrillic) +se-latin1 Swedish +trfu Turkish (F layout) +trqu Turkish (Q layout) +ua Ukrainian +amiga-us American English (amiga) +amiga-fr French (amiga) +amiga-de German (amiga) +amiga-it Italian (amiga) +amiga-se Swedish (amiga) +amiga-sg Swiss German (amiga) +amiga-es Spanish (amiga) +atari-us American English (atari) +atari-uk British English (atari) +atari-fr French (atari) +atari-de German (atari) +atari-se Swedish (atari) +lk201-us US English +mac-us-std U.S. English (Mac; 82 keys) +mac-us-ext U.S. English (Mac; extended kbd) +mac-de2-ext German (Mac; extended kbd) +mac-fr2-ext French (Mac; extended kbd) +mac-fr3 French (Mac; alternate) +sunkeymap American English (sun) +sunt5-fi-latin1 Finnish (type 5) +sunt5-fr-latin1 French (type 5) +sunt5-de-latin1 German (type 5) +sunt5-ru Russian (type 5) +sunt5-es Spanish (type 5) +sunt4-es Spanish (type 4) +sun-pl Polish (sun) +sunt5-cz-us Czech (type 5; US layout) +sunt5-uk British English (type 5) +sunt4-no-latin1 Norwegian (type 4) +sunt5-no Norwegian (type 5) +sunt5-trqalt Turkish Q (type 5) +sunt4-ja Japanese (type 4) +sunt5-ja Japanese (type 5) +mac-usb-be Belgian +mac-usb-de-latin1 German +mac-usb-de-latin1-nodeadkeys German (no dead keys) +mac-usb-de_CH Swiss German +mac-usb-dk-latin1 Danish +mac-usb-us American English +mac-usb-dvorak Dvorak +mac-usb-es Spanish +mac-usb-fi-latin1 Finnish +mac-usb-fr French +mac-usb-fr_CH-latin1 Swiss French +mac-usb-it Italian +mac-usb-pt-latin1 Portuguese +mac-usb-se Swedish +mac-usb-uk British English diff --git a/debian/template-convert/po-convert b/debian/template-convert/po-convert new file mode 100755 index 0000000..bccad1e --- /dev/null +++ b/debian/template-convert/po-convert @@ -0,0 +1,27 @@ +#! /bin/bash + +echo +echo "NOTE: Duplicate msgid's after conversion are automatically removed!" +echo + +while [ "$1" ]; do + if [ -z "$1" ] || [ ! -f "$1" ] || ! echo "$1" | grep -q "\.po$"; then + echo "Not a valid PO file: $1" + echo "Skipping" + continue + fi + + echo "Converting $1..." + + while read line; do + code=$(echo "$line" | cut -f1) + name=$(echo "$line" | cut -f2) + sed -i "s/^msgid \"$code\"$/msgid \"$name\"/" $1 + done <template-convert/keymaplist + + # remove duplicate strings + msguniq --use-first $1 >$1.new + mv $1.new $1 + + shift +done diff --git a/debian/template-convert/tconvert b/debian/template-convert/tconvert new file mode 100755 index 0000000..31a6f35 --- /dev/null +++ b/debian/template-convert/tconvert @@ -0,0 +1,65 @@ +#! /bin/bash + +OLDIFS="$IFS" + +while read line; do + type="${line%%: *}" + content="${line#*: }" + case $type in + Template) + template="$content" + ;; + Description) + desc="$content" + ;; + Choices) + content="$(echo "$content" | sed "s/, /,/g")" + IFS=, + for item in $content; do + choice=( "[EMAIL PROTECTED]" "$item" ) + done + IFS="$OLDIFS" + ;; + Choices-en.UTF-8) + content="$(echo "$content" | sed "s/, /,/g")" + IFS=, + for item in $content; do + choice_en=( "[EMAIL PROTECTED]" "$item" ) + done + IFS="$OLDIFS" + ;; + Indices-en.UTF-8) + content="$(echo "$content" | sed "s/, /,/g")" + IFS=, + for item in $content; do + index=( "[EMAIL PROTECTED]" "$item" ) + done + IFS="$OLDIFS" + ;; + esac +done < $1 + +# sanity check +if [ [EMAIL PROTECTED] -ne [EMAIL PROTECTED] ] || [ [EMAIL PROTECTED] -ne [EMAIL PROTECTED] ]; then + echo "error: Number of elements does not match" >&2 + exit 1 +fi + [EMAIL PROTECTED] +for i in $(seq 0 $(($count - 1))); do + # Write file with codes for PO conversion + touch template-convert/keymaplist + if ! grep -q "^${choice[i]}[[:space:]]" template-convert/keymaplist; then + echo -e "${choice[i]}\t${choice_en[i]}" >>template-convert/keymaplist + fi + + wanted=${index[i]} + choice_sort=${choice_sort:+$choice_sort, }${choice[wanted - 1]} + choice_en_sort=${choice_en_sort:+$choice_en_sort, }${choice_en[wanted - 1]} +done + +echo "Template: $template" +echo "Choices-C: $choice_sort" +echo "#flag:partial" +echo "__Choices: $choice_en_sort" +echo "_Description: $desc"
signature.asc
Description: This is a digitally signed message part.