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

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