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.c 66KB

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