commit b16195b4c3d4fd42f1a62b566751149f43b4df46 Author: Ahmed Siam Date: Fri Aug 18 15:59:50 2023 +0300 internationalize and fix some scripts diff --git a/apertium/apertium-unformat-header.sh b/apertium/apertium-unformat-header.sh index 2307cf2..dde9542 100644 --- a/apertium/apertium-unformat-header.sh +++ b/apertium/apertium-unformat-header.sh @@ -9,10 +9,7 @@ OUTPUT_FILE="/dev/stdout" message () { - echo "USAGE: $(basename "$0") [-f format] [in [out]]" - echo " -f format one of: txt (default), html, rtf, odt, docx, wxml, xlsx, pptx" - echo " in input file (stdin by default)" - echo " out output file (stdout by default)" + icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "unformat_desc" "basename" "$(basename "$0")"\ exit 1; } @@ -21,7 +18,7 @@ locale_utf8 () LC_CTYPE=$(locale -a|grep -i "utf[.]*8"|head -1) export LC_CTYPE if [ "$LC_CTYPE" = "" ] - then echo "Error: Install an UTF-8 locale in your system"; + then icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1158"; exit 1; fi } @@ -29,12 +26,12 @@ locale_utf8 () test_zip () { if ! command -v zip &>/dev/null; then - echo "Error: Install 'zip' command in your system"; + icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1161" "command" "zip"; exit 1; fi if ! command -v unzip &>/dev/null; then - echo "Error: Install 'unzip' command in your system"; + icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1161" "command" "unzip"; exit 1; fi } @@ -42,7 +39,7 @@ test_zip () test_gawk () { if ! command -v gawk &>/dev/null; then - echo "Error: Install 'gawk' in your system" + icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1161" "command" "gawk" exit 1 fi } @@ -146,8 +143,8 @@ unformat_xlsx () while getopts "f:" opt; do case "$opt" in f) FORMAT=$OPTARG ;; - \?) echo "ERROR: Unknown option $OPTARG" >&2; message >&2 ;; - :) echo "ERROR: $OPTARG requires an argument" >&2; message >&2 ;; + \?) icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1108" "opt" "$OPTARG" >&2; message >&2 ;; + :) icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1162" "opt" "$OPTARG" >&2; message >&2 ;; esac done @@ -158,14 +155,14 @@ case "$#" in OUTPUT_FILE=$2; INPUT_FILE=$1; if [ ! -e "$INPUT_FILE" ]; - then echo "Error: file '$INPUT_FILE' not found." + then icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$INPUT_FILE" message; fi ;; 1) INPUT_FILE=$1; if [ ! -e "$INPUT_FILE" ]; - then echo "Error: file '$INPUT_FILE' not found." + then icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$INPUT_FILE" message; fi ;; @@ -187,7 +184,7 @@ case "$FORMATADOR" in rtf) MILOCALE=$(locale -a | grep -E -i -v -m1 'utf|^C|^POSIX$') if [ "$MILOCALE" = "" ] - then echo "Error: Install a ISO-8859-1 compatible locale in your system"; + then icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1166"; exit 1; fi export LC_CTYPE=$MILOCALE diff --git a/apertium/deformat-header.sh b/apertium/deformat-header.sh index 6f69e32..b8acfdf 100644 --- a/apertium/deformat-header.sh +++ b/apertium/deformat-header.sh @@ -25,7 +25,7 @@ MODE="apertium" # default mode if [ $# = 3 ] then if [ ! -e "$2" ] - then echo icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$2"; + then icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$2"; exit 1; fi diff --git a/apertium/gen-header.sh b/apertium/gen-header.sh index 692c80d..156e28d 100644 --- a/apertium/gen-header.sh +++ b/apertium/gen-header.sh @@ -14,14 +14,14 @@ FILE2=$2; if [ $# = 2 ] then if [ ! -e "$1" ] - then echo icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$1"; + then icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$1"; exit 1; fi fi if [ $# = 3 ] then if [ ! -e "$2" ] - then echo icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$2"; + then icuformat "$APERTIUM_DATADIR"/apertium.dat "apertium" "APER1000" "file_name" "$2"; exit 1; fi FLEXOPTS="-Cfer"; diff --git a/locales/root.txt b/locales/root.txt index f1c459b..5625a36 100644 --- a/locales/root.txt +++ b/locales/root.txt @@ -234,18 +234,22 @@ There are various postprocessors which remove implausible rungs based on various "Closes all word-bound blanks, turning [[...]]^...$ into [[...]]^...$[[/]]\n" "This tool does not merge across whitespace or do any other heuristics wrt. which word-bound blanks should have their spans combined.\n"} - deformat_desc{"USAGE: {first_line}\n" + deformat_desc{"USAGE: {first_line}\n" " -a: apertium standard mode\n" " -A: apertium optimized mode (default mode)\n" " -m: matxin standard mode\n" " -M: matxin optimized mode"} - trans_desc{"USAGE: [format [infile [outfile]]]\n" + trans_desc{"USAGE: [format [infile [outfile]]]\n" " datadir Directory of linguistic data\n" " translation LANG1-LANG2\n" " format one of: txt (default), txtu, html, htmlu, rtf, rtfu\n" " infile input file (stdin by default)\n" " outfile output file (stdout by default)"} some_failed_assertion{"some failed assertion: {what}"} + unformat_desc{"USAGE: {basename} [-f format] [in [out]]\n" + " -f format one of: txt (default), html, rtf, odt, docx, wxml, xlsx, pptx\n" + " in input file (stdin by default)\n" + " out output file (stdout by default)"} APER1000{"ERROR APER1000: Unable to access \"{file_name}\"."} APER1001{"ERROR APER1001: Unescaped \"^\": {buf}^"} APER1002{"ERROR APER1002: Stray \"$\""}