1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
|
/* Copyright (C) 2009 LordGregGreg Back
This is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the viewer; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "llviewerprecompiledheaders.h"
#include "lgghunspell_wrapper.h"
#include <boost/regex.hpp>
#include "llweb.h"
#include "llviewercontrol.h"
#include "llviewerwindow.h"
#include "llfile.h"
#include "llhttpclient.h"
#include "lggdicdownload.h"
lggHunSpell_Wrapper *glggHunSpell = 0;
Hunspell* lggHunSpell_Wrapper::myHunspell = 0;
// do not insert empty lines after this line until the size calculation
#define COUNTRY_CODES_RAW_START_LINE (__LINE__ + 2)
static char * countryCodesraw[] = {
(char*)"SL",(char*)"SecondLife",
(char*)"AD",(char*)"Andorra",
(char*)"AE",(char*)"United Arab Emirates",
(char*)"AF",(char*)"Afghanistan",
(char*)"AG",(char*)"Antigua & Barbuda",
(char*)"AI",(char*)"Anguilla",
(char*)"AL",(char*)"Albania",
(char*)"AM",(char*)"Armenia",
(char*)"AN",(char*)"Netherlands Antilles",
(char*)"AO",(char*)"Angola",
(char*)"AQ",(char*)"Antarctica",
(char*)"AR",(char*)"Argentina",
(char*)"AS",(char*)"American Samoa",
(char*)"AT",(char*)"Austria",
(char*)"AU",(char*)"Australia",
(char*)"AW",(char*)"Aruba",
(char*)"AZ",(char*)"Azerbaijan",
(char*)"BA",(char*)"Bosnia and Herzegovina",
(char*)"BB",(char*)"Barbados",
(char*)"BD",(char*)"Bangladesh",
(char*)"BE",(char*)"Belgium",
(char*)"BF",(char*)"Burkina Faso",
(char*)"BG",(char*)"Bulgaria",
(char*)"BH",(char*)"Bahrain",
(char*)"BI",(char*)"Burundi",
(char*)"BJ",(char*)"Benin",
(char*)"BM",(char*)"Bermuda",
(char*)"BN",(char*)"Brunei Darussalam",
(char*)"BO",(char*)"Bolivia",
(char*)"BR",(char*)"Brazil",
(char*)"BS",(char*)"Bahama",
(char*)"BT",(char*)"Bhutan",
(char*)"BU",(char*)"Burma",
(char*)"BV",(char*)"Bouvet Island",
(char*)"BW",(char*)"Botswana",
(char*)"BY",(char*)"Belarus",
(char*)"BZ",(char*)"Belize",
(char*)"CA",(char*)"Canada",
(char*)"CC",(char*)"Cocos (Keeling) Islands",
(char*)"CF",(char*)"Central African Republic",
(char*)"CG",(char*)"Congo",
(char*)"CH",(char*)"Switzerland",
(char*)"CI",(char*)"Côte D'ivoire (Ivory Coast)",
(char*)"CK",(char*)"Cook Iislands",
(char*)"CL",(char*)"Chile",
(char*)"CM",(char*)"Cameroon",
(char*)"CN",(char*)"China",
(char*)"CO",(char*)"Colombia",
(char*)"CR",(char*)"Costa Rica",
(char*)"CS",(char*)"Czechoslovakia",
(char*)"CU",(char*)"Cuba",
(char*)"CV",(char*)"Cape Verde",
(char*)"CX",(char*)"Christmas Island",
(char*)"CY",(char*)"Cyprus",
(char*)"CZ",(char*)"Czech Republic",
(char*)"DD",(char*)"German Democratic Republic",
(char*)"DE",(char*)"Germany",
(char*)"DJ",(char*)"Djibouti",
(char*)"DK",(char*)"Denmark",
(char*)"DM",(char*)"Dominica",
(char*)"DO",(char*)"Dominican Republic",
(char*)"DZ",(char*)"Algeria",
(char*)"EC",(char*)"Ecuador",
(char*)"EE",(char*)"Estonia",
(char*)"EG",(char*)"Egypt",
(char*)"EH",(char*)"Western Sahara",
(char*)"ER",(char*)"Eritrea",
(char*)"ES",(char*)"Spain",
(char*)"ET",(char*)"Ethiopia",
(char*)"FI",(char*)"Finland",
(char*)"FJ",(char*)"Fiji",
(char*)"FK",(char*)"Falkland Islands (Malvinas)",
(char*)"FM",(char*)"Micronesia",
(char*)"FO",(char*)"Faroe Islands",
(char*)"FR",(char*)"France",
(char*)"FX",(char*)"France, Metropolitan",
(char*)"GA",(char*)"Gabon",
(char*)"GB",(char*)"United Kingdom (Great Britain)",
(char*)"GD",(char*)"Grenada",
(char*)"GE",(char*)"Georgia",
(char*)"GF",(char*)"French Guiana",
(char*)"GH",(char*)"Ghana",
(char*)"GI",(char*)"Gibraltar",
(char*)"GL",(char*)"Greenland",
(char*)"GM",(char*)"Gambia",
(char*)"GN",(char*)"Guinea",
(char*)"GP",(char*)"Guadeloupe",
(char*)"GQ",(char*)"Equatorial Guinea",
(char*)"GR",(char*)"Greece",
(char*)"GS",(char*)"South Georgia and the South Sandwich Islands",
(char*)"GT",(char*)"Guatemala",
(char*)"GU",(char*)"Guam",
(char*)"GW",(char*)"Guinea-Bissau",
(char*)"GY",(char*)"Guyana",
(char*)"HK",(char*)"Hong Kong",
(char*)"HM",(char*)"Heard & McDonald Islands",
(char*)"HN",(char*)"Honduras",
(char*)"HR",(char*)"Croatia",
(char*)"HT",(char*)"Haiti",
(char*)"HU",(char*)"Hungary",
(char*)"ID",(char*)"Indonesia",
(char*)"IE",(char*)"Ireland",
(char*)"IL",(char*)"Israel",
(char*)"IN",(char*)"India",
(char*)"IO",(char*)"British Indian Ocean Territory",
(char*)"IQ",(char*)"Iraq",
(char*)"IR",(char*)"Islamic Republic of Iran",
(char*)"IS",(char*)"Iceland",
(char*)"IT",(char*)"Italy",
(char*)"JM",(char*)"Jamaica",
(char*)"JO",(char*)"Jordan",
(char*)"JP",(char*)"Japan",
(char*)"KE",(char*)"Kenya",
(char*)"KG",(char*)"Kyrgyzstan",
(char*)"KH",(char*)"Cambodia",
(char*)"KI",(char*)"Kiribati",
(char*)"KM",(char*)"Comoros",
(char*)"KN",(char*)"St. Kitts and Nevis",
(char*)"KP",(char*)"Korea, Democratic People's Republic of",
(char*)"KR",(char*)"Korea, Republic of",
(char*)"KW",(char*)"Kuwait",
(char*)"KY",(char*)"Cayman Islands",
(char*)"KZ",(char*)"Kazakhstan",
(char*)"LA",(char*)"Lao People's Democratic Republic",
(char*)"LB",(char*)"Lebanon",
(char*)"LC",(char*)"Saint Lucia",
(char*)"LI",(char*)"Liechtenstein",
(char*)"LK",(char*)"Sri Lanka",
(char*)"LR",(char*)"Liberia",
(char*)"LS",(char*)"Lesotho",
(char*)"LT",(char*)"Lithuania",
(char*)"LU",(char*)"Luxembourg",
(char*)"LV",(char*)"Latvia",
(char*)"LY",(char*)"Libyan Arab Jamahiriya",
(char*)"MA",(char*)"Morocco",
(char*)"MC",(char*)"Monaco",
(char*)"MD",(char*)"Moldova, Republic of",
(char*)"MG",(char*)"Madagascar",
(char*)"MH",(char*)"Marshall Islands",
(char*)"ML",(char*)"Mali",
(char*)"MN",(char*)"Mongolia",
(char*)"MM",(char*)"Myanmar",
(char*)"MO",(char*)"Macau",
(char*)"MP",(char*)"Northern Mariana Islands",
(char*)"MQ",(char*)"Martinique",
(char*)"MR",(char*)"Mauritania",
(char*)"MS",(char*)"Monserrat",
(char*)"MT",(char*)"Malta",
(char*)"MU",(char*)"Mauritius",
(char*)"MV",(char*)"Maldives",
(char*)"MW",(char*)"Malawi",
(char*)"MX",(char*)"Mexico",
(char*)"MY",(char*)"Malaysia",
(char*)"MZ",(char*)"Mozambique",
(char*)"NA",(char*)"Namibia",
(char*)"NC",(char*)"New Caledonia",
(char*)"NE",(char*)"Niger",
(char*)"NF",(char*)"Norfolk Island",
(char*)"NG",(char*)"Nigeria",
(char*)"NI",(char*)"Nicaragua",
(char*)"NL",(char*)"Netherlands",
(char*)"NO",(char*)"Norway",
(char*)"NP",(char*)"Nepal",
(char*)"NR",(char*)"Nauru",
(char*)"NT",(char*)"Neutral Zone",
(char*)"NU",(char*)"Niue",
(char*)"NZ",(char*)"New Zealand",
(char*)"OM",(char*)"Oman",
(char*)"PA",(char*)"Panama",
(char*)"PE",(char*)"Peru",
(char*)"PF",(char*)"French Polynesia",
(char*)"PG",(char*)"Papua New Guinea",
(char*)"PH",(char*)"Philippines",
(char*)"PK",(char*)"Pakistan",
(char*)"PL",(char*)"Poland",
(char*)"PM",(char*)"St. Pierre & Miquelon",
(char*)"PN",(char*)"Pitcairn",
(char*)"PR",(char*)"Puerto Rico",
(char*)"PT",(char*)"Portugal",
(char*)"PW",(char*)"Palau",
(char*)"PY",(char*)"Paraguay",
(char*)"QA",(char*)"Qatar",
(char*)"RE",(char*)"Réunion",
(char*)"RO",(char*)"Romania",
(char*)"RU",(char*)"Russian Federation",
(char*)"RW",(char*)"Rwanda",
(char*)"SA",(char*)"Saudi Arabia",
(char*)"SB",(char*)"Solomon Islands",
(char*)"SC",(char*)"Seychelles",
(char*)"SD",(char*)"Sudan",
(char*)"SE",(char*)"Sweden",
(char*)"SG",(char*)"Singapore",
(char*)"SH",(char*)"St. Helena",
(char*)"SI",(char*)"Slovenia",
(char*)"SJ",(char*)"Svalbard & Jan Mayen Islands",
(char*)"SK",(char*)"Slovakia",
(char*)"SL",(char*)"Sierra Leone",
(char*)"SM",(char*)"San Marino",
(char*)"SN",(char*)"Senegal",
(char*)"SO",(char*)"Somalia",
(char*)"SR",(char*)"Suriname",
(char*)"ST",(char*)"Sao Tome & Principe",
(char*)"SU",(char*)"Union of Soviet Socialist Republics",
(char*)"SV",(char*)"El Salvador",
(char*)"SY",(char*)"Syrian Arab Republic",
(char*)"SZ",(char*)"Swaziland",
(char*)"TC",(char*)"Turks & Caicos Islands",
(char*)"TD",(char*)"Chad",
(char*)"TF",(char*)"French Southern Territories",
(char*)"TG",(char*)"Togo",
(char*)"TH",(char*)"Thailand",
(char*)"TJ",(char*)"Tajikistan",
(char*)"TK",(char*)"Tokelau",
(char*)"TM",(char*)"Turkmenistan",
(char*)"TN",(char*)"Tunisia",
(char*)"TO",(char*)"Tonga",
(char*)"TP",(char*)"East Timor",
(char*)"TR",(char*)"Turkey",
(char*)"TT",(char*)"Trinidad & Tobago",
(char*)"TV",(char*)"Tuvalu",
(char*)"TW",(char*)"Taiwan, Province of China",
(char*)"TZ",(char*)"Tanzania, United Republic of",
(char*)"UA",(char*)"Ukraine",
(char*)"UG",(char*)"Uganda",
(char*)"UM",(char*)"United States Minor Outlying Islands",
(char*)"US",(char*)"United States of America",
(char*)"UY",(char*)"Uruguay",
(char*)"UZ",(char*)"Uzbekistan",
(char*)"VA",(char*)"Vatican City State",
(char*)"VC",(char*)"St. Vincent & the Grenadines",
(char*)"VE",(char*)"Venezuela",
(char*)"VG",(char*)"British Virgin Islands",
(char*)"VI",(char*)"United States Virgin Islands",
(char*)"VN",(char*)"Viet Nam",
(char*)"VU",(char*)"Vanuatu",
(char*)"WF",(char*)"Wallis & Futuna Islands",
(char*)"WS",(char*)"Samoa",
(char*)"YD",(char*)"Democratic Yemen",
(char*)"YE",(char*)"Yemen",
(char*)"YT",(char*)"Mayotte",
(char*)"YU",(char*)"Yugoslavia",
(char*)"ZA",(char*)"South Africa",
(char*)"ZM",(char*)"Zambia",
(char*)"ZR",(char*)"Zaire",
(char*)"ZW",(char*)"Zimbabwe",
(char*)"ZZ",(char*)"Unknown or unspecified country"
};
//#define COUNTRY_CODES_RAW_SIZE ((__LINE__ - 1 - COUNTRY_CODES_RAW_START_LINE) * 2)
#define COUNTRY_CODES_RAW_SIZE 492
#define LANGUAGE_CODES_RAW_START_LINE (__LINE__ + 2)
static char * languageCodesraw[]={
(char*)"aa",(char*)"Afar",
(char*)"ab",(char*)"Abkhazian",
(char*)"ae",(char*)"Avestan",
(char*)"af",(char*)"Afrikaans",
(char*)"ak",(char*)"Akan",
(char*)"am",(char*)"Amharic",
(char*)"an",(char*)"Aragonese",
(char*)"ar",(char*)"Arabic",
(char*)"as",(char*)"Assamese",
(char*)"av",(char*)"Avaric",
(char*)"ay",(char*)"Aymara",
(char*)"az",(char*)"Azerbaijani",
(char*)"ba",(char*)"Bashkir",
(char*)"be",(char*)"Belarusian",
(char*)"bg",(char*)"Bulgarian",
(char*)"bh",(char*)"Bihari",
(char*)"bi",(char*)"Bislama",
(char*)"bm",(char*)"Bambara",
(char*)"bn",(char*)"Bengali",
(char*)"bo",(char*)"Tibetan",
(char*)"br",(char*)"Breton",
(char*)"bs",(char*)"Bosnian",
(char*)"ca",(char*)"Catalan",
(char*)"ce",(char*)"Chechen",
(char*)"ch",(char*)"Chamorro",
(char*)"co",(char*)"Corsican",
(char*)"cr",(char*)"Cree",
(char*)"cs",(char*)"Czech",
(char*)"cu",(char*)"ChurchSlavic",
(char*)"cv",(char*)"Chuvash",
(char*)"cy",(char*)"Welsh",
(char*)"da",(char*)"Danish",
(char*)"de",(char*)"German",
(char*)"dv",(char*)"Divehi",
(char*)"dz",(char*)"Dzongkha",
(char*)"ee",(char*)"Ewe",
(char*)"el",(char*)"ModernGreek",
(char*)"en",(char*)"English",
(char*)"eo",(char*)"Esperanto",
(char*)"es",(char*)"Spanish",
(char*)"et",(char*)"Estonian",
(char*)"eu",(char*)"Basque",
(char*)"fa",(char*)"Persian",
(char*)"ff",(char*)"Fulah",
(char*)"fi",(char*)"Finnish",
(char*)"fj",(char*)"Fijian",
(char*)"fo",(char*)"Faroese",
(char*)"fr",(char*)"French",
(char*)"fy",(char*)"WesternFrisian",
(char*)"ga",(char*)"Irish",
(char*)"gd",(char*)"Gaelic",
(char*)"gl",(char*)"Galician",
(char*)"gn",(char*)"Guaraní",
(char*)"gu",(char*)"Gujarati",
(char*)"gv",(char*)"Manx",
(char*)"ha",(char*)"Hausa",
(char*)"he",(char*)"ModernHebrew",
(char*)"hi",(char*)"Hindi",
(char*)"ho",(char*)"HiriMotu",
(char*)"hr",(char*)"Croatian",
(char*)"ht",(char*)"Haitian",
(char*)"hu",(char*)"Hungarian",
(char*)"hy",(char*)"Armenian",
(char*)"hz",(char*)"Herero",
(char*)"ia",(char*)"Interlingua",
(char*)"id",(char*)"Indonesian",
(char*)"ie",(char*)"Interlingue",
(char*)"ig",(char*)"Igbo",
(char*)"ii",(char*)"SichuanYi",
(char*)"ik",(char*)"Inupiaq",
(char*)"io",(char*)"Ido",
(char*)"is",(char*)"Icelandic",
(char*)"it",(char*)"Italian",
(char*)"iu",(char*)"Inuktitut",
(char*)"ja",(char*)"Japanese",
(char*)"jv",(char*)"Javanese",
(char*)"ka",(char*)"Georgian",
(char*)"kg",(char*)"Kongo",
(char*)"ki",(char*)"Kikuyu",
(char*)"kj",(char*)"Kwanyama",
(char*)"kk",(char*)"Kazakh",
(char*)"kl",(char*)"Kalaallisut",
(char*)"km",(char*)"CentralKhmer",
(char*)"kn",(char*)"Kannada",
(char*)"ko",(char*)"Korean",
(char*)"kr",(char*)"Kanuri",
(char*)"ks",(char*)"Kashmiri",
(char*)"ku",(char*)"Kurdish",
(char*)"kv",(char*)"Komi",
(char*)"kw",(char*)"Cornish",
(char*)"ky",(char*)"Kirghiz",
(char*)"la",(char*)"Latin",
(char*)"lb",(char*)"Luxembourgish",
(char*)"lg",(char*)"Ganda",
(char*)"li",(char*)"Limburgish",
(char*)"ln",(char*)"Lingala",
(char*)"lo",(char*)"Lao",
(char*)"lt",(char*)"Lithuanian",
(char*)"lu",(char*)"Luba-Katanga",
(char*)"lv",(char*)"Latvian",
(char*)"mg",(char*)"Malagasy",
(char*)"mh",(char*)"Marshallese",
(char*)"mi",(char*)"Maori",
(char*)"mk",(char*)"Macedonian",
(char*)"ml",(char*)"Malayalam",
(char*)"mn",(char*)"Mongolian",
(char*)"mr",(char*)"Marathi",
(char*)"ms",(char*)"Malay",
(char*)"mt",(char*)"Maltese",
(char*)"my",(char*)"Burmese",
(char*)"na",(char*)"Nauru",
(char*)"nb",(char*)"NorwegianBokmal",
(char*)"nd",(char*)"NorthNdebele",
(char*)"ne",(char*)"Nepali",
(char*)"ng",(char*)"Ndonga",
(char*)"nl",(char*)"Dutch/Flemish",
(char*)"nn",(char*)"NorwegianNynorsk",
(char*)"no",(char*)"Norwegian",
(char*)"nr",(char*)"SouthNdebele",
(char*)"nv",(char*)"Navajo/Navaho",
(char*)"ny",(char*)"Nyanja",
(char*)"oc",(char*)"Occitan",
(char*)"oj",(char*)"Ojibwa",
(char*)"om",(char*)"Oromo",
(char*)"or",(char*)"Oriya",
(char*)"os",(char*)"Ossetian",
(char*)"pa",(char*)"Panjabi",
(char*)"pi",(char*)"Pali",
(char*)"pl",(char*)"Polish",
(char*)"ps",(char*)"Pashto/Pushto",
(char*)"pt",(char*)"Portuguese",
(char*)"qu",(char*)"Quechua",
(char*)"rm",(char*)"Romansh",
(char*)"rn",(char*)"Rundi",
(char*)"ro",(char*)"Romanian",
(char*)"ru",(char*)"Russian",
(char*)"rw",(char*)"Kinyarwanda",
(char*)"sa",(char*)"Sanskrit",
(char*)"sc",(char*)"Sardinian",
(char*)"sd",(char*)"Sindhi",
(char*)"se",(char*)"NorthernSami",
(char*)"sg",(char*)"Sango",
(char*)"si",(char*)"Sinhala",
(char*)"sk",(char*)"Slovak",
(char*)"sl",(char*)"Slovene",
(char*)"sm",(char*)"Samoan",
(char*)"sn",(char*)"Shona",
(char*)"so",(char*)"Somali",
(char*)"sq",(char*)"Albanian",
(char*)"sr",(char*)"Serbian",
(char*)"ss",(char*)"Swati",
(char*)"st",(char*)"SouthernSotho",
(char*)"su",(char*)"Sundanese",
(char*)"sv",(char*)"Swedish",
(char*)"sw",(char*)"Swahili",
(char*)"ta",(char*)"Tamil",
(char*)"te",(char*)"Telugu",
(char*)"tg",(char*)"Tajik",
(char*)"th",(char*)"Thai",
(char*)"ti",(char*)"Tigrinya",
(char*)"tk",(char*)"Turkmen",
(char*)"tl",(char*)"Tagalog",
(char*)"tn",(char*)"Tswana",
(char*)"to",(char*)"Tonga",
(char*)"tr",(char*)"Turkish",
(char*)"ts",(char*)"Tsonga",
(char*)"tt",(char*)"Tatar",
(char*)"tw",(char*)"Twi",
(char*)"ty",(char*)"Tahitian",
(char*)"ug",(char*)"Uighur",
(char*)"uk",(char*)"Ukrainian",
(char*)"ur",(char*)"Urdu",
(char*)"uz",(char*)"Uzbek",
(char*)"ve",(char*)"Venda",
(char*)"vi",(char*)"Vietnamese",
(char*)"vo",(char*)"Volapük",
(char*)"wa",(char*)"Walloon",
(char*)"wo",(char*)"Wolof",
(char*)"xh",(char*)"Xhosa",
(char*)"yi",(char*)"Yiddish",
(char*)"yo",(char*)"Yoruba",
(char*)"za",(char*)"Zhuang",
(char*)"zh",(char*)"Chinese",
(char*)"zu",(char*)"Zulu"
};
//#define LANGUAGE_CODES_RAW_SIZE ((__LINE__ - 1 - LANGUAGE_CODES_RAW_START_LINE) * 2)
#define LANGUAGE_CODES_RAW_SIZE 368
lggHunSpell_Wrapper::lggHunSpell_Wrapper()
{
//languageCodes(begin(languageCodesraw), end(languageCodesraw));
mSpellCheckHighlight = rebind_llcontrol<BOOL>("EmeraldSpellDisplay", &gSavedSettings, true);
}
lggHunSpell_Wrapper::~lggHunSpell_Wrapper()
{
}
std::string lggHunSpell_Wrapper::getCorrectPath(std::string file)
{
//finds out if it is in user dir, if not, takes it from app dir
std::string dicpath1(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", file).c_str());
if (!gDirUtilp->fileExists(dicpath1))
{
dicpath1=gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", file).c_str();
}
return dicpath1;
}
void lggHunSpell_Wrapper::setNewDictionary(std::string newDict)
{
llinfos << "Setting new base dictionary long name is-> " << newDict.c_str() << llendl;
currentBaseDic = newDict;
//expecting a full name comming in
newDict = fullName2DictName(newDict);
if (myHunspell)
{
delete myHunspell;
}
std::string dicaffpath = getCorrectPath(newDict+".aff");
std::string dicdicpath = getCorrectPath(newDict+".dic");
llinfos << "Setting new base dictionary -> " << dicaffpath.c_str() << llendl;
myHunspell = new Hunspell(dicaffpath.c_str(), dicdicpath.c_str());
llinfos << "Adding custom dictionary " << llendl;
createCustomDic();
addDictionary("custom");
std::vector<std::string> toInstall = getInstalledDicts();
for (int i = 0; i < (int)toInstall.size(); i++)
{
addDictionary(toInstall[i]);
}
}
void lggHunSpell_Wrapper::createCustomDic()
{
std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "custom.dic"));
if (!gDirUtilp->fileExists(filename))
{
llofstream export_file;
export_file.open(filename);
std::string sizePart("1\nLordGregGreg\n");
export_file.write(sizePart.c_str(),sizePart.length());
export_file.close();
}
}
void lggHunSpell_Wrapper::addWordToCustomDictionary(std::string wordToAdd)
{
if (!myHunspell)
{
return;
}
myHunspell->add(wordToAdd.c_str());
std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "custom.dic"));
std::vector<std::string> lines;
if (gDirUtilp->fileExists(filename))
{
//get words already there..
llifstream importer(filename);
std::string line;
if (getline( importer, line ))//ignored the size
{
while ( getline( importer, line ) ) lines.push_back(line);
}
importer.close();
}
llofstream export_file;
export_file.open(filename);
std::string sizePart(llformat("%i", (int)(lines.size()+1)) + "\n");
export_file.write(sizePart.c_str(), sizePart.length());
for (int i = 0; i < (int)lines.size() ;i++)
{
export_file.write(std::string(lines[i]+"\n").c_str(),lines[i].length()+1);
}
//LLStringUtil::toLower(wordToAdd);
wordToAdd = wordToAdd+std::string("\n");
export_file.write(wordToAdd.c_str(), wordToAdd.length());
//export_file << std::hex << 10 ;
export_file.close();
}
BOOL lggHunSpell_Wrapper::isSpelledRight(std::string wordToCheck)
{
if (!myHunspell || wordToCheck.length() < 3)
{
return TRUE;
}
return myHunspell->spell(wordToCheck.c_str());
}
std::vector<std::string> lggHunSpell_Wrapper::getSuggestionList(std::string badWord)
{
std::vector<std::string> toReturn;
if (!myHunspell)
{
return toReturn;
}
char** suggestionList;
int numberOfSuggestions = myHunspell->suggest(&suggestionList, badWord.c_str());
if (numberOfSuggestions <= 0)
{
return toReturn;
}
for (int i = 0; i < numberOfSuggestions; i++)
{
std::string tempSugg(suggestionList[i]);
toReturn.push_back(tempSugg);
}
myHunspell->free_list(&suggestionList,numberOfSuggestions);
return toReturn;
}
void lggHunSpell_Wrapper::debugTest(std::string testWord)
{
llinfos << "Testing to see if " << testWord.c_str() << " is spelled correct" << llendl;
if (isSpelledRight(testWord))
{
llinfos << testWord.c_str() << " is spelled correctly" << llendl;
}
else
{
llinfos << testWord.c_str() << " is not spelled correctly, getting suggestions" << llendl;
std::vector<std::string> suggList;
suggList.clear();
suggList = getSuggestionList(testWord);
llinfos << "Got suggestions.. " << llendl;
for (int i = 0; i < (int)suggList.size(); i++)
{
llinfos << "Suggestion for " << testWord.c_str() << ":" << suggList[i].c_str() << llendl;
}
}
}
void lggHunSpell_Wrapper::initSettings()
{
glggHunSpell = new lggHunSpell_Wrapper();
glggHunSpell->processSettings();
}
void lggHunSpell_Wrapper::processSettings()
{
//expects everything to already be in saved settings
//this will also reload and read the installed dicts
setNewDictionary(gSavedSettings.getString("EmeraldSpellBase"));
}
void lggHunSpell_Wrapper::addDictionary(std::string additionalDictionary)
{
if (!myHunspell || additionalDictionary.empty())
{
return;
}
//expecting a full name here
std::string dicpath = getCorrectPath(fullName2DictName(additionalDictionary)+".dic");
if (gDirUtilp->fileExists(dicpath))
{
llinfos << "Adding additional dictionary -> " << dicpath.c_str() << llendl;
myHunspell->add_dic(dicpath.c_str());
}
}
std::string lggHunSpell_Wrapper::dictName2FullName(std::string dictName)
{
if (dictName.empty())
{
return dictName;
}
std::string countryCode("");
std::string languageCode("");
//remove extension
dictName = dictName.substr(0,dictName.find("."));
//break it up by - or _
S32 breakPoint = dictName.find("-");
if (breakPoint == std::string::npos)
{
breakPoint = dictName.find("_");
}
if (breakPoint == std::string::npos)
{
//no country code given
languageCode = dictName;
}
else
{
languageCode = dictName.substr(0,breakPoint);
countryCode = dictName.substr(breakPoint+1);
}
//get long language code
for (int i = 0; i<LANGUAGE_CODES_RAW_SIZE; i++)
{
if (0 == LLStringUtil::compareInsensitive(languageCode, std::string(languageCodesraw[i])))
{
languageCode = languageCodesraw[i+1];
break;
}
}
//get long country code
if (!countryCode.empty())
{
for (int i =0; i<COUNTRY_CODES_RAW_SIZE; i++)
{
//llinfos << i << llendl;
if (0 == LLStringUtil::compareInsensitive(countryCode, std::string(countryCodesraw[i])))
{
countryCode = countryCodesraw[i+1];
break;
}
}
countryCode = " (" + countryCode + ")";
}
return std::string(languageCode+countryCode);
}
std::string lggHunSpell_Wrapper::fullName2DictName(std::string fullName)
{
std::string countryCode("");
std::string languageCode("");
S32 breakPoint = fullName.find(" (");
if (breakPoint == std::string::npos)
{
languageCode = fullName;
}
else
{
languageCode = fullName.substr(0, breakPoint);
countryCode = fullName.substr(breakPoint+2, fullName.length()-3-breakPoint);
}
//get long language code
for (int i = 1; i<LANGUAGE_CODES_RAW_SIZE; i+=2)
{
//llinfos << i << llendl;
if (0 == LLStringUtil::compareInsensitive(languageCode, std::string(languageCodesraw[i])))
{
languageCode = std::string(languageCodesraw[i-1]);
break;
}
}
//get long country code
std::string toReturn = languageCode;
if (!countryCode.empty())
{
for (int i = 1; i<COUNTRY_CODES_RAW_SIZE; i+=2)
{
//llinfos << i << " comparing " <<countryCode<<" and "<<std::string(countryCodesraw[i]).c_str()<< llendl;
if (0 == LLStringUtil::compareInsensitive(countryCode, std::string(countryCodesraw[i])))
{
countryCode = std::string(countryCodesraw[i-1]);
break;
}
}
toReturn += "_" + countryCode;
}
LLStringUtil::toLower(toReturn);
return toReturn;
}
std::vector <std::string> lggHunSpell_Wrapper::getDicts()
{
std::vector<std::string> names;
std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", ""));
bool found = true;
while (found)
{
std::string name;
found = gDirUtilp->getNextFileInDir(path_name, "*.aff", name, false);
if (found)
{
names.push_back(dictName2FullName(name));
}
}
path_name = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "");
found = true;
while (found)
{
std::string name;
found = gDirUtilp->getNextFileInDir(path_name, "*.aff", name, false);
if (found)
{
names.push_back(dictName2FullName(name));
}
}
return names;
}
std::vector <std::string> lggHunSpell_Wrapper::getExtraDicts()
{
std::vector<std::string> names;
std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", ""));
bool found = true;
while (found)
{
std::string name;
found = gDirUtilp->getNextFileInDir(path_name, "*.dic", name, false);
if (found)
{
names.push_back(dictName2FullName(name));
}
}
path_name = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "");
found = true;
while (found)
{
std::string name;
found = gDirUtilp->getNextFileInDir(path_name, "*.dic", name, false);
if (found)
{
names.push_back(dictName2FullName(name));
}
}
return names;
}
std::vector<std::string> lggHunSpell_Wrapper::getInstalledDicts()
{
std::vector<std::string> toReturn;
//expecting short names to be stored...
std::vector<std::string> shortNames = CSV2VEC(gSavedSettings.getString("EmeraldSpellInstalled"));
for (int i =0; i < (int)shortNames.size(); i++)
{
toReturn.push_back(dictName2FullName(shortNames[i]));
}
return toReturn;
}
std::vector<std::string> lggHunSpell_Wrapper::getAvailDicts()
{
std::vector<std::string> toReturn;
std::vector<std::string> dics = getExtraDicts();
std::vector<std::string> installedDics = getInstalledDicts();
for (int i = 0; i < (int)dics.size(); i++)
{
bool found = false;
for (int j = 0; j < (int)installedDics.size(); j++)
{
if (0 == LLStringUtil::compareInsensitive(dics[i], installedDics[j]))
{
found = true;//this dic is already installed
}
}
if (0 == LLStringUtil::compareInsensitive(dics[i], currentBaseDic))
{
found = true;
}
if (0 == LLStringUtil::compareInsensitive(dics[i], "Emerald (CUSTOM)"))
{
found = true;
}
if (!found)
{
toReturn.push_back(dics[i]);
}
}
return toReturn;
}
std::vector<std::string> lggHunSpell_Wrapper::CSV2VEC(std::string csv)
{
std::vector<std::string> toReturn;
boost::regex re(",");
boost::sregex_token_iterator i(csv.begin(), csv.end(), re, -1);
boost::sregex_token_iterator j;
while (i != j)
{
toReturn.push_back(*i++);
}
return toReturn;
}
std::string lggHunSpell_Wrapper::VEC2CSV(std::vector<std::string> vec)
{
std::string toReturn("");
if (vec.size() < 1)
{
return toReturn;
}
for (int i = 0;i < (int)vec.size() ;i++)
{
toReturn += vec[i] + ",";
}
return toReturn.erase(toReturn.length()-1);
}
void lggHunSpell_Wrapper::addButton(std::string selection)
{
if (selection.empty())
{
return;
}
addDictionary(selection);
std::vector<std::string> alreadyInstalled = CSV2VEC(gSavedSettings.getString("EmeraldSpellInstalled"));
alreadyInstalled.push_back(fullName2DictName(selection));
gSavedSettings.setString("EmeraldSpellInstalled", VEC2CSV(alreadyInstalled));
}
void lggHunSpell_Wrapper::removeButton(std::string selection)
{
if (selection.empty())
{
return;
}
std::vector<std::string> newInstalledDics;
std::vector<std::string> currentlyInstalled = getInstalledDicts();
for (int i = 0; i < (int)currentlyInstalled.size(); i++)
{
if (0 != LLStringUtil::compareInsensitive(selection, currentlyInstalled[i]))
{
newInstalledDics.push_back(fullName2DictName(currentlyInstalled[i]));
}
}
gSavedSettings.setString("EmeraldSpellInstalled", VEC2CSV(newInstalledDics));
processSettings();
}
void lggHunSpell_Wrapper::newDictSelection(std::string selection)
{
currentBaseDic = selection;
gSavedSettings.setString("EmeraldSpellBase", selection);
//better way to do this would be to check and see if there is a installed conflict
//and then only remove that one.. messy
gSavedSettings.setString("EmeraldSpellInstalled", "en_sl");
processSettings();
}
void lggHunSpell_Wrapper::getMoreButton(void* data)
{
std::vector<std::string> shortNames;
std::vector<std::string> longNames;
LLSD response = LLHTTPClient::blockingGet(gSavedSettings.getString("DicDownloadBaseURL")+"dic_list.xml");
if (response.has("body"))
{
const LLSD &dict_list = response["body"];
if (dict_list.has("isComplete"))
{
LLSD dics = dict_list["data"];
for (int i = 0; i < dics.size(); i++)
{
std::string dicFullName = dictName2FullName(dics[i].asString());
longNames.push_back(dicFullName);
shortNames.push_back(fullName2DictName(dicFullName));
}
LggDicDownload::show(true,shortNames,longNames, data);
}
}
}
void lggHunSpell_Wrapper::editCustomButton()
{
std::string dicdicpath(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", std::string("custom.dic")).c_str());
if (!gDirUtilp->fileExists(dicdicpath))
{
createCustomDic();
//glggHunSpell->addWordToCustomDictionary("temp");
}
gViewerWindow->getWindow()->ShellEx(dicdicpath);
}
void lggHunSpell_Wrapper::setSpellCheckHighlight(BOOL highlight)
{
gSavedSettings.setBOOL("EmeraldSpellDisplay", highlight);
}
|