lang-import.sh 17 KB

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