lang-import.sh 17 KB

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