eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tr_languages.cpp 62KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. /***************************************************************************
  2. * Copyright (C) 2005 to 2011 by Jonathan Duddington *
  3. * email: [email protected] *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 3 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, see: *
  17. * <http://www.gnu.org/licenses/>. *
  18. ***************************************************************************/
  19. #include "StdAfx.h"
  20. #include <stdio.h>
  21. #include <ctype.h>
  22. #include <wctype.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <locale.h>
  26. #include <wctype.h>
  27. #include "speak_lib.h"
  28. #include "speech.h"
  29. #include "phoneme.h"
  30. #include "synthesize.h"
  31. #include "translate.h"
  32. #define L_qa 0x716100
  33. #define L_grc 0x677263 // grc Ancient Greek
  34. #define L_jbo 0x6a626f // jbo Lojban
  35. #define L_pap 0x706170 // pap Papiamento]
  36. #define L_qvi 0x717669 // qvi Kichwa
  37. #define L_shs 0x736873 // shs Shuswap / Secwepemctsin
  38. #define L_zhy 0x7a6879 // zhy
  39. // start of unicode pages for character sets
  40. #define OFFSET_GREEK 0x380
  41. #define OFFSET_CYRILLIC 0x420
  42. #define OFFSET_ARMENIAN 0x530
  43. #define OFFSET_ARABIC 0x600
  44. #define OFFSET_THAANA 0x780 // Divehi/Maldives
  45. #define OFFSET_DEVANAGARI 0x900
  46. #define OFFSET_BENGALI 0x980
  47. #define OFFSET_GURMUKHI 0xa00
  48. #define OFFSET_GUJARATI 0xa80
  49. #define OFFSET_ORIYA 0xb00
  50. #define OFFSET_TAMIL 0xb80
  51. #define OFFSET_TELUGU 0xc00
  52. #define OFFSET_KANNADA 0xc80
  53. #define OFFSET_MALAYALAM 0xd00
  54. #define OFFSET_SINHALA 0x0d80
  55. #define OFFSET_TIBET 0x0f00
  56. #define OFFSET_GEORGIAN 0x1080
  57. #define OFFSET_KOREAN 0x1100
  58. #define OFFSET_ETHIOPIC 0x1200
  59. static void Translator_Russian(Translator *tr);
  60. static void SetLetterVowel(Translator *tr, int c)
  61. {//==============================================
  62. tr->letter_bits[c] = (tr->letter_bits[c] & 0x40) | 0x81; // keep value for group 6 (front vowels e,i,y)
  63. }
  64. static void ResetLetterBits(Translator *tr, int groups)
  65. {//====================================================
  66. // Clear all the specified groups
  67. unsigned int ix;
  68. unsigned int mask;
  69. mask = ~groups;
  70. for(ix=0; ix<sizeof(tr->letter_bits); ix++)
  71. {
  72. tr->letter_bits[ix] &= mask;
  73. }
  74. }
  75. static void SetLetterBits(Translator *tr, int group, const char *string)
  76. {//=====================================================================
  77. int bits;
  78. unsigned char c;
  79. bits = (1L << group);
  80. while((c = *string++) != 0)
  81. tr->letter_bits[c] |= bits;
  82. }
  83. static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
  84. {//===========================================================================
  85. int bits;
  86. int ix;
  87. bits = (1L << group);
  88. for(ix=first; ix<=last; ix++)
  89. {
  90. tr->letter_bits[ix] |= bits;
  91. }
  92. }
  93. // ignore these characters
  94. static const unsigned short chars_ignore_default[] = {
  95. 0xad, 1, // soft hyphtn
  96. 0x200c, 1, // zero width non-joiner
  97. 0x200d, 1, // zero width joiner
  98. 0, 0 };
  99. // alternatively, ignore characters but allow zero-width-non-joiner (lang-fa)
  100. static const unsigned short chars_ignore_zwnj_hyphen[] = {
  101. 0xad, 1, // soft hyphen
  102. 0x200c, '-', // zero width non-joiner, replace with hyphen
  103. 0x200d, 1, // zero width joiner
  104. 0, 0 };
  105. static Translator* NewTranslator(void)
  106. {//===================================
  107. Translator *tr;
  108. int ix;
  109. static const unsigned char stress_amps2[] = {18,18, 20,20, 20,22, 22,20 };
  110. static const short stress_lengths2[8] = {182,140, 220,220, 220,240, 260,280};
  111. static const wchar_t empty_wstring[1] = {0};
  112. static const wchar_t punct_in_word[2] = {'\'', 0}; // allow hyphen within words
  113. static const unsigned char default_tunes[6] = {0, 1, 2, 3, 0, 0};
  114. tr = (Translator *)Alloc(sizeof(Translator));
  115. if(tr == NULL)
  116. return(NULL);
  117. tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8
  118. dictionary_name[0] = 0;
  119. tr->dict_condition=0;
  120. tr->data_dictrules = NULL; // language_1 translation rules file
  121. tr->data_dictlist = NULL; // language_2 dictionary lookup file
  122. tr->transpose_min = 'a';
  123. tr->transpose_max = 'z';
  124. tr->frequent_pairs = NULL;
  125. // only need lower case
  126. tr->letter_bits_offset = 0;
  127. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  128. memset(tr->letter_groups,0,sizeof(tr->letter_groups));
  129. // 0-6 sets of characters matched by A B C H F G Y in pronunciation rules
  130. // these may be set differently for different languages
  131. SetLetterBits(tr,0,"aeiou"); // A vowels, except y
  132. SetLetterBits(tr,1,"bcdfgjklmnpqstvxz"); // B hard consonants, excluding h,r,w
  133. SetLetterBits(tr,2,"bcdfghjklmnpqrstvwxz"); // C all consonants
  134. SetLetterBits(tr,3,"hlmnr"); // H 'soft' consonants
  135. SetLetterBits(tr,4,"cfhkpqstx"); // F voiceless consonants
  136. SetLetterBits(tr,5,"bdgjlmnrvwyz"); // G voiced
  137. SetLetterBits(tr,6,"eiy"); // Letter group Y, front vowels
  138. SetLetterBits(tr,7,"aeiouy"); // vowels, including y
  139. tr->char_plus_apostrophe = empty_wstring;
  140. tr->punct_within_word = punct_in_word;
  141. tr->chars_ignore = chars_ignore_default;
  142. for(ix=0; ix<8; ix++)
  143. {
  144. tr->stress_amps[ix] = stress_amps2[ix];
  145. tr->stress_amps_r[ix] = stress_amps2[ix] - 1;
  146. tr->stress_lengths[ix] = stress_lengths2[ix];
  147. }
  148. memset(&(tr->langopts),0,sizeof(tr->langopts));
  149. tr->langopts.max_lengthmod = 500;
  150. tr->langopts.lengthen_tonic = 20;
  151. tr->langopts.stress_rule = STRESSPOSN_2R;
  152. tr->langopts.unstressed_wd1 = 1;
  153. tr->langopts.unstressed_wd2 = 3;
  154. tr->langopts.param[LOPT_SONORANT_MIN] = 95;
  155. tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 190/2;
  156. tr->langopts.param[LOPT_MAXAMP_EOC] = 19;
  157. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 's'; // don't count this character at start of word
  158. tr->langopts.param[LOPT_BRACKET_PAUSE] = 4; // pause at bracket
  159. tr->langopts.param2[LOPT_BRACKET_PAUSE] = 2; // pauses when announcing bracket names
  160. tr->langopts.max_initial_consonants = 3;
  161. tr->langopts.replace_chars = NULL;
  162. tr->langopts.ascii_language = ""; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
  163. SetLengthMods(tr,201);
  164. // tr->langopts.length_mods = length_mods_en;
  165. // tr->langopts.length_mods0 = length_mods_en0;
  166. tr->langopts.long_stop = 100;
  167. tr->langopts.max_roman = 49;
  168. tr->langopts.min_roman = 2;
  169. tr->langopts.thousands_sep = ',';
  170. tr->langopts.decimal_sep = '.';
  171. tr->langopts.break_numbers = BREAK_THOUSANDS; // 1000, 1000,000 1,000,000 etc
  172. tr->langopts.max_digits = 14;
  173. memcpy(tr->punct_to_tone, punctuation_to_tone, sizeof(tr->punct_to_tone));
  174. memcpy(tr->langopts.tunes, default_tunes, sizeof(tr->langopts.tunes));
  175. return(tr);
  176. }
  177. // common letter pairs, encode these as a single byte
  178. // 2 bytes, using the transposed character codes
  179. static const short pairs_ru[] = {
  180. 0x010c, // ла 21052 0x23
  181. 0x010e, // на 18400
  182. 0x0113, // та 14254
  183. 0x0301, // ав 31083
  184. 0x030f, // ов 13420
  185. 0x060e, // не 21798
  186. 0x0611, // ре 19458
  187. 0x0903, // ви 16226
  188. 0x0b01, // ак 14456
  189. 0x0b0f, // ок 17836
  190. 0x0c01, // ал 13324
  191. 0x0c09, // ил 16877
  192. 0x0e01, // ан 15359
  193. 0x0e06, // ен 13543 0x30
  194. 0x0e09, // ин 17168
  195. 0x0e0e, // нн 15973
  196. 0x0e0f, // он 22373
  197. 0x0e1c, // ын 15052
  198. 0x0f03, // во 24947
  199. 0x0f11, // ро 13552
  200. 0x0f12, // со 16368
  201. 0x100f, // оп 19054
  202. 0x1011, // рп 17067
  203. 0x1101, // ар 23967
  204. 0x1106, // ер 18795
  205. 0x1109, // ир 13797
  206. 0x110f, // ор 21737
  207. 0x1213, // тс 25076
  208. 0x1220, // яс 14310
  209. 0x7fff};
  210. //0x040f ог 12976
  211. //0x1306 ет 12826
  212. //0x0f0d мо 12688
  213. static const unsigned int replace_cyrillic_latin[] =
  214. {0x430,'a',
  215. 0x431,'b',
  216. 0x446,'c',
  217. 0x45b,0x107,
  218. 0x447,0x10d,
  219. 0x45f,'d'+(0x17e<<16),
  220. 0x455,'d'+('z'<<16),
  221. 0x434,'d',
  222. 0x452,0x111,
  223. 0x435,'e',
  224. 0x444,'f',
  225. 0x433,'g',
  226. 0x445,'h',
  227. 0x438,'i',
  228. 0x458,'j',
  229. 0x43a,'k',
  230. 0x459,'l'+('j'<<16),
  231. 0x43b,'l',
  232. 0x43c,'m',
  233. 0x45a,'n'+('j'<<16),
  234. 0x43d,'n',
  235. 0x43e,'o',
  236. 0x43f,'p',
  237. 0x440,'r',
  238. 0x441,'s',
  239. 0x448,0x161,
  240. 0x442,'t',
  241. 0x443,'u',
  242. 0x432,'v',
  243. 0x437,'z',
  244. 0x436,0x17e,
  245. 0x453,0x111,
  246. 0x45c,0x107,
  247. 0}; // ѓ ѕ ќ
  248. static const unsigned char ru_vowels[] = {0x10,0x15,0x31,0x18,0x1e,0x23,0x2b,0x2d,0x2e,0x2f, 0xb9,0xc9,0x91,0x8f,0x36,0}; //also kazakh
  249. static const unsigned char ru_consonants[] = {0x11,0x12,0x13,0x14,0x16,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2c, 0x73,0x7b,0x83,0x9b,0};
  250. static void SetCyrillicLetters(Translator *tr)
  251. {//===========================================
  252. // character codes offset by 0x420
  253. static const char ru_soft[] = {0x2c,0x19,0x27,0x29,0}; // letter group B [k ts; s;]
  254. static const char ru_hard[] = {0x2a,0x16,0x26,0x28,0}; // letter group H [S Z ts]
  255. static const char ru_nothard[] = {0x11,0x12,0x13,0x14,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x27,0x29,0x2c,0};
  256. static const char ru_voiced[] = {0x11,0x12,0x13,0x14,0x16,0x17,0}; // letter group G (voiced obstruents)
  257. static const char ru_ivowels[] = {0x2c,0x2e,0x2f,0x31,0}; // letter group Y (iotated vowels & soft-sign)
  258. tr->charset_a0 = charsets[18]; // KOI8-R
  259. tr->transpose_min = 0x430; // convert cyrillic from unicode into range 0x01 to 0x22
  260. tr->transpose_max = 0x451;
  261. tr->frequent_pairs = pairs_ru;
  262. tr->letter_bits_offset = OFFSET_CYRILLIC;
  263. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  264. SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
  265. SetLetterBits(tr,LETTERGP_B,ru_soft);
  266. SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
  267. SetLetterBits(tr,LETTERGP_H,ru_hard);
  268. SetLetterBits(tr,LETTERGP_F,ru_nothard);
  269. SetLetterBits(tr,LETTERGP_G,ru_voiced);
  270. SetLetterBits(tr,LETTERGP_Y,ru_ivowels);
  271. SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
  272. } // end of SetCyrillicLetters
  273. void SetIndicLetters(Translator *tr)
  274. {//=================================
  275. // Set letter types for Indic scripts, Devanagari, Tamill, etc
  276. static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x7b,0x7c,0x7e,0x7f,0};
  277. static const char dev_vowels2[] = {0x60,0x61, 0x55,0x56,0x57,0x62,0x63,0}; // non-consecutive vowels and vowel-signs
  278. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  279. SetLetterBitsRange(tr,LETTERGP_A,0x04,0x14); // vowel letters
  280. SetLetterBitsRange(tr,LETTERGP_A,0x3e,0x4d); // + vowel signs, and virama
  281. SetLetterBits(tr,LETTERGP_A, dev_vowels2); // + extra vowels and vowel signs
  282. SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs, and virama
  283. SetLetterBits(tr,LETTERGP_B, dev_vowels2); // + extra vowels and vowel signs
  284. SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
  285. SetLetterBits(tr,LETTERGP_C,dev_consonants2); // + additional consonants
  286. SetLetterBitsRange(tr,LETTERGP_Y,0x04,0x14); // vowel letters
  287. SetLetterBitsRange(tr,LETTERGP_Y,0x3e,0x4c); // + vowel signs
  288. SetLetterBits(tr,LETTERGP_Y, dev_vowels2); // + extra vowels and vowel signs
  289. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  290. tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4d; //virama
  291. }
  292. void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
  293. {//==================================================================================
  294. if(lengths != NULL)
  295. memcpy(tr->stress_lengths,lengths,sizeof(tr->stress_lengths));
  296. if(amps != NULL)
  297. memcpy(tr->stress_amps,amps,sizeof(tr->stress_amps));
  298. }
  299. Translator *SelectTranslator(const char *name)
  300. {//===========================================
  301. int name2 = 0;
  302. Translator *tr;
  303. static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 190, 240};
  304. static const unsigned char stress_amps_fr[8] = {18,16, 18,18, 18,18, 18,18 };
  305. static const unsigned char stress_amps_sk[8] = {17,16, 20,20, 20,22, 22,21 };
  306. static const short stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210};
  307. static const short stress_lengths_ta[8] = {200, 200, 210, 210, 0, 0, 230, 230};
  308. static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };
  309. // convert name string into a word of up to 4 characters, for the switch()
  310. while(*name != 0)
  311. name2 = (name2 << 8) + *name++;
  312. tr = NewTranslator();
  313. switch(name2)
  314. {
  315. case L('a','f'):
  316. {
  317. static const short stress_lengths_af[8] = {170,140, 220,220, 0, 0, 250,270};
  318. SetupTranslator(tr,stress_lengths_af,NULL);
  319. tr->langopts.stress_rule = STRESSPOSN_1L;
  320. tr->langopts.vowel_pause = 0x30;
  321. tr->langopts.param[LOPT_DIERESES] = 1;
  322. tr->langopts.param[LOPT_PREFIXES] = 1;
  323. SetLetterVowel(tr,'y'); // add 'y' to vowels
  324. tr->langopts.numbers = NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_ROMAN | NUM_1900;
  325. tr->langopts.accents = 1;
  326. }
  327. break;
  328. case L('a','m'): // Amharic, Ethiopia
  329. {
  330. SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
  331. tr->letter_bits_offset = OFFSET_ETHIOPIC;
  332. tr->langopts.stress_rule = STRESSPOSN_1L;
  333. tr->langopts.stress_flags = 0x0024; // don't use secondary stress
  334. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  335. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  336. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  337. }
  338. break;
  339. case L('a','r'): // Arabic
  340. tr->letter_bits_offset = OFFSET_ARABIC;
  341. tr->langopts.numbers = NUM_SWAP_TENS | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED | NUM_THOUSAND_AND | NUM_OMIT_1_THOUSAND;
  342. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  343. break;
  344. case L('b','g'): //Bulgarian
  345. {
  346. SetCyrillicLetters(tr);
  347. SetLetterVowel(tr,0x2a);
  348. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  349. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x107; // devoice at end of word, and change voicing to match a following consonant (except v)
  350. tr->langopts.param[LOPT_REDUCE] = 2;
  351. tr->langopts.stress_rule = STRESSPOSN_2R;
  352. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_SINGLE_AND | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS ;
  353. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  354. }
  355. break;
  356. case L('b','n'): // Bengali
  357. {
  358. static const short stress_lengths_bn[8] = {180, 180, 210, 210, 0, 0, 230, 240};
  359. static const unsigned char stress_amps_bn[8] = {18,18, 18,18, 20,20, 22,22 };
  360. SetupTranslator(tr,stress_lengths_bn,stress_amps_bn);
  361. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  362. tr->langopts.stress_rule = STRESSPOSN_1L;
  363. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  364. tr->letter_bits_offset = OFFSET_BENGALI;
  365. SetIndicLetters(tr); // call this after setting OFFSET_BENGALI
  366. SetLetterBitsRange(tr,LETTERGP_F,0x3e,0x4c); // vowel signs, but not virama
  367. tr->langopts.numbers = 0x1;
  368. tr->langopts.break_numbers = 0x24924aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  369. }
  370. break;
  371. case L('b','o'): // Tibet
  372. {
  373. tr->langopts.stress_rule = STRESSPOSN_1L;
  374. tr->letter_bits_offset = OFFSET_TIBET;
  375. SetLetterBitsRange(tr,LETTERGP_A,0x71,0x7d); // vowel signs
  376. SetLetterBitsRange(tr,LETTERGP_B,0x71,0x81); // vowel signs and subjoined letters
  377. SetLetterBitsRange(tr,LETTERGP_B,0x90,0xbc);
  378. SetLetterBitsRange(tr,LETTERGP_C,0x40,0x6c); // consonant letters (not subjoined)
  379. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  380. tr->langopts.numbers = 1;
  381. }
  382. break;
  383. case L('c','y'): // Welsh
  384. {
  385. static const short stress_lengths_cy[8] = {170,220, 180,180, 0, 0, 250,270};
  386. static const unsigned char stress_amps_cy[8] = {17,15, 18,18, 0,0, 22,20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  387. SetupTranslator(tr,stress_lengths_cy,stress_amps_cy);
  388. tr->charset_a0 = charsets[14]; // ISO-8859-14
  389. // tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  390. tr->langopts.stress_rule = STRESSPOSN_2R;
  391. // tr->langopts.intonation_group = 4;
  392. // 'diminished' is an unstressed final syllable
  393. tr->langopts.stress_flags = 0x6 | 0x10;
  394. tr->langopts.unstressed_wd1 = 0;
  395. tr->langopts.unstressed_wd2 = 2;
  396. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  397. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  398. SetLetterVowel(tr,'w'); // add letter to vowels and remove from consonants
  399. SetLetterVowel(tr,'y');
  400. }
  401. break;
  402. case L('d','a'): // Danish
  403. {
  404. static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,230};
  405. SetupTranslator(tr,stress_lengths_da,NULL);
  406. tr->langopts.stress_rule = STRESSPOSN_1L;
  407. tr->langopts.param[LOPT_PREFIXES] = 1;
  408. SetLetterVowel(tr,'y');
  409. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
  410. }
  411. break;
  412. case L('d','e'):
  413. {
  414. static const short stress_lengths_de[8] = {150,130, 200,200, 0, 0, 270,270};
  415. static const unsigned char stress_amps_de[] = {20,20, 20,20, 20,22, 22,20 };
  416. SetupTranslator(tr, stress_lengths_de, stress_amps_de);
  417. tr->langopts.stress_rule = STRESSPOSN_1L;
  418. tr->langopts.word_gap = 0x8; // don't use linking phonemes
  419. tr->langopts.vowel_pause = 0x30;
  420. tr->langopts.param[LOPT_PREFIXES] = 1;
  421. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  422. tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 175/2;
  423. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
  424. // tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
  425. SetLetterVowel(tr,'y');
  426. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use de_rules for unpronouncable rules
  427. }
  428. break;
  429. case L('d','v'): // Divehi (Maldives)
  430. {
  431. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  432. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  433. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  434. tr->letter_bits_offset = OFFSET_THAANA;
  435. tr->langopts.stress_rule = STRESSPOSN_1L;
  436. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  437. SetLetterBitsRange(tr,LETTERGP_B,0x26,0x30); // vowel signs, and virama
  438. tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
  439. tr->langopts.numbers = 1;
  440. }
  441. break;
  442. case L('e','n'):
  443. {
  444. static const short stress_lengths_en[8] = {182,140, 220,220, 0,0, 248,275};
  445. SetupTranslator(tr,stress_lengths_en,NULL);
  446. tr->langopts.stress_rule = STRESSPOSN_1L;
  447. tr->langopts.stress_flags = 0x08;
  448. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_ROMAN | NUM_1900;
  449. tr->langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
  450. tr->langopts.suffix_add_e = 'e';
  451. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use en_rules for unpronouncable rules
  452. SetLetterBits(tr,6,"aeiouy"); // Group Y: vowels, including y
  453. }
  454. break;
  455. case L('e','l'): // Greek
  456. case L_grc: // Ancient Greek
  457. {
  458. static const short stress_lengths_el[8] = {155, 180, 210, 210, 0, 0, 270, 300};
  459. static const unsigned char stress_amps_el[8] = {15,12, 20,20, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  460. // character codes offset by 0x380
  461. static const char el_vowels[] = {0x10,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x35,0x37,0x39,0x3f,0x45,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0};
  462. static const char el_fvowels[] = {0x2d,0x2e,0x2f,0x35,0x37,0x39,0x45,0x4d,0}; // ε η ι υ έ ή ί ύ
  463. static const char el_voiceless[]= {0x38,0x3a,0x3e,0x40,0x42,0x43,0x44,0x46,0x47,0}; // θ κ ξ π ς σ τ φ χ
  464. static const char el_consonants[]={0x32,0x33,0x34,0x36,0x38,0x3a,0x3b,0x3c,0x3d,0x3e,0x40,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0};
  465. static const wchar_t el_char_apostrophe[] = {0x3c3,0}; // σ
  466. SetupTranslator(tr,stress_lengths_el,stress_amps_el);
  467. tr->charset_a0 = charsets[7]; // ISO-8859-7
  468. tr->char_plus_apostrophe = el_char_apostrophe;
  469. tr->letter_bits_offset = OFFSET_GREEK;
  470. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  471. SetLetterBits(tr,LETTERGP_A,el_vowels);
  472. SetLetterBits(tr,LETTERGP_VOWEL2,el_vowels);
  473. SetLetterBits(tr,LETTERGP_B,el_voiceless);
  474. SetLetterBits(tr,LETTERGP_C,el_consonants);
  475. SetLetterBits(tr,LETTERGP_Y,el_fvowels); // front vowels: ε η ι υ
  476. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  477. tr->langopts.stress_rule = STRESSPOSN_2R;
  478. tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
  479. tr->langopts.unstressed_wd1 = 0;
  480. tr->langopts.unstressed_wd2 = 2;
  481. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  482. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA;
  483. tr->langopts.numbers2 = 0x2 | NUM2_MULTIPLE_ORDINAL; // variant form of numbers before thousands
  484. if(name2 == L_grc)
  485. {
  486. // ancient greek
  487. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1;
  488. }
  489. }
  490. break;
  491. case L('e','o'):
  492. {
  493. static const short stress_lengths_eo[8] = {150, 150, 230, 180, 0, 0, 300, 320};
  494. static const unsigned char stress_amps_eo[] = {16,14, 20,20, 20,22, 22,21 };
  495. static const wchar_t eo_char_apostrophe[2] = {'l',0};
  496. SetupTranslator(tr,stress_lengths_eo,stress_amps_eo);
  497. tr->charset_a0 = charsets[3]; // ISO-8859-3
  498. tr->char_plus_apostrophe = eo_char_apostrophe;
  499. // tr->langopts.word_gap = 1;
  500. tr->langopts.vowel_pause = 2;
  501. tr->langopts.stress_rule = STRESSPOSN_2R;
  502. tr->langopts.stress_flags = 0x6 | 0x10;
  503. // tr->langopts.unstressed_wd1 = 3;
  504. tr->langopts.unstressed_wd2 = 2;
  505. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_ALLOW_SPACE | NUM_ROMAN;
  506. }
  507. break;
  508. case L('e','s'): // Spanish
  509. case L('c','a'): // Catalan
  510. case L_pap: // Papiamento
  511. {
  512. static const short stress_lengths_es[8] = {180, 190, 230, 180, 0, 0, 240, 270};
  513. static const unsigned char stress_amps_es[8] = {16,12, 18,18, 20,20, 20,20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  514. static const wchar_t ca_punct_within_word[] = {'\'',0xb7,0}; // ca: allow middle-dot within word
  515. SetupTranslator(tr,stress_lengths_es,stress_amps_es);
  516. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  517. tr->langopts.stress_rule = STRESSPOSN_2R;
  518. // stress last syllable if it doesn't end in vowel or "s" or "n"
  519. // 'diminished' is an unstressed final syllable
  520. tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
  521. tr->langopts.unstressed_wd1 = 0;
  522. tr->langopts.unstressed_wd2 = 2;
  523. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  524. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_AFTER;
  525. tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL;
  526. if(name2 == L('c','a'))
  527. {
  528. tr->punct_within_word = ca_punct_within_word;
  529. tr->langopts.stress_flags = 0x200 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
  530. }
  531. else
  532. if(name2 == L_pap)
  533. {
  534. tr->langopts.stress_flags = 0x100 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
  535. }
  536. else
  537. {
  538. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use es_rules for unpronouncable rules
  539. }
  540. }
  541. break;
  542. case L('e','u'): // basque
  543. {
  544. static const short stress_lengths_eu[8] = {200, 200, 200, 200, 0, 0, 210, 230}; // very weak stress
  545. static const unsigned char stress_amps_eu[8] = {16,16, 18,18, 18,18, 18,18 };
  546. SetupTranslator(tr,stress_lengths_eu,stress_amps_eu);
  547. tr->langopts.stress_rule = STRESSPOSN_2L; // ?? second syllable ??
  548. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_VIGESIMAL;
  549. }
  550. break;
  551. case L('f','a'): // Farsi
  552. {
  553. tr->letter_bits_offset = OFFSET_ARABIC;
  554. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND;
  555. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  556. tr->chars_ignore = chars_ignore_zwnj_hyphen; // replace ZWNJ by hyphen
  557. }
  558. break;
  559. case L('e','t'): // Estonian
  560. tr->charset_a0 = charsets[4]; // ISO-8859-4
  561. // drop through to Finnish
  562. case L('f','i'): // Finnish
  563. {
  564. static const unsigned char stress_amps_fi[8] = {18,16, 22,22, 20,22, 22,22 };
  565. static const short stress_lengths_fi[8] = {150,180, 200,200, 0,0, 210,250};
  566. SetupTranslator(tr,stress_lengths_fi,stress_amps_fi);
  567. tr->langopts.stress_rule = STRESSPOSN_1L;
  568. tr->langopts.stress_flags = 0x56; // move secondary stress from light to a following heavy syllable
  569. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  570. tr->langopts.long_stop = 130;
  571. tr->langopts.numbers = NUM_DECIMAL_COMMA + NUM_ALLOW_SPACE;
  572. SetLetterVowel(tr,'y');
  573. // tr->langopts.max_initial_consonants = 2; // BUT foreign words may have 3
  574. tr->langopts.spelling_stress = 1;
  575. tr->langopts.intonation_group = 3; // less intonation, don't raise pitch at comma
  576. }
  577. break;
  578. case L('f','r'): // french
  579. {
  580. SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
  581. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  582. tr->langopts.stress_flags = 0x0024; // don't use secondary stress
  583. tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
  584. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  585. tr->langopts.accents = 2; // Say "Capital" after the letter.
  586. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_AFTER | NUM_VIGESIMAL | NUM_DFRACTION_4;
  587. SetLetterVowel(tr,'y');
  588. }
  589. break;
  590. case L('h','i'): // Hindi
  591. case L('n','e'): // Nepali
  592. case L('p','a'): // Punjabi
  593. {
  594. static const short stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250};
  595. static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,22, 22,21 };
  596. SetupTranslator(tr,stress_lengths_hi,stress_amps_hi);
  597. tr->charset_a0 = charsets[19]; // ISCII
  598. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  599. tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
  600. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  601. tr->langopts.numbers = NUM_SWAP_TENS;
  602. tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  603. tr->letter_bits_offset = OFFSET_DEVANAGARI;
  604. if(name2 == L('p','a'))
  605. {
  606. tr->letter_bits_offset = OFFSET_GURMUKHI;
  607. }
  608. if(name2 == L('n','e'))
  609. {
  610. tr->langopts.break_numbers = 0x2aaaa8;
  611. tr->langopts.max_digits = 22;
  612. tr->langopts.numbers2 |= NUM2_ENGLISH_NUMERALS;
  613. }
  614. SetIndicLetters(tr);
  615. }
  616. break;
  617. case L('h','r'): // Croatian
  618. case L('b','s'): // Bosnian
  619. case L('s','r'): // Serbian
  620. {
  621. static const unsigned char stress_amps_hr[8] = {17,17, 20,20, 20,22, 22,21 };
  622. static const short stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230};
  623. static const short stress_lengths_sr[8] = {160,150, 200,200, 0,0, 250,260};
  624. if(name2 == L('s','r'))
  625. SetupTranslator(tr,stress_lengths_sr,stress_amps_hr);
  626. else
  627. SetupTranslator(tr,stress_lengths_hr,stress_amps_hr);
  628. tr->charset_a0 = charsets[2]; // ISO-8859-2
  629. tr->langopts.stress_rule = STRESSPOSN_1L;
  630. tr->langopts.stress_flags = 0x10;
  631. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  632. tr->langopts.max_initial_consonants = 5;
  633. tr->langopts.spelling_stress = 1;
  634. tr->langopts.accents = 1;
  635. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS;
  636. tr->langopts.numbers2 = 0xa + NUM2_THOUSANDS_VAR5; // variant numbers before thousands,milliards
  637. tr->langopts.replace_chars = replace_cyrillic_latin;
  638. SetLetterVowel(tr,'y');
  639. SetLetterVowel(tr,'r');
  640. }
  641. break;
  642. case L('h','t'): // Haitian Creole
  643. // memcpy(tr->stress_lengths,stress_lengths_fr,sizeof(tr->stress_lengths));
  644. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  645. tr->langopts.stress_flags = 0x0024; // don't use secondary stress
  646. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL | NUM_DFRACTION_4;
  647. break;
  648. case L('h','u'): // Hungarian
  649. {
  650. static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,22, 22,21 };
  651. static const short stress_lengths_hu[8] = {185,195, 195,190, 0,0, 210,220};
  652. SetupTranslator(tr,stress_lengths_hu,stress_amps_hu);
  653. tr->charset_a0 = charsets[2]; // ISO-8859-2
  654. tr->langopts.vowel_pause = 0x20;
  655. tr->langopts.stress_rule = STRESSPOSN_1L;
  656. tr->langopts.stress_flags = 0x8036 | S_HYPEN_UNSTRESS;
  657. tr->langopts.unstressed_wd1 = 2;
  658. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  659. tr->langopts.param[LOPT_ANNOUNCE_PUNCT] = 2; // don't break clause before announcing . ? !
  660. tr->langopts.numbers = NUM_DFRACTION_5 | NUM_ALLOW_SPACE | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS | NUM_ORDINAL_DOT | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
  661. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  662. tr->langopts.decimal_sep = ',';
  663. tr->langopts.max_roman = 899;
  664. tr->langopts.min_roman = 1;
  665. SetLetterVowel(tr,'y');
  666. tr->langopts.spelling_stress = 1;
  667. SetLengthMods(tr,3); // all equal
  668. }
  669. break;
  670. case L('h','y'): // Armenian
  671. {
  672. static const short stress_lengths_hy[8] = {250, 200, 250, 250, 0, 0, 250, 250};
  673. static const char hy_vowels[] = {0x31, 0x35, 0x37, 0x38, 0x3b, 0x48, 0x55, 0};
  674. static const char hy_consonants[] = {0x32,0x33,0x34,0x36,0x39,0x3a,0x3c,0x3d,0x3e,0x3f,
  675. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
  676. SetupTranslator(tr,stress_lengths_hy,NULL);
  677. tr->langopts.stress_rule = STRESSPOSN_1R; // default stress on final syllable
  678. tr->letter_bits_offset = OFFSET_ARMENIAN;
  679. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  680. SetLetterBits(tr,LETTERGP_A,hy_vowels);
  681. SetLetterBits(tr,LETTERGP_VOWEL2,hy_vowels);
  682. SetLetterBits(tr,LETTERGP_C,hy_consonants);
  683. tr->langopts.max_initial_consonants = 6;
  684. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
  685. // tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  686. }
  687. break;
  688. case L('i','d'): // Indonesian
  689. {
  690. static const short stress_lengths_id[8] = {160, 200, 180, 180, 0, 0, 220, 240};
  691. static const unsigned char stress_amps_id[8] = {16,18, 18,18, 20,22, 22,21 };
  692. SetupTranslator(tr,stress_lengths_id,stress_amps_id);
  693. tr->langopts.stress_rule = STRESSPOSN_2R;
  694. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_ROMAN;
  695. tr->langopts.stress_flags = 0x6 | 0x10;
  696. tr->langopts.accents = 2; // "capital" after letter name
  697. }
  698. break;
  699. case L('i','s'): // Icelandic
  700. {
  701. static const short stress_lengths_is[8] = {180,160, 200,200, 0,0, 240,250};
  702. static const wchar_t is_lettergroup_B[] = {'c','f','h','k','p','t','x',0xfe,0}; // voiceless conants, including 'þ' ?? 's'
  703. SetupTranslator(tr,stress_lengths_is,NULL);
  704. tr->langopts.stress_rule = STRESSPOSN_1L;
  705. tr->langopts.stress_flags = 0x10;
  706. tr->langopts.param[LOPT_IT_LENGTHEN] = 0x11; // remove lengthen indicator from unstressed vowels
  707. tr->langopts.param[LOPT_REDUCE] = 2;
  708. ResetLetterBits(tr,0x18);
  709. SetLetterBits(tr,4,"kpst"); // Letter group F
  710. SetLetterBits(tr,3,"jvr"); // Letter group H
  711. tr->letter_groups[1] = is_lettergroup_B;
  712. SetLetterVowel(tr,'y');
  713. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SINGLE_AND | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_1900;
  714. tr->langopts.numbers2 = 0x2;
  715. }
  716. break;
  717. case L('i','t'): // Italian
  718. {
  719. static const short stress_lengths_it[8] = {150, 140, 170, 170, 0, 0, 300, 330};
  720. static const unsigned char stress_amps_it[8] = {15,14, 19,19, 20,22, 22,20 };
  721. SetupTranslator(tr,stress_lengths_it,stress_amps_it);
  722. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  723. tr->langopts.stress_rule = STRESSPOSN_2R;
  724. tr->langopts.stress_flags = 0x10 | 0x20000;
  725. tr->langopts.vowel_pause = 1;
  726. tr->langopts.unstressed_wd1 = 2;
  727. tr->langopts.unstressed_wd2 = 2;
  728. tr->langopts.param[LOPT_IT_LENGTHEN] = 2; // remove lengthen indicator from unstressed or non-penultimate syllables
  729. tr->langopts.param[LOPT_IT_DOUBLING] = 2; // double the first consonant if the previous word ends in a stressed vowel
  730. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  731. tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
  732. tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
  733. tr->langopts.numbers = NUM_SINGLE_VOWEL | NUM_OMIT_1_HUNDRED |NUM_DECIMAL_COMMA | NUM_ROMAN | NUM_DFRACTION_1;
  734. tr->langopts.accents = 2; // Say "Capital" after the letter.
  735. SetLetterVowel(tr,'y');
  736. }
  737. break;
  738. case L_jbo: // Lojban
  739. {
  740. static const short stress_lengths_jbo[8] = {145,145, 170,160, 0,0, 330,350};
  741. static const wchar_t jbo_punct_within_word[] = {'.',',','\'',0x2c8,0}; // allow period and comma within a word, also stress marker (from LOPT_CAPS_IN_WORD)
  742. SetupTranslator(tr,stress_lengths_jbo,NULL);
  743. tr->langopts.stress_rule = STRESSPOSN_2R;
  744. tr->langopts.vowel_pause = 0x20c; // pause before a word which starts with a vowel, or after a word which ends in a consonant
  745. // tr->langopts.word_gap = 1;
  746. tr->punct_within_word = jbo_punct_within_word;
  747. tr->langopts.param[LOPT_CAPS_IN_WORD] = 2; // capitals indicate stressed syllables
  748. SetLetterVowel(tr,'y');
  749. tr->langopts.max_lengthmod = 368;
  750. }
  751. break;
  752. case L('k','a'): // Georgian
  753. {
  754. // character codes offset by 0x1080
  755. static const char ka_vowels[] = {0x50,0x54,0x58,0x5d,0x63,0x75,0x77,0};
  756. static const char ka_consonants[] = {0x51,0x52,0x53,0x55,0x56,0x57,0x59,0x5a,0x5b,0x5c,0x5e,0x5f,0x60,0x61,0x62,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x76,0};
  757. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  758. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  759. SetLetterBits(tr,LETTERGP_A,ka_vowels);
  760. SetLetterBits(tr,LETTERGP_C,ka_consonants);
  761. SetLetterBits(tr,LETTERGP_VOWEL2,ka_vowels);
  762. tr->langopts.stress_rule = STRESSPOSN_1L;
  763. tr->langopts.stress_flags = S_FINAL_NO_2;
  764. tr->letter_bits_offset = OFFSET_GEORGIAN;
  765. // tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  766. tr->langopts.max_initial_consonants = 7;
  767. tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5 | NUM_ROMAN;
  768. }
  769. break;
  770. case L('k','k'): // Kazakh
  771. {
  772. static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
  773. static const short stress_lengths_tr[8] = {190,180, 230,230, 0,0, 250,250};
  774. tr->letter_bits_offset = OFFSET_CYRILLIC;
  775. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  776. SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
  777. SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
  778. SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
  779. SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
  780. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  781. tr->langopts.stress_flags = S_NO_AUTO_2 + S_NO_EOC_LENGTHEN; //no automatic secondary stress, don't lengthen at end-of-clause
  782. tr->langopts.lengthen_tonic = 0;
  783. tr->langopts.param[LOPT_SUFFIX] = 1;
  784. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_6 ;
  785. tr->langopts.max_initial_consonants = 2;
  786. SetLengthMods(tr,3); // all equal
  787. }
  788. break;
  789. case L('k','l'): // Greenlandic
  790. {
  791. tr->langopts.stress_rule = 12;
  792. tr->langopts.stress_flags = S_NO_AUTO_2;
  793. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
  794. }
  795. break;
  796. case L('k','o'): // Korean, TEST
  797. {
  798. static const char ko_ivowels[] = {0x63,0x64,0x67,0x68,0x6d,0x72,0x74,0x75,0}; // y and i vowels
  799. static const unsigned char ko_voiced[] = {0x02,0x05,0x06,0xab,0xaf,0xb7,0xbc,0}; // voiced consonants, l,m,n,N
  800. tr->letter_bits_offset = OFFSET_KOREAN;
  801. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  802. SetLetterBitsRange(tr,LETTERGP_A,0x61,0x75);
  803. SetLetterBits(tr,LETTERGP_Y,ko_ivowels);
  804. SetLetterBits(tr,LETTERGP_G,(const char *)ko_voiced);
  805. tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable
  806. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  807. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  808. tr->langopts.numbers2 = NUM2_MYRIADS;
  809. tr->langopts.break_numbers = 0x1111110;
  810. tr->langopts.max_digits = 20;
  811. }
  812. break;
  813. case L('k','u'): // Kurdish
  814. {
  815. static const unsigned char stress_amps_ku[8] = {18,18, 20,20, 20,22, 22,21 };
  816. static const short stress_lengths_ku[8] = {180,180, 190,180, 0,0, 230,240};
  817. SetupTranslator(tr,stress_lengths_ku,stress_amps_ku);
  818. tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
  819. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  820. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED;
  821. tr->langopts.max_initial_consonants = 2;
  822. }
  823. break;
  824. case L('l','a'): //Latin
  825. {
  826. tr->charset_a0 = charsets[4]; // ISO-8859-4, includes a,e,i,o,u-macron
  827. tr->langopts.stress_rule = STRESSPOSN_2R;
  828. tr->langopts.stress_flags = 0x20;
  829. tr->langopts.unstressed_wd1 = 0;
  830. tr->langopts.unstressed_wd2 = 2;
  831. tr->langopts.param[LOPT_DIERESES] = 1;
  832. tr->langopts.numbers = NUM_ROMAN;
  833. tr->langopts.max_roman = 5000;
  834. }
  835. break;
  836. case L('l','t'): // Lithuanian
  837. {
  838. tr->charset_a0 = charsets[4]; // ISO-8859-4
  839. tr->langopts.stress_rule = STRESSPOSN_2R;
  840. tr->langopts.stress_flags = 0x20;
  841. tr->langopts.unstressed_wd1 = 0;
  842. tr->langopts.unstressed_wd2 = 2;
  843. tr->langopts.param[LOPT_DIERESES] = 1;
  844. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
  845. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4;
  846. tr->langopts.max_roman = 5000;
  847. }
  848. break;
  849. case L('l','v'): // latvian
  850. {
  851. static const unsigned char stress_amps_lv[8] = {17,13, 20,20, 20,22, 22,21 };
  852. static const short stress_lengths_lv[8] = {180,130, 210,210, 0,0, 210,210};
  853. SetupTranslator(tr,stress_lengths_lv,stress_amps_lv);
  854. tr->langopts.stress_rule = STRESSPOSN_1L;
  855. tr->langopts.spelling_stress = 1;
  856. tr->charset_a0 = charsets[4]; // ISO-8859-4
  857. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
  858. tr->langopts.stress_flags = 0x16 + 0x40000;
  859. }
  860. break;
  861. case L('m','k'): // Macedonian
  862. {
  863. static wchar_t vowels_cyrillic[] = {0x440, // also include 'р' [R]
  864. 0x430,0x435,0x438,0x439,0x43e,0x443,0x44b,0x44d,0x44e,0x44f,0x450,0x451,0x456,0x457,0x45d,0x45e,0};
  865. static const unsigned char stress_amps_mk[8] = {17,17, 20,20, 20,22, 22,21 };
  866. static const short stress_lengths_mk[8] = {180,160, 200,200, 0,0, 220,230};
  867. SetupTranslator(tr,stress_lengths_mk,stress_amps_mk);
  868. tr->charset_a0 = charsets[5]; // ISO-8859-5
  869. tr->letter_groups[0] = tr->letter_groups[7] = vowels_cyrillic;
  870. tr->langopts.stress_rule = STRESSPOSN_3R; // antipenultimate
  871. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  872. tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
  873. }
  874. break;
  875. case L('m','t'): // Maltese
  876. {
  877. tr->charset_a0 = charsets[3]; // ISO-8859-3
  878. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  879. tr->langopts.stress_rule = STRESSPOSN_2R; // penultimate
  880. tr->langopts.numbers = 1;
  881. }
  882. break;
  883. case L('n','l'): // Dutch
  884. {
  885. static const short stress_lengths_nl[8] = {160,135, 210,210, 0, 0, 260,280};
  886. tr->langopts.stress_rule = STRESSPOSN_1L;
  887. tr->langopts.vowel_pause = 0x30; // ??
  888. tr->langopts.param[LOPT_DIERESES] = 1;
  889. tr->langopts.param[LOPT_PREFIXES] = 1;
  890. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  891. SetLetterVowel(tr,'y');
  892. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
  893. tr->langopts.ordinal_indicator = "e";
  894. tr->langopts.stress_flags = S_FIRST_PRIMARY;
  895. memcpy(tr->stress_lengths,stress_lengths_nl,sizeof(tr->stress_lengths));
  896. }
  897. break;
  898. case L('n','o'): // Norwegian
  899. {
  900. static const short stress_lengths_no[8] = {160,140, 200,200, 0,0, 220,230};
  901. SetupTranslator(tr,stress_lengths_no,NULL);
  902. tr->langopts.stress_rule = STRESSPOSN_1L;
  903. SetLetterVowel(tr,'y');
  904. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
  905. }
  906. break;
  907. case L('o','m'):
  908. {
  909. static const unsigned char stress_amps_om[] = {18,15, 20,20, 20,22, 22,22 };
  910. static const short stress_lengths_om[8] = {200,200, 200,200, 0,0, 200,200};
  911. SetupTranslator(tr,stress_lengths_om,stress_amps_om);
  912. tr->langopts.stress_rule = STRESSPOSN_2R;
  913. tr->langopts.stress_flags = 0x16 + 0x80000;
  914. }
  915. break;
  916. case L('p','l'): // Polish
  917. {
  918. static const short stress_lengths_pl[8] = {160, 190, 175, 175, 0, 0, 200, 210};
  919. static const unsigned char stress_amps_pl[8] = {17,13, 19,19, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  920. SetupTranslator(tr,stress_lengths_pl,stress_amps_pl);
  921. tr->charset_a0 = charsets[2]; // ISO-8859-2
  922. tr->langopts.stress_rule = STRESSPOSN_2R;
  923. tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
  924. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
  925. tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
  926. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
  927. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR3;
  928. tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt)
  929. SetLetterVowel(tr,'y');
  930. }
  931. break;
  932. case L('p','t'): // Portuguese
  933. {
  934. static const short stress_lengths_pt[8] = {170, 115, 210, 240, 0, 0, 260, 280};
  935. static const unsigned char stress_amps_pt[8] = {16,11, 19,21, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  936. SetupTranslator(tr,stress_lengths_pt,stress_amps_pt);
  937. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  938. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  939. tr->langopts.stress_flags = 0x6 | 0x10 | 0x2000 | 0x20000;
  940. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN;
  941. tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS;
  942. SetLetterVowel(tr,'y');
  943. ResetLetterBits(tr,0x2);
  944. SetLetterBits(tr,1,"bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
  945. tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
  946. }
  947. break;
  948. case L('r','o'): // Romanian
  949. {
  950. static const short stress_lengths_ro[8] = {170, 170, 180, 180, 0, 0, 240, 260};
  951. static const unsigned char stress_amps_ro[8] = {15,13, 18,18, 20,22, 22,21 };
  952. SetupTranslator(tr,stress_lengths_ro,stress_amps_ro);
  953. tr->langopts.stress_rule = STRESSPOSN_2R;
  954. tr->langopts.stress_flags = 0x100 + 0x6;
  955. tr->charset_a0 = charsets[2]; // ISO-8859-2
  956. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_3 | NUM_AND_UNITS | NUM_ROMAN;
  957. tr->langopts.numbers2 = 0x1e; // variant numbers before all thousandplex
  958. }
  959. break;
  960. case L('r','u'): // Russian
  961. Translator_Russian(tr);
  962. break;
  963. case L('r','w'): // Kiryarwanda
  964. {
  965. tr->langopts.stress_rule = STRESSPOSN_2R;
  966. tr->langopts.stress_flags = 0x16;
  967. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  968. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_2 | NUM_AND_HUNDRED;
  969. tr->langopts.numbers2 = 0x200; // say "thousands" before its number
  970. }
  971. break;
  972. case L('s','k'): // Slovak
  973. case L('c','s'): // Czech
  974. {
  975. static const char *sk_voiced = "bdgjlmnrvwzaeiouy";
  976. SetupTranslator(tr,stress_lengths_sk,stress_amps_sk);
  977. tr->charset_a0 = charsets[2]; // ISO-8859-2
  978. tr->langopts.stress_rule = STRESSPOSN_1L;
  979. tr->langopts.stress_flags = 0x16;
  980. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  981. tr->langopts.max_initial_consonants = 5;
  982. tr->langopts.spelling_stress = 1;
  983. tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
  984. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ROMAN;
  985. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR2;
  986. tr->langopts.thousands_sep = STRESSPOSN_1L; //no thousands separator
  987. tr->langopts.decimal_sep = ',';
  988. if(name2 == L('c','s'))
  989. {
  990. tr->langopts.numbers2 = 0x108; // variant numbers before milliards
  991. }
  992. SetLetterVowel(tr,'y');
  993. SetLetterVowel(tr,'r');
  994. ResetLetterBits(tr,0x20);
  995. SetLetterBits(tr,5,sk_voiced);
  996. }
  997. break;
  998. case L('s','i'): // Sinhala
  999. {
  1000. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  1001. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1002. tr->langopts.stress_rule = STRESSPOSN_1L;
  1003. tr->langopts.stress_flags = S_FINAL_DIM | S_NO_AUTO_DIM | S_FINAL_NO_2;
  1004. tr->langopts.spelling_stress = 1;
  1005. tr->letter_bits_offset = OFFSET_SINHALA;
  1006. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  1007. SetLetterBitsRange(tr,LETTERGP_A,0x05,0x16); // vowel letters
  1008. SetLetterBitsRange(tr,LETTERGP_A,0x4a,0x73); // + vowel signs, and virama
  1009. SetLetterBitsRange(tr,LETTERGP_B,0x4a,0x73); // vowel signs, and virama
  1010. SetLetterBitsRange(tr,LETTERGP_C,0x1a,0x46); // the main consonant range
  1011. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1012. tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4a; //virama
  1013. tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS_L | NUM_DFRACTION_7;
  1014. tr->langopts.numbers2 = NUM2_PERCENT_BEFORE;
  1015. tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  1016. }
  1017. break;
  1018. case L('s','l'): // Slovenian
  1019. tr->charset_a0 = charsets[2]; // ISO-8859-2
  1020. tr->langopts.stress_rule = STRESSPOSN_2R; // Temporary
  1021. tr->langopts.stress_flags = 0x20;
  1022. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x103;
  1023. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ORDINAL_DOT | NUM_ROMAN;
  1024. tr->langopts.numbers2 = 0x100; // plural forms of millions etc
  1025. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  1026. SetLetterVowel(tr,'r');
  1027. break;
  1028. case L('s','q'): // Albanian
  1029. {
  1030. static const short stress_lengths_sq[8] = {150, 150, 180, 180, 0, 0, 300, 300};
  1031. static const unsigned char stress_amps_sq[8] = {16,12, 16,16, 20,20, 21,19 };
  1032. SetupTranslator(tr,stress_lengths_sq,stress_amps_sq);
  1033. tr->langopts.stress_rule = STRESSPOSN_2R;
  1034. tr->langopts.stress_flags = 0x16 + 0x100;
  1035. SetLetterVowel(tr,'y');
  1036. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_4;
  1037. tr->langopts.accents = 2; // "capital" after letter name
  1038. }
  1039. break;
  1040. case L('s','v'): // Swedish
  1041. {
  1042. static const unsigned char stress_amps_sv[] = {16,16, 20,20, 20,22, 22,21 };
  1043. static const short stress_lengths_sv[8] = {160,135, 220,220, 0,0, 250,280};
  1044. SetupTranslator(tr,stress_lengths_sv,stress_amps_sv);
  1045. tr->langopts.stress_rule = STRESSPOSN_1L;
  1046. SetLetterVowel(tr,'y');
  1047. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_1900;
  1048. tr->langopts.accents = 1;
  1049. }
  1050. break;
  1051. case L('s','w'): // Swahili
  1052. case L('t','n'): // Setswana
  1053. {
  1054. static const short stress_lengths_sw[8] = {160, 170, 200, 200, 0, 0, 320, 340};
  1055. static const unsigned char stress_amps_sw[] = {16,12, 19,19, 20,22, 22,21 };
  1056. SetupTranslator(tr,stress_lengths_sw,stress_amps_sw);
  1057. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1058. tr->langopts.vowel_pause = 1;
  1059. tr->langopts.stress_rule = STRESSPOSN_2R;
  1060. tr->langopts.stress_flags = 0x6 | 0x10;
  1061. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_OMIT_1_HUNDRED;
  1062. tr->langopts.break_numbers = 0x49249268; // for languages which have numbers for 100,000 and 1,000,000
  1063. }
  1064. break;
  1065. case L('t','a'): // Tamil
  1066. case L('m','l'): // Malayalam
  1067. case L('k','n'): // Kannada
  1068. case L('m','r'): // Marathi
  1069. case L('t','e'): // Telugu
  1070. {
  1071. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  1072. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1073. tr->langopts.stress_rule = STRESSPOSN_1L;
  1074. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  1075. tr->langopts.spelling_stress = 1;
  1076. tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
  1077. if(name2 == L('t','a'))
  1078. {
  1079. tr->letter_bits_offset = OFFSET_TAMIL;
  1080. tr->langopts.numbers = NUM_OMIT_1_THOUSAND ;
  1081. }
  1082. if(name2 == L('m','r'))
  1083. {
  1084. tr->letter_bits_offset = OFFSET_DEVANAGARI;
  1085. }
  1086. else
  1087. if(name2 == L('m','l'))
  1088. {
  1089. tr->letter_bits_offset = OFFSET_MALAYALAM;
  1090. tr->langopts.numbers = NUM_OMIT_1_THOUSAND;
  1091. }
  1092. else
  1093. if(name2 == L('k','n'))
  1094. {
  1095. tr->letter_bits_offset = OFFSET_KANNADA;
  1096. tr->langopts.numbers = 0x1;
  1097. }
  1098. else
  1099. if(name2 == L('t','e'))
  1100. {
  1101. tr->letter_bits_offset = OFFSET_TELUGU;
  1102. tr->langopts.numbers = 0x1;
  1103. }
  1104. tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
  1105. SetIndicLetters(tr); // call this after setting OFFSET_
  1106. SetLetterBitsRange(tr,LETTERGP_B,0x4e,0x4e); // chillu-virama (unofficial)
  1107. }
  1108. break;
  1109. #ifdef deleted
  1110. case L('t','h'): // Thai
  1111. {
  1112. static const short stress_lengths_th[8] = {230,150, 230,230, 230,0, 230,250};
  1113. static const unsigned char stress_amps_th[] = {22,16, 22,22, 22,22, 22,22 };
  1114. SetupTranslator(tr,stress_lengths_th,stress_amps_th);
  1115. tr->langopts.stress_rule = 0; // stress on final syllable of a "word"
  1116. tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
  1117. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1118. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1119. // tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
  1120. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1121. }
  1122. break;
  1123. #endif
  1124. case L('t','r'): // Turkish
  1125. case L('a','z'): // Azerbaijan
  1126. {
  1127. static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
  1128. static const short stress_lengths_tr[8] = {190,180, 200,230, 0,0, 240,250};
  1129. SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
  1130. tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
  1131. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  1132. tr->langopts.stress_flags = 0x20; //no automatic secondary stress
  1133. tr->langopts.param[LOPT_SUFFIX] = 1;
  1134. if(name2 == L('a','z'))
  1135. {
  1136. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  1137. }
  1138. else
  1139. {
  1140. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  1141. }
  1142. tr->langopts.max_initial_consonants = 2;
  1143. }
  1144. break;
  1145. case L('t','t'): // Tatar
  1146. {
  1147. SetCyrillicLetters(tr);
  1148. SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
  1149. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  1150. tr->langopts.stress_flags = 0x20; //no automatic secondary stress
  1151. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_4;
  1152. }
  1153. break;
  1154. case L('u','k'): // Ukrainian
  1155. {
  1156. SetCyrillicLetters(tr);
  1157. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  1158. }
  1159. break;
  1160. case L('u','r'): // Urdu
  1161. tr->letter_bits_offset = OFFSET_ARABIC;
  1162. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1163. tr->langopts.numbers = NUM_SWAP_TENS;
  1164. tr->langopts.break_numbers = 0x52a8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  1165. break;
  1166. case L('v','i'): // Vietnamese
  1167. {
  1168. static const short stress_lengths_vi[8] = {150, 150, 180, 180, 210, 230, 230, 240};
  1169. static const unsigned char stress_amps_vi[] = {16,16, 16,16, 22,22, 22,22 };
  1170. static wchar_t vowels_vi[] = {
  1171. 0x61, 0xe0, 0xe1, 0x1ea3, 0xe3, 0x1ea1, // a
  1172. 0x103, 0x1eb1, 0x1eaf, 0x1eb3, 0x1eb5, 0x1eb7, // ă
  1173. 0xe2, 0x1ea7, 0x1ea5, 0x1ea9, 0x1eab, 0x1ead, // â
  1174. 0x65, 0xe8, 0xe9, 0x1ebb, 0x1ebd, 0x1eb9, // e
  1175. 0xea, 0x1ec1, 0x1ebf, 0x1ec3, 0x1ec5, 0x1ec7, // i
  1176. 0x69, 0xec, 0xed, 0x1ec9, 0x129, 0x1ecb, // i
  1177. 0x6f, 0xf2, 0xf3, 0x1ecf, 0xf5, 0x1ecd, // o
  1178. 0xf4, 0x1ed3, 0x1ed1, 0x1ed5, 0x1ed7, 0x1ed9, // ô
  1179. 0x1a1, 0x1edd, 0x1edb, 0x1edf, 0x1ee1, 0x1ee3, // ơ
  1180. 0x75, 0xf9, 0xfa, 0x1ee7, 0x169, 0x1ee5, // u
  1181. 0x1b0, 0x1eeb, 0x1ee9, 0x1eed, 0x1eef, 0x1ef1, // ư
  1182. 0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1e, 0 }; // y
  1183. SetupTranslator(tr,stress_lengths_vi,stress_amps_vi);
  1184. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1185. tr->langopts.stress_rule = STRESSPOSN_1L;
  1186. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1187. // tr->langopts.vowel_pause = 4;
  1188. tr->letter_groups[0] = tr->letter_groups[7] = vowels_vi;
  1189. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1190. tr->langopts.unstressed_wd1 = 2;
  1191. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND_DIGIT | NUM_DFRACTION_4 | NUM_ZERO_HUNDRED;
  1192. }
  1193. break;
  1194. case L('w','o'):
  1195. tr->langopts.stress_rule = STRESSPOSN_1L;
  1196. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS;
  1197. break;
  1198. case L('z','h'):
  1199. case L_zhy:
  1200. {
  1201. static const short stress_lengths_zh[8] = {230,150, 230,230, 230,0, 240,250}; // 1=tone5. end-of-sentence, 6=tone 1&4, 7=tone 2&3
  1202. static const unsigned char stress_amps_zh[] = {22,16, 22,22, 22,22, 22,22 };
  1203. SetupTranslator(tr,stress_lengths_zh,stress_amps_zh);
  1204. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable of a "word"
  1205. tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
  1206. tr->langopts.vowel_pause = 0;
  1207. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1208. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1209. tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
  1210. tr->langopts.ideographs = 1;
  1211. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1212. if(name2 == L('z','h'))
  1213. {
  1214. tr->langopts.textmode = 1;
  1215. tr->langopts.listx = 1; // compile zh_listx after zh_list
  1216. }
  1217. }
  1218. break;
  1219. default:
  1220. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1221. break;
  1222. }
  1223. tr->translator_name = name2;
  1224. if(tr->langopts.numbers & NUM_DECIMAL_COMMA)
  1225. {
  1226. // use . and ; for thousands and decimal separators
  1227. tr->langopts.thousands_sep = '.';
  1228. tr->langopts.decimal_sep = ',';
  1229. }
  1230. if(tr->langopts.numbers & NUM_THOUS_SPACE)
  1231. {
  1232. tr->langopts.thousands_sep = 0; // don't allow thousands separator, except space
  1233. }
  1234. return(tr);
  1235. } // end of SelectTranslator
  1236. //**********************************************************************************************************
  1237. static void Translator_Russian(Translator *tr)
  1238. {//===========================================
  1239. static const unsigned char stress_amps_ru[] = {16,16, 18,18, 20,24, 24,22 };
  1240. static const short stress_lengths_ru[8] = {150,140, 220,220, 0,0, 260,280};
  1241. static const char ru_ivowels2[] = {0x2c,0x15,0x18,0x2e,0x2f,0}; // add more vowels to letter group Y (iotated vowels & soft-sign)
  1242. SetupTranslator(tr,stress_lengths_ru,stress_amps_ru);
  1243. SetCyrillicLetters(tr);
  1244. SetLetterBits(tr,6,ru_ivowels2);
  1245. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  1246. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 1;
  1247. tr->langopts.param[LOPT_REDUCE] = 2;
  1248. tr->langopts.stress_rule = 5;
  1249. tr->langopts.stress_flags = 0x0020; // waas 0x1010
  1250. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
  1251. tr->langopts.numbers2 = 0x2 + NUM2_THOUSANDS_VAR1; // variant numbers before thousands
  1252. tr->langopts.phoneme_change = 1;
  1253. tr->langopts.testing = 2;
  1254. } // end of Translator_Russian
  1255. /*
  1256. typedef struct {
  1257. int flags;
  1258. unsigned char stress; // stress level of this vowel
  1259. unsigned char stress_highest; // the highest stress level of a vowel in this word
  1260. unsigned char n_vowels; // number of vowels in the word
  1261. unsigned char vowel_this; // syllable number of this vowel (counting from 1)
  1262. unsigned char vowel_stressed; // syllable number of the highest stressed vowel
  1263. } CHANGEPH;
  1264. */
  1265. #ifdef RUSSIAN2
  1266. // This is now done in the phoneme data, ph_russian
  1267. int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
  1268. {//=============================================================================================================
  1269. // Called for each phoneme in the phoneme list, to allow a language to make changes
  1270. // ph The current phoneme
  1271. int variant;
  1272. int vowelix;
  1273. PHONEME_TAB *prev, *next;
  1274. if(ch->flags & 8)
  1275. return(0); // full phoneme translation has already been given
  1276. // Russian vowel softening and reduction rules
  1277. if(ph->type == phVOWEL)
  1278. {
  1279. int prestressed = ch->vowel_stressed==ch->vowel_this+1; // the next vowel after this has the main stress
  1280. #define N_VOWELS_RU 11
  1281. static unsigned int vowels_ru[N_VOWELS_RU] = {'a','V','O','I',PH('I','#'),PH('E','#'),PH('E','2'),
  1282. PH('V','#'),PH('I','3'),PH('I','2'),PH('E','3')};
  1283. static unsigned int vowel_replace[N_VOWELS_RU][6] = {
  1284. // stressed, soft, soft-stressed, j+stressed, j+soft, j+soft-stressed
  1285. /*0*/ {'A', 'I', PH('j','a'), 'a', 'a', 'a'}, // a Uses 3,4,5 columns.
  1286. /*1*/ {'A', 'V', PH('j','a'), 'a', 'V', 'a'}, // V Uses 3,4,5 columns.
  1287. /*2*/ {'o', '8', '8', 'o', '8', '8'}, // O
  1288. /*3*/ {'i', 'I', 'i', 'a', 'I', 'a'}, // I Uses 3,4,5 columns.
  1289. /*4*/ {'i', PH('I','#'), 'i', 'i', PH('I','#'), 'i'}, // I#
  1290. /*5*/ {'E', PH('E','#'), 'E', 'e', PH('E','#'), 'e'}, // E#
  1291. /*6*/ {'E', PH('E','2'), 'E', 'e', PH('E','2'), 'e'}, // E2 Uses 3,4,5 columns.
  1292. /*7*/ {PH('j','a'), 'V', PH('j','a'), 'A', 'V', 'A'}, // V#
  1293. /*8*/ {PH('j','a'), 'I', PH('j','a'), 'e', 'I', 'e'}, // I3 Uses 3,4,5 columns.
  1294. /*9*/ {'e', 'I', 'e', 'e', 'I', 'e'}, // I2
  1295. /*10*/ {'e', PH('E', '2'), 'e', 'e', PH('E','2'), 'e'} // E3
  1296. };
  1297. prev = phoneme_tab[phlist[index-1].phcode];
  1298. next = phoneme_tab[phlist[index+1].phcode];
  1299. // lookup the vowel name to get an index into the vowel_replace[] table
  1300. for(vowelix=0; vowelix<N_VOWELS_RU; vowelix++)
  1301. {
  1302. if(vowels_ru[vowelix] == ph->mnemonic)
  1303. break;
  1304. }
  1305. if(vowelix == N_VOWELS_RU)
  1306. return(0);
  1307. if(prestressed)
  1308. {
  1309. if((vowelix==6)&&(prev->mnemonic=='j'))
  1310. vowelix=8;
  1311. if(vowelix==1)
  1312. vowelix=0;
  1313. if(vowelix==4)
  1314. vowelix=3;
  1315. if(vowelix==6)
  1316. vowelix=5;
  1317. if(vowelix==7)
  1318. vowelix=8;
  1319. if(vowelix==10)
  1320. vowelix=9;
  1321. }
  1322. // do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
  1323. variant = -1;
  1324. int stressed = ch->flags & 2;
  1325. int soft=prev->phflags & phPALATAL;
  1326. if (soft && stressed)
  1327. variant = 2; else
  1328. if (stressed)
  1329. variant = 0; else
  1330. if (soft)
  1331. variant = 1;
  1332. if(variant >= 0)
  1333. {
  1334. if(prev->mnemonic == 'j')
  1335. variant += 3;
  1336. phlist[index].phcode = PhonemeCode(vowel_replace[vowelix][variant]);
  1337. }
  1338. else
  1339. {
  1340. phlist[index].phcode = PhonemeCode(vowels_ru[vowelix]);
  1341. }
  1342. }
  1343. return(0);
  1344. }
  1345. #endif