lang-import.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. #!/bin/bash
  2. #
  3. # Version 1.0.1 Build 36
  4. #
  5. # lang-import.sh - multi-language support script
  6. # for importing translated xx.po
  7. #
  8. #############################################################################
  9. # Change log:
  10. # 9 Nov. 2018, XPila, Initial
  11. # 21 Nov. 2018, XPila, fix - replace '\n' with space in all languages
  12. # 10 Dec. 2018, jhoblitt, make all shell scripts executable
  13. # 21 Aug. 2019, 3d-gussner, Added "All" argument and it is default in nothing is chosen
  14. # Added few German/French diacritical characters
  15. # 6 Sep. 2019, DRracer, change to bash
  16. # 14 Sep. 2019, 3d-gussner, Prepare adding new language
  17. # 1 Mar. 2019, 3d-gussner, Move `Dutch` language parts
  18. # Add templates for future community languages
  19. # 17 Dec. 2021, 3d-gussner, Use one config file for all languages
  20. # Fix missing last translation
  21. # Add counter
  22. # replace two double quotes with `\x00`
  23. # 21 Dec. 2021, 3d-gussner, Add Swedish, Danish, Slovanian, Hungarian,
  24. # Luxembourgish, Croatian
  25. # 3 Jan. 2022, 3d-gussner, Add Lithuanian
  26. # Cleanup outaded code
  27. # 11 Jan. 2022, 3d-gussner, Added version and Change log
  28. # colored output
  29. # Add Community language support
  30. # Use `git rev-list --count HEAD lang-import.sh`
  31. # to get Build Nr
  32. # 14 Jan. 2022, 3d-gussner, Replace German UTF-8 'äöÿÿ' to HD44780 A00 ROM 'äöÿÿ'
  33. # 28 Jan. 2022, 3d-gussner, Run lang-check and output `xx-output.txt` file to review
  34. # translations
  35. # new argruments `--information` `--import-check`
  36. # 11 Jan. 2022, ingbrzy, Add Slovak letters
  37. # 11 Feb. 2022, 3d-gussner, Change to python3
  38. # 14 Feb. 2022, 3d-gussner, Replace non-block space with space
  39. # Fix single language run without config.sh OK
  40. #############################################################################
  41. echo "$(tput setaf 2)lang-import.sh started$(tput sgr 0)" >&2
  42. LNG=$1
  43. # if no arguments, 'all' is selected (all po and also pot will be generated)
  44. if [ -z "$LNG" ]; then
  45. LNG=all;
  46. # Config:
  47. if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
  48. if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo "$(tput setaf 1)Config NG!$(tput sgr 0)" >&2; exit 1; fi
  49. fi
  50. if [[ ! -z "$COMMUNITY_LANGUAGES" && "$LNG" = "all" ]]; then
  51. LANGUAGES+=" $COMMUNITY_LANGUAGES"
  52. else
  53. LANGUAGES="$LNG"
  54. fi
  55. echo "$(tput setaf 2)lang-import languages:$LANGUAGES$(tput sgr 0)" >&2
  56. # if 'all' is selected, script will generate all po files and also pot file
  57. if [ "$LNG" = "all" ]; then
  58. for lang in $LANGUAGES; do
  59. ./lang-import.sh $lang
  60. done
  61. exit 0
  62. fi
  63. # language code (iso639-1) is equal to LNG
  64. LNGISO=$LNG
  65. # exception for 'cz' (code='cs')
  66. if [ "$LNG" = "cz" ]; then LNGISO=cs; fi
  67. # cd to input folder
  68. cd po/new
  69. # check if input file exists
  70. if ! [ -e $LNGISO.po ]; then
  71. echo "$(tput setaf 1)Input file $LNGISO.po not found!$(tput sgr 0)" >&2
  72. exit -1
  73. fi
  74. #convert '\\e' sequencies to 'x1b' and '\\' to '\'
  75. cat $LNGISO.po | sed 's/\\e/\\x1b/g;s/\\\\/\\/g' > $LNG'_filtered.po'
  76. #replace '\n' with ' ' (single space)
  77. sed -i 's/ \\n/ /g;s/\\n/ /g' $LNG'_filtered.po'
  78. #replace in czech translation
  79. if [ "$LNG" = "cz" ]; then
  80. #replace 'Á' with 'A'
  81. sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po'
  82. #replace 'á' with 'a'
  83. sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
  84. #replace 'Č' with 'C'
  85. sed -i 's/\xc4\x8c/C/g' $LNG'_filtered.po'
  86. #replace 'č' with 'c'
  87. sed -i 's/\xc4\x8d/c/g' $LNG'_filtered.po'
  88. #replace 'Ď' with 'D'
  89. sed -i 's/\xc4\x8e/D/g' $LNG'_filtered.po'
  90. #replace 'ď' with 'd'
  91. sed -i 's/\xc4\x8f/d/g' $LNG'_filtered.po'
  92. #replace 'É' with 'E'
  93. sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
  94. #replace 'é' with 'e'
  95. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  96. #replace 'Ě' with 'E'
  97. sed -i 's/\xc4\x9a/E/g' $LNG'_filtered.po'
  98. #replace 'ě' with 'e'
  99. sed -i 's/\xc4\x9b/e/g' $LNG'_filtered.po'
  100. #replace 'Í' with 'I'
  101. sed -i 's/\xc3\x8d/I/g' $LNG'_filtered.po'
  102. #replace 'í' with 'i'
  103. sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
  104. #replace 'Ň' with 'N'
  105. sed -i 's/\xc5\x87/N/g' $LNG'_filtered.po'
  106. #replace 'ň' with 'n'
  107. sed -i 's/\xc5\x88/n/g' $LNG'_filtered.po'
  108. #replace 'Ó' with 'O'
  109. sed -i 's/\xc3\x93/O/g' $LNG'_filtered.po'
  110. #replace 'ó' with 'o'
  111. sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
  112. #replace 'Ř' with 'R'
  113. sed -i 's/\xc5\x98/R/g' $LNG'_filtered.po'
  114. #replace 'ř' with 'r'
  115. sed -i 's/\xc5\x99/r/g' $LNG'_filtered.po'
  116. #replace 'Š' with 'S'
  117. sed -i 's/\xc5\xa0/S/g' $LNG'_filtered.po'
  118. #replace 'š' with 's'
  119. sed -i 's/\xc5\xa1/s/g' $LNG'_filtered.po'
  120. #replace 'Ť' with 'T'
  121. sed -i 's/\xc5\xa4/T/g' $LNG'_filtered.po'
  122. #replace 'ť' with 't'
  123. sed -i 's/\xc5\xa5/t/g' $LNG'_filtered.po'
  124. #replace 'Ú' with 'U'
  125. sed -i 's/\xc3\x9a/U/g' $LNG'_filtered.po'
  126. #replace 'ú' with 'u'
  127. sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
  128. #replace 'Ů' with 'U'
  129. sed -i 's/\xc5\xae/U/g' $LNG'_filtered.po'
  130. #replace 'ů' with 'u'
  131. sed -i 's/\xc5\xaf/u/g' $LNG'_filtered.po'
  132. #replace 'Ý' with 'Y'
  133. sed -i 's/\xc3\x9d/Y/g' $LNG'_filtered.po'
  134. #replace 'ý' with 'y'
  135. sed -i 's/\xc3\xbd/y/g' $LNG'_filtered.po'
  136. #replace 'Ž' with 'Z'
  137. sed -i 's/\xc5\xbd/Z/g' $LNG'_filtered.po'
  138. #replace 'ž' with 'z'
  139. sed -i 's/\xc5\xbe/z/g' $LNG'_filtered.po'
  140. fi
  141. #replace in german translation https://en.wikipedia.org/wiki/German_orthography
  142. if [ "$LNG" = "de" ]; then
  143. #replace UTF-8 'äöüß' to HD44780 A00 'äöüß'
  144. #replace 'ä' with 'A00 ROM ä'
  145. sed -i 's/\xc3\xa4/\\xe1/g' $LNG'_filtered.po'
  146. #replace 'Ä' with 'A00 ROM ä'
  147. sed -i 's/\xc3\x84/\\xe1/g' $LNG'_filtered.po'
  148. #replace 'ü' with 'A00 ROM ü'
  149. sed -i 's/\xc3\xbc/\\xf5/g' $LNG'_filtered.po'
  150. #replace 'Ü' with 'A00 ROM ü'
  151. sed -i 's/\xc3\x9c/\\xf5/g' $LNG'_filtered.po'
  152. #replace 'ö' with 'A00 ROM ö'
  153. sed -i 's/\xc3\xb6/\\xef/g' $LNG'_filtered.po'
  154. #replace 'Ö' with 'A00 ROM ö'
  155. sed -i 's/\xc3\x96/\\xef/g' $LNG'_filtered.po'
  156. #replace 'ß' with 'A00 ROM ß'
  157. sed -i 's/\xc3\x9f/\\xe2/g' $LNG'_filtered.po'
  158. fi
  159. #replace in spain translation
  160. if [ "$LNG" = "es" ]; then
  161. #replace 'á' with 'a'
  162. sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
  163. #replace '¿' with '?'
  164. sed -i 's/\xc2\xbf/?/g' $LNG'_filtered.po'
  165. #replace 'ó' with 'o'
  166. sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
  167. #replace 'é' with 'e'
  168. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  169. #replace 'í' with 'i'
  170. sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
  171. #replace '!' with '!'
  172. sed -i 's/\xc2\xa1/!/g' $LNG'_filtered.po'
  173. #replace 'n~' with 'n'
  174. sed -i 's/\xc3\xb1/n/g' $LNG'_filtered.po'
  175. fi
  176. #replace in french translation https://en.wikipedia.org/wiki/French_orthography
  177. if [ "$LNG" = "fr" ]; then
  178. #replace 'á' with 'a' (right)
  179. sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
  180. #replace 'Á' with 'A' (right)
  181. sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po'
  182. #replace 'à' with 'a' (left)
  183. sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po'
  184. #replace 'À' with 'A' (left)
  185. sed -i 's/\xc3\x80/A/g' $LNG'_filtered.po'
  186. #replace 'é' with 'e' (right)
  187. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  188. #replace 'É' with 'E' (right)
  189. sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
  190. #replace 'è' with 'e' (left)
  191. sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
  192. #replace 'È' with 'E' (left)
  193. sed -i 's/\xc3\x88/E/g' $LNG'_filtered.po'
  194. fi
  195. #replace in italian translation
  196. if [ "$LNG" = "it" ]; then
  197. #replace 'é' with 'e' (left)
  198. sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
  199. #replace 'á' with 'a' (left)
  200. sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po'
  201. #replace 'ó' with 'o' (left)
  202. sed -i 's/\xc3\xb2/o/g' $LNG'_filtered.po'
  203. #replace 'ú' with 'u' (left)
  204. sed -i 's/\xc3\xb9/u/g' $LNG'_filtered.po'
  205. #replace 'é' with 'e'
  206. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  207. #replace 'É' with 'E' (left)
  208. sed -i 's/\xc3\x88/E/g' $LNG'_filtered.po'
  209. fi
  210. #replace in dutch translation according to https://nl.wikipedia.org/wiki/Accenttekens_in_de_Nederlandse_spelling
  211. if [ "$LNG" = "nl" ]; then
  212. #replace 'ë' with 'e'
  213. sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
  214. #replace 'ï' with 'i'
  215. sed -i 's/\xc3\xaf/i/g' $LNG'_filtered.po'
  216. #replace 'é' with 'e'
  217. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  218. #replace 'è' with 'e' (left)
  219. sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
  220. #replace 'ö' with 'o' (left)
  221. sed -i 's/\xc3\xb6/o/g' $LNG'_filtered.po'
  222. #replace 'ê' with 'e' (left)
  223. sed -i 's/\xc3\xaa/e/g' $LNG'_filtered.po'
  224. #replace 'ü' with 'u' (left)
  225. sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po'
  226. #replace 'ç' with 'c' (left)
  227. sed -i 's/\xc3\xa7/c/g' $LNG'_filtered.po'
  228. #replace 'á' with 'a' (left)
  229. sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
  230. #replace 'à' with 'a' (left)
  231. sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po'
  232. #replace 'ä' with 'a' (left)
  233. sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
  234. #replace 'û' with 'u' (left)
  235. sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po'
  236. #replace 'î' with 'i' (left)
  237. sed -i 's/\xc3\xae/i/g' $LNG'_filtered.po'
  238. #replace 'í' with 'i' (left)
  239. sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
  240. #replace 'ô' with 'o' (left)
  241. sed -i 's/\xc3\xb4/o/g' $LNG'_filtered.po'
  242. #replace 'ú' with 'u' (left)
  243. sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
  244. #replace 'ñ' with 'n' (left)
  245. sed -i 's/\xc3\xb1/n/g' $LNG'_filtered.po'
  246. #replace 'â' with 'a' (left)
  247. sed -i 's/\xc3\xa2/a/g' $LNG'_filtered.po'
  248. #replace 'Å' with 'A' (left)
  249. sed -i 's/\xc3\x85/A/g' $LNG'_filtered.po'
  250. fi
  251. if [ "$LNG" = "sv" ]; then
  252. #repace 'Å' with 'Aa'
  253. sed -i 's/\xc3\x85/Aa/g' $LNG'_filtered.po'
  254. #repace 'å' with 'aa'
  255. sed -i 's/\xc3\xA5/aa/g' $LNG'_filtered.po'
  256. fi
  257. #https://en.wikipedia.org/wiki/Norwegian_orthography éèêóòôù ÅåÆæØø
  258. if [ "$LNG" = "no" ]; then
  259. #repace 'Å' with 'A'
  260. sed -i 's/\xc3\x85/A/g' $LNG'_filtered.po'
  261. #repace 'å' with 'a'
  262. sed -i 's/\xc3\xA5/a/g' $LNG'_filtered.po'
  263. #repace 'Æ' with 'Ae'
  264. sed -i 's/\xc3\x86/A/g' $LNG'_filtered.po'
  265. #repace 'æ' with 'ae'
  266. sed -i 's/\xc3\xa6/a/g' $LNG'_filtered.po'
  267. #repace 'Ø' with 'O'
  268. sed -i 's/\xc3\x98/O/g' $LNG'_filtered.po'
  269. #repace 'ø' with 'o'
  270. sed -i 's/\xc3\xb8/o/g' $LNG'_filtered.po'
  271. #replace 'é' with 'e'
  272. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  273. #replace 'è' with 'e'
  274. sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
  275. #replace 'ê' with 'e'
  276. sed -i 's/\xc3\xaa/e/g' $LNG'_filtered.po'
  277. #replace 'ó' with 'o'
  278. sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
  279. #replace 'ò' with 'o'
  280. sed -i 's/\xc3\xb2/o/g' $LNG'_filtered.po'
  281. #replace 'ô' with 'o'
  282. sed -i 's/\xc3\xb4/o/g' $LNG'_filtered.po'
  283. #replace 'ù' with 'u'
  284. sed -i 's/\xc3\xb9/u/g' $LNG'_filtered.po'
  285. fi
  286. if [ "$LNG" = "da" ]; then
  287. #repace 'Å' with 'Aa'
  288. sed -i 's/\xc3\x85/Aa/g' $LNG'_filtered.po'
  289. #repace 'å' with 'aa'
  290. sed -i 's/\xc3\xA5/aa/g' $LNG'_filtered.po'
  291. fi
  292. if [ "$LNG" = "sl" ]; then
  293. #replace 'ë' with 'e'
  294. sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
  295. #replace 'ä' with 'a' (left)
  296. sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
  297. #replace 'é' with 'e'
  298. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  299. fi
  300. if [ "$LNG" = "hu" ]; then # See https://www.fileformat.info/info/charset/UTF-8/list.htm
  301. #replace 'Á' with 'A'(acute)
  302. sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po'
  303. #replace 'á' with 'a'
  304. sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
  305. #replace 'É' with 'E' (acute)
  306. sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
  307. #replace 'é' with 'e'
  308. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  309. #replace 'Í' with 'I' (acute)
  310. sed -i 's/\xc3\x8d/I/g' $LNG'_filtered.po'
  311. #replace 'i̇́' with 'i'
  312. sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
  313. #replace 'Ó' with 'O' (acute)
  314. sed -i 's/\xc3\x93/O/g' $LNG'_filtered.po'
  315. #replace 'ó' with 'o'
  316. sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
  317. #replace 'Ö' with 'O' (diaresis)
  318. sed -i 's/\xc3\x96/O/g' $LNG'_filtered.po'
  319. #replace 'ö' with 'o'
  320. sed -i 's/\xc3\xb6/o/g' $LNG'_filtered.po'
  321. #replace 'Ő' with 'O' (double acute)
  322. sed -i 's/\xc5\x90/O/g' $LNG'_filtered.po'
  323. #replace 'ő' with 'o'
  324. sed -i 's/\xc5\x91/o/g' $LNG'_filtered.po'
  325. #replace 'Ú' with 'U' (acute)
  326. sed -i 's/\xc3\x9a/U/g' $LNG'_filtered.po'
  327. #replace 'ú' with 'u'
  328. sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
  329. #replace 'Ü' with 'U' (diaersis)
  330. sed -i 's/\xc3\x9c/U/g' $LNG'_filtered.po'
  331. #replace 'ü' with 'u'
  332. sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po'
  333. #replace 'Ű' with 'U' (double acute)
  334. sed -i 's/\xc5\xb0/U/g' $LNG'_filtered.po'
  335. #replace 'ű' with 'u'
  336. sed -i 's/\xc5\xb1/u/g' $LNG'_filtered.po'
  337. fi
  338. if [ "$LNG" = "lb" ]; then
  339. #replace 'ë' with 'e'
  340. sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
  341. #replace 'ä' with 'a'
  342. sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
  343. #replace 'é' with 'e'
  344. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  345. fi
  346. if [ "$LNG" = "hr" ]; then
  347. #replace 'ë' with 'e'
  348. sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
  349. #replace 'ä' with 'a'
  350. sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
  351. #replace 'é' with 'e'
  352. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  353. fi
  354. if [ "$LNG" = "lt" ]; then
  355. #replace 'ë' with 'e'
  356. sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
  357. #replace 'ä' with 'a'
  358. sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
  359. #replace 'é' with 'e'
  360. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  361. fi
  362. #replace in polish translation
  363. #if [ "$LNG" = "pl" ]; then
  364. #fi
  365. #replace in slovak translation
  366. if [ "$LNG" = "sk" ]; then
  367. #replace 'Á' with 'A'
  368. sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po'
  369. #replace 'á' with 'a'
  370. sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
  371. #replace 'ä' with 'a'
  372. sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
  373. #replace 'Č' with 'C'
  374. sed -i 's/\xc4\x8c/C/g' $LNG'_filtered.po'
  375. #replace 'č' with 'c'
  376. sed -i 's/\xc4\x8d/c/g' $LNG'_filtered.po'
  377. #replace 'Ď' with 'D'
  378. sed -i 's/\xc4\x8e/D/g' $LNG'_filtered.po'
  379. #replace 'ď' with 'd'
  380. sed -i 's/\xc4\x8f/d/g' $LNG'_filtered.po'
  381. #replace 'É' with 'E'
  382. sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
  383. #replace 'é' with 'e'
  384. sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
  385. #replace 'Í' with 'I'
  386. sed -i 's/\xc3\x8d/I/g' $LNG'_filtered.po'
  387. #replace 'í' with 'i'
  388. sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
  389. #replace 'ľ' with 'l'
  390. sed -i 's/\xc4\xbe/l/g' $LNG'_filtered.po'
  391. #replace 'Ľ' with 'L'
  392. sed -i 's/\xc4\xbd/L/g' $LNG'_filtered.po'
  393. #replace 'Ň' with 'N'
  394. sed -i 's/\xc5\x87/N/g' $LNG'_filtered.po'
  395. #replace 'ň' with 'n'
  396. sed -i 's/\xc5\x88/n/g' $LNG'_filtered.po'
  397. #replace 'Ó' with 'O'
  398. sed -i 's/\xc3\x93/O/g' $LNG'_filtered.po'
  399. #replace 'ó' with 'o'
  400. sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
  401. #replace 'ô' with 'o'
  402. sed -i 's/\xc3\xb4/o/g' $LNG'_filtered.po'
  403. #replace 'Ô' with 'O'
  404. sed -i 's/\xc3\x94/O/g' $LNG'_filtered.po'
  405. #replace 'ŕ' with 'r'
  406. sed -i 's/\xc5\x95/r/g' $LNG'_filtered.po'
  407. #replace 'Ŕ' with 'R'
  408. sed -i 's/\xc5\x94/R/g' $LNG'_filtered.po'
  409. #replace 'Š' with 'S'
  410. sed -i 's/\xc5\xa0/S/g' $LNG'_filtered.po'
  411. #replace 'š' with 's'
  412. sed -i 's/\xc5\xa1/s/g' $LNG'_filtered.po'
  413. #replace 'Ť' with 'T'
  414. sed -i 's/\xc5\xa4/T/g' $LNG'_filtered.po'
  415. #replace 'ť' with 't'
  416. sed -i 's/\xc5\xa5/t/g' $LNG'_filtered.po'
  417. #replace 'Ú' with 'U'
  418. sed -i 's/\xc3\x9a/U/g' $LNG'_filtered.po'
  419. #replace 'ú' with 'u'
  420. sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
  421. #replace 'Ý' with 'Y'
  422. sed -i 's/\xc3\x9d/Y/g' $LNG'_filtered.po'
  423. #replace 'ý' with 'y'
  424. sed -i 's/\xc3\xbd/y/g' $LNG'_filtered.po'
  425. #replace 'Ž' with 'Z'
  426. sed -i 's/\xc5\xbd/Z/g' $LNG'_filtered.po'
  427. #replace 'ž' with 'z'
  428. sed -i 's/\xc5\xbe/z/g' $LNG'_filtered.po'
  429. fi
  430. #replace UTF-8 'μ' to HD44780 A00 'μ'
  431. #replace 'μ' with 'A00 ROM μ'
  432. sed -i 's/\xce\xbc/\\xe4/g' $LNG'_filtered.po'
  433. #replace non-break space with space
  434. sed -i 's/\xc2\xa0/ /g' $LNG'_filtered.po'
  435. #check for nonasci characters except HD44780 ROM A00 'äöüß'
  436. if grep --color='auto' -P -n '[^\x00-\x7F]' $LNG'_filtered.po' >nonascii.txt; then
  437. exit
  438. fi
  439. #join lines with multi-line string constants
  440. cat $LNG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LNG'_new.po'
  441. #Get counter from po files
  442. CNTTXT=$(grep '^# MSG' -c $LNGISO.po)
  443. num=1
  444. echo " selected language=$(tput setaf 2)$LNGISO$(tput sgr 0)" >&2
  445. #generate new dictionary
  446. cat ../../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
  447. /bin/echo -e "$s"
  448. #echo "s = $s ." >&2
  449. if [ "${s:0:1}" = "\"" ]; then
  450. # /bin/echo -e "$s"
  451. s=$(/bin/echo -e "$s")
  452. s2=$(grep -F -A1 -B0 "msgid $s" "$LNG"_new.po | tail -n1 | sed 's/^msgstr //')
  453. if [ -z "$s2" ]; then
  454. echo -ne " processing $num of $CNTTXT\033[0K\r" >&2
  455. echo '"\x00"'
  456. num=$((num+1))
  457. else
  458. echo -ne " processing $num of $CNTTXT\033[0K\r" >&2
  459. echo "$s2"
  460. num=$((num+1))
  461. fi
  462. # echo
  463. fi
  464. done > lang_en_$LNG.txt
  465. echo >&2
  466. echo "$(tput setaf 2)Finished with $LNGISO$(tput sgr 0)" >&2
  467. #replace two double quotes to "\x00"
  468. sed -i 's/""/"\\x00"/g' lang_en_$LNG.txt
  469. #remove CR
  470. sed -i "s/\r//g" lang_en_$LNG.txt
  471. #check new lang
  472. python3 ../../lang-check.py $LNG --warn-empty
  473. python3 ../../lang-check.py $LNG --information >$LNG-output.txt
  474. echo >&2
  475. echo "$(tput setaf 2)lang-import.sh finished$(tput sgr 0)">&2