-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathlanguage.rs
2590 lines (2329 loc) · 74.8 KB
/
language.rs
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
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const PRIMARY_LANGUAGE_MASK: u16 = 0x03FF;
const SUB_LANGUAGE_MASK: u16 = 0xFC00;
/// A language used to read string descriptors from USB devices.
///
/// A language consists of a primary language and a sub language. Primary languages are language
/// families, such as English or Spanish. Sub languages identify a dialect of the primary language.
/// The dialect may be based on regional differences (United States English compared to United
/// Kingdom English), writing systems (Cyrillic compared to Latin), or age (Modern compared to
/// Traditional). Each primary language has its own set of sub languages.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Language {
raw: u16,
}
impl Language {
/// Returns the language's 16-bit `LANGID`.
///
/// Each language's `LANGID` is defined by the USB forum
/// <https://learn.microsoft.com/en-us/windows/win32/intl/language-identifier-constants-and-strings>.
pub fn lang_id(self) -> u16 {
self.raw
}
/// Returns the primary language.
pub fn primary_language(self) -> PrimaryLanguage {
PrimaryLanguage::from_raw(self.raw)
}
/// Returns the sub language.
pub fn sub_language(self) -> SubLanguage {
SubLanguage::from_raw(self.primary_language(), self.raw)
}
/// Creates a new `Language` from a raw 16-bit `LANGID`.
///
/// The `LANGID` should follow the USB forum's language identifier specification, where
/// the lower 10 bits represent the sub language and the upper 6 bits represent the primary language.
///
/// # Examples
/// ```
/// use rusb::{Language,SubLanguage,PrimaryLanguage};
/// // Create English (United States) language
/// let lang = Language::new(0x0409);
/// assert_eq!(lang.primary_language(), PrimaryLanguage::English);
/// assert_eq!(lang.sub_language(), SubLanguage::UnitedStates);
/// ```
pub fn new(raw: u16) -> Self {
Language { raw }
}
}
#[doc(hidden)]
pub(crate) fn from_lang_id(raw: u16) -> Language {
Language { raw }
}
/// Primary language families.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum PrimaryLanguage {
Afrikaans,
Albanian,
Arabic,
Armenian,
Assamese,
Azeri,
Basque,
Belarussian,
Bengali,
Bulgarian,
Burmese,
Catalan,
Chinese,
Croatian,
Czech,
Danish,
Dutch,
English,
Estonian,
Faeroese,
Farsi,
Finnish,
French,
Georgian,
German,
Greek,
Gujarati,
Hebrew,
Hindi,
Hungarian,
Icelandic,
Indonesian,
Italian,
Japanese,
Kannada,
Kashmiri,
Kazakh,
Konkani,
Korean,
Latvian,
Lithuanian,
Macedonian,
Malay,
Malayalam,
Manipuri,
Marathi,
Nepali,
Norwegian,
Oriya,
Polish,
Portuguese,
Punjabi,
Romanian,
Russian,
Sanskrit,
Serbian,
Sindhi,
Slovak,
Slovenian,
Spanish,
Sutu,
Swahili,
Swedish,
Tamil,
Tatar,
Telugu,
Thai,
Turkish,
Ukrainian,
Urdu,
Uzbek,
Vietnamese,
HID,
Other(u16),
}
impl PrimaryLanguage {
fn from_raw(raw: u16) -> PrimaryLanguage {
match raw & PRIMARY_LANGUAGE_MASK {
0x0036 => PrimaryLanguage::Afrikaans,
0x001C => PrimaryLanguage::Albanian,
0x0001 => PrimaryLanguage::Arabic,
0x002B => PrimaryLanguage::Armenian,
0x004D => PrimaryLanguage::Assamese,
0x002C => PrimaryLanguage::Azeri,
0x002D => PrimaryLanguage::Basque,
0x0023 => PrimaryLanguage::Belarussian,
0x0045 => PrimaryLanguage::Bengali,
0x0002 => PrimaryLanguage::Bulgarian,
0x0055 => PrimaryLanguage::Burmese,
0x0003 => PrimaryLanguage::Catalan,
0x0004 => PrimaryLanguage::Chinese,
0x001A => match raw & SUB_LANGUAGE_MASK {
0x0400 => PrimaryLanguage::Croatian,
_ => PrimaryLanguage::Serbian,
},
0x0005 => PrimaryLanguage::Czech,
0x0006 => PrimaryLanguage::Danish,
0x0013 => PrimaryLanguage::Dutch,
0x0009 => PrimaryLanguage::English,
0x0025 => PrimaryLanguage::Estonian,
0x0038 => PrimaryLanguage::Faeroese,
0x0029 => PrimaryLanguage::Farsi,
0x000B => PrimaryLanguage::Finnish,
0x000C => PrimaryLanguage::French,
0x0037 => PrimaryLanguage::Georgian,
0x0007 => PrimaryLanguage::German,
0x0008 => PrimaryLanguage::Greek,
0x0047 => PrimaryLanguage::Gujarati,
0x000D => PrimaryLanguage::Hebrew,
0x0039 => PrimaryLanguage::Hindi,
0x000E => PrimaryLanguage::Hungarian,
0x000F => PrimaryLanguage::Icelandic,
0x0021 => PrimaryLanguage::Indonesian,
0x0010 => PrimaryLanguage::Italian,
0x0011 => PrimaryLanguage::Japanese,
0x004B => PrimaryLanguage::Kannada,
0x0060 => PrimaryLanguage::Kashmiri,
0x003F => PrimaryLanguage::Kazakh,
0x0057 => PrimaryLanguage::Konkani,
0x0012 => PrimaryLanguage::Korean,
0x0026 => PrimaryLanguage::Latvian,
0x0027 => PrimaryLanguage::Lithuanian,
0x002F => PrimaryLanguage::Macedonian,
0x003E => PrimaryLanguage::Malay,
0x004C => PrimaryLanguage::Malayalam,
0x0058 => PrimaryLanguage::Manipuri,
0x004E => PrimaryLanguage::Marathi,
0x0061 => PrimaryLanguage::Nepali,
0x0014 => PrimaryLanguage::Norwegian,
0x0048 => PrimaryLanguage::Oriya,
0x0015 => PrimaryLanguage::Polish,
0x0016 => PrimaryLanguage::Portuguese,
0x0046 => PrimaryLanguage::Punjabi,
0x0018 => PrimaryLanguage::Romanian,
0x0019 => PrimaryLanguage::Russian,
0x004F => PrimaryLanguage::Sanskrit,
0x0059 => PrimaryLanguage::Sindhi,
0x001B => PrimaryLanguage::Slovak,
0x0024 => PrimaryLanguage::Slovenian,
0x000A => PrimaryLanguage::Spanish,
0x0030 => PrimaryLanguage::Sutu,
0x0041 => PrimaryLanguage::Swahili,
0x001D => PrimaryLanguage::Swedish,
0x0049 => PrimaryLanguage::Tamil,
0x0044 => PrimaryLanguage::Tatar,
0x004A => PrimaryLanguage::Telugu,
0x001E => PrimaryLanguage::Thai,
0x001F => PrimaryLanguage::Turkish,
0x0022 => PrimaryLanguage::Ukrainian,
0x0020 => PrimaryLanguage::Urdu,
0x0043 => PrimaryLanguage::Uzbek,
0x002A => PrimaryLanguage::Vietnamese,
0x00FF => PrimaryLanguage::HID,
n => PrimaryLanguage::Other(n),
}
}
}
/// Language dialects and writing systems.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum SubLanguage {
Standard,
Classic,
Traditional,
Modern,
Algeria, // arabic
Argentina, // spanish
Australia, // english
Austria, // german
Bahrain, // arabic
Belgium, // dutch, french
Belize, // english
Bokmal, // norwegian
Bolivia, // spanish
Brazil, // portuguese
BruneiDarussalam, // malay
Canada, // english, french
Caribbean, // english
Chile, // spanish
China, // chinese
Colombia, // spanish
CostaRica, // spanish
Cyrillic, // azeri, serbian, uzbek
DominicanRepublic, // spanish
Ecuador, // spanish
Egypt, // arabic
ElSalvador, // spanish
Finland, // swedish
Guatemala, // spanish
Honduras, // spanish
HongKong, // chinese
India, // kashmiri, nepali, urdu
Iraq, // arabic
Ireland, // english
Jamaica, // english
Johab, // korean
Jordan, // arabic
Kuwait, // arabic
Latin, // azeri, serbian, uzbek
Lebanon, // arabic
Libya, // arabic
Liechtenstein, // german
Luxembourg, // french, german
Macau, // chinese
Malaysia, // malay
Mexico, // spanish
Monaco, // french
Morocco, // arabic
Netherlands, // dutch
NewZealand, // english
Nicaragua, // spanish
Nynorsk, // norwegian
Oman, // arabic
Pakistan, // urdu
Panama, // spanish
Paraguay, // spanish
Peru, // spanish
Philippines, // english
PuertoRico, // spanish
Qatar, // arabic
SaudiArabia, // arabic
Singapore, // chinese
SouthAfrica, // english
Switzerland, // french, german, italian
Syria, // arabic
Taiwan, // chinese
Trinidad, // english
Tunisia, // arabic
UnitedArabEmirates, // arabic
UnitedKingdom, // english
UnitedStates, // english
Uruguay, // spanish
Venezuela, // spanish
Yemen, // arabic
Zimbabwe, // english
UsageDataDescriptor, // HID
VendorDefined1, // HID
VendorDefined2, // HID
VendorDefined3, // HID
VendorDefined4, // HID
Other(u16),
}
impl SubLanguage {
fn from_raw(language: PrimaryLanguage, raw: u16) -> SubLanguage {
match language {
PrimaryLanguage::Arabic => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::SaudiArabia,
0x0800 => SubLanguage::Iraq,
0x0C00 => SubLanguage::Egypt,
0x1000 => SubLanguage::Libya,
0x1400 => SubLanguage::Algeria,
0x1800 => SubLanguage::Morocco,
0x1C00 => SubLanguage::Tunisia,
0x2000 => SubLanguage::Oman,
0x2400 => SubLanguage::Yemen,
0x2800 => SubLanguage::Syria,
0x2C00 => SubLanguage::Jordan,
0x3000 => SubLanguage::Lebanon,
0x3400 => SubLanguage::Kuwait,
0x3800 => SubLanguage::UnitedArabEmirates,
0x3C00 => SubLanguage::Bahrain,
0x4000 => SubLanguage::Qatar,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Azeri => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Latin,
0x0800 => SubLanguage::Cyrillic,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Chinese => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Taiwan,
0x0800 => SubLanguage::China,
0x0C00 => SubLanguage::HongKong,
0x1000 => SubLanguage::Singapore,
0x1400 => SubLanguage::Macau,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Dutch => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Netherlands,
0x0800 => SubLanguage::Belgium,
n => SubLanguage::Other(n),
},
PrimaryLanguage::English => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::UnitedStates,
0x0800 => SubLanguage::UnitedKingdom,
0x0C00 => SubLanguage::Australia,
0x1000 => SubLanguage::Canada,
0x1400 => SubLanguage::NewZealand,
0x1800 => SubLanguage::Ireland,
0x1C00 => SubLanguage::SouthAfrica,
0x2000 => SubLanguage::Jamaica,
0x2400 => SubLanguage::Caribbean,
0x2800 => SubLanguage::Belize,
0x2C00 => SubLanguage::Trinidad,
0x3000 => SubLanguage::Zimbabwe,
0x3400 => SubLanguage::Philippines,
n => SubLanguage::Other(n),
},
PrimaryLanguage::French => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Standard,
0x0800 => SubLanguage::Belgium,
0x0C00 => SubLanguage::Canada,
0x1000 => SubLanguage::Switzerland,
0x1400 => SubLanguage::Luxembourg,
0x1800 => SubLanguage::Monaco,
n => SubLanguage::Other(n),
},
PrimaryLanguage::German => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Standard,
0x0800 => SubLanguage::Switzerland,
0x0C00 => SubLanguage::Austria,
0x1000 => SubLanguage::Luxembourg,
0x1400 => SubLanguage::Liechtenstein,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Italian => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Standard,
0x0800 => SubLanguage::Switzerland,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Korean => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Standard,
0x0800 => SubLanguage::Johab,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Lithuanian => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Standard,
0x0800 => SubLanguage::Classic,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Malay => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Malaysia,
0x0800 => SubLanguage::BruneiDarussalam,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Norwegian => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Bokmal,
0x0800 => SubLanguage::Nynorsk,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Portuguese => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Brazil,
0x0800 => SubLanguage::Standard,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Serbian => match raw & SUB_LANGUAGE_MASK {
0x0C00 => SubLanguage::Cyrillic,
0x0800 => SubLanguage::Latin,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Spanish => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Traditional,
0x0800 => SubLanguage::Mexico,
0x0C00 => SubLanguage::Modern,
0x1000 => SubLanguage::Guatemala,
0x1400 => SubLanguage::CostaRica,
0x1800 => SubLanguage::Panama,
0x1C00 => SubLanguage::DominicanRepublic,
0x2000 => SubLanguage::Venezuela,
0x2400 => SubLanguage::Colombia,
0x2800 => SubLanguage::Peru,
0x2C00 => SubLanguage::Argentina,
0x3000 => SubLanguage::Ecuador,
0x3400 => SubLanguage::Chile,
0x3800 => SubLanguage::Uruguay,
0x3C00 => SubLanguage::Paraguay,
0x4000 => SubLanguage::Bolivia,
0x4400 => SubLanguage::ElSalvador,
0x4800 => SubLanguage::Honduras,
0x4C00 => SubLanguage::Nicaragua,
0x5000 => SubLanguage::PuertoRico,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Swedish => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Standard,
0x0800 => SubLanguage::Finland,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Urdu => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Pakistan,
0x0800 => SubLanguage::India,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Uzbek => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::Latin,
0x0800 => SubLanguage::Cyrillic,
n => SubLanguage::Other(n),
},
PrimaryLanguage::HID => match raw & SUB_LANGUAGE_MASK {
0x0400 => SubLanguage::UsageDataDescriptor,
0xF000 => SubLanguage::VendorDefined1,
0xF400 => SubLanguage::VendorDefined2,
0xF800 => SubLanguage::VendorDefined3,
0xFC00 => SubLanguage::VendorDefined4,
n => SubLanguage::Other(n),
},
PrimaryLanguage::Other(_) => SubLanguage::Other(raw & SUB_LANGUAGE_MASK),
_ => SubLanguage::Standard,
}
}
}
#[cfg(test)]
mod test {
use super::{PrimaryLanguage, SubLanguage};
use super::{PRIMARY_LANGUAGE_MASK, SUB_LANGUAGE_MASK};
// language ids defined in http://www.usb.org/developers/docs/USB_LANGIDs.pdf
const AFRIKAANS: u16 = 0x0436;
const ALBANIAN: u16 = 0x041C;
const ARABIC_SAUDI_ARABIA: u16 = 0x0401;
const ARABIC_IRAQ: u16 = 0x0801;
const ARABIC_EGYPT: u16 = 0x0C01;
const ARABIC_LIBYA: u16 = 0x1001;
const ARABIC_ALGERIA: u16 = 0x1401;
const ARABIC_MOROCCO: u16 = 0x1801;
const ARABIC_TUNISIA: u16 = 0x1C01;
const ARABIC_OMAN: u16 = 0x2001;
const ARABIC_YEMEN: u16 = 0x2401;
const ARABIC_SYRIA: u16 = 0x2801;
const ARABIC_JORDAN: u16 = 0x2C01;
const ARABIC_LEBANON: u16 = 0x3001;
const ARABIC_KUWAIT: u16 = 0x3401;
const ARABIC_UAE: u16 = 0x3801;
const ARABIC_BAHRAIN: u16 = 0x3C01;
const ARABIC_QATAR: u16 = 0x4001;
const ARMENIAN: u16 = 0x042B;
const ASSAMESE: u16 = 0x044D;
const AZERI_LATIN: u16 = 0x042C;
const AZERI_CYRILLIC: u16 = 0x082C;
const BASQUE: u16 = 0x042D;
const BELARUSSIAN: u16 = 0x0423;
const BENGALI: u16 = 0x0445;
const BULGARIAN: u16 = 0x0402;
const BURMESE: u16 = 0x0455;
const CATALAN: u16 = 0x0403;
const CHINESE_TAIWAN: u16 = 0x0404;
const CHINESE_CHINA: u16 = 0x0804;
const CHINESE_HONG_KONG: u16 = 0x0C04;
const CHINESE_SINGAPORE: u16 = 0x1004;
const CHINESE_MACAU: u16 = 0x1404;
const CROATIAN: u16 = 0x041A;
const CZECH: u16 = 0x0405;
const DANISH: u16 = 0x0406;
const DUTCH_NETHERLANDS: u16 = 0x0413;
const DUTCH_BELGIUM: u16 = 0x0813;
const ENGLISH_UNITED_STATES: u16 = 0x0409;
const ENGLISH_UNITED_KINGDOM: u16 = 0x0809;
const ENGLISH_AUSTRALIAN: u16 = 0x0C09;
const ENGLISH_CANADIAN: u16 = 0x1009;
const ENGLISH_NEW_ZEALAND: u16 = 0x1409;
const ENGLISH_IRELAND: u16 = 0x1809;
const ENGLISH_SOUTH_AFRICA: u16 = 0x1C09;
const ENGLISH_JAMAICA: u16 = 0x2009;
const ENGLISH_CARIBBEAN: u16 = 0x2409;
const ENGLISH_BELIZE: u16 = 0x2809;
const ENGLISH_TRINIDAD: u16 = 0x2C09;
const ENGLISH_ZIMBABWE: u16 = 0x3009;
const ENGLISH_PHILIPPINES: u16 = 0x3409;
const ESTONIAN: u16 = 0x0425;
const FAEROESE: u16 = 0x0438;
const FARSI: u16 = 0x0429;
const FINNISH: u16 = 0x040B;
const FRENCH_STANDARD: u16 = 0x040C;
const FRENCH_BELGIAN: u16 = 0x080C;
const FRENCH_CANADIAN: u16 = 0x0C0C;
const FRENCH_SWITZERLAND: u16 = 0x100C;
const FRENCH_LUXEMBOURG: u16 = 0x140C;
const FRENCH_MONACO: u16 = 0x180C;
const GEORGIAN: u16 = 0x0437;
const GERMAN_STANDARD: u16 = 0x0407;
const GERMAN_SWITZERLAND: u16 = 0x0807;
const GERMAN_AUSTRIA: u16 = 0x0C07;
const GERMAN_LUXEMBOURG: u16 = 0x1007;
const GERMAN_LIECHTENSTEIN: u16 = 0x1407;
const GREEK: u16 = 0x0408;
const GUJARATI: u16 = 0x0447;
const HEBREW: u16 = 0x040D;
const HINDI: u16 = 0x0439;
const HUNGARIAN: u16 = 0x040E;
const ICELANDIC: u16 = 0x040F;
const INDONESIAN: u16 = 0x0421;
const ITALIAN_STANDARD: u16 = 0x0410;
const ITALIAN_SWITZERLAND: u16 = 0x0810;
const JAPANESE: u16 = 0x0411;
const KANNADA: u16 = 0x044B;
const KASHMIRI_INDIA: u16 = 0x0860;
const KAZAKH: u16 = 0x043F;
const KONKANI: u16 = 0x0457;
const KOREAN: u16 = 0x0412;
const KOREAN_JOHAB: u16 = 0x0812;
const LATVIAN: u16 = 0x0426;
const LITHUANIAN: u16 = 0x0427;
const LITHUANIAN_CLASSIC: u16 = 0x0827;
const MACEDONIAN: u16 = 0x042F;
const MALAY_MALAYSIAN: u16 = 0x043E;
const MALAY_BRUNEI_DARUSSALAM: u16 = 0x083E;
const MALAYALAM: u16 = 0x044C;
const MANIPURI: u16 = 0x0458;
const MARATHI: u16 = 0x044E;
const NEPALI_INDIA: u16 = 0x0861;
const NORWEGIAN_BOKMAL: u16 = 0x0414;
const NORWEGIAN_NYNORSK: u16 = 0x0814;
const ORIYA: u16 = 0x0448;
const POLISH: u16 = 0x0415;
const PORTUGUESE_BRAZIL: u16 = 0x0416;
const PORTUGUESE_STANDARD: u16 = 0x0816;
const PUNJABI: u16 = 0x0446;
const ROMANIAN: u16 = 0x0418;
const RUSSIAN: u16 = 0x0419;
const SANSKRIT: u16 = 0x044F;
const SERBIAN_CYRILLIC: u16 = 0x0C1A;
const SERBIAN_LATIN: u16 = 0x081A;
const SINDHI: u16 = 0x0459;
const SLOVAK: u16 = 0x041B;
const SLOVENIAN: u16 = 0x0424;
const SPANISH_TRADITIONAL_SORT: u16 = 0x040A;
const SPANISH_MEXICAN: u16 = 0x080A;
const SPANISH_MODERN_SORT: u16 = 0x0C0A;
const SPANISH_GUATEMALA: u16 = 0x100A;
const SPANISH_COSTA_RICA: u16 = 0x140A;
const SPANISH_PANAMA: u16 = 0x180A;
const SPANISH_DOMINICAN_REPUBLIC: u16 = 0x1C0A;
const SPANISH_VENEZUELA: u16 = 0x200A;
const SPANISH_COLOMBIA: u16 = 0x240A;
const SPANISH_PERU: u16 = 0x280A;
const SPANISH_ARGENTINA: u16 = 0x2C0A;
const SPANISH_ECUADOR: u16 = 0x300A;
const SPANISH_CHILE: u16 = 0x340A;
const SPANISH_URUGUAY: u16 = 0x380A;
const SPANISH_PARAGUAY: u16 = 0x3C0A;
const SPANISH_BOLIVIA: u16 = 0x400A;
const SPANISH_EL_SALVADOR: u16 = 0x440A;
const SPANISH_HONDURAS: u16 = 0x480A;
const SPANISH_NICARAGUA: u16 = 0x4C0A;
const SPANISH_PUERTO_RICO: u16 = 0x500A;
const SUTU: u16 = 0x0430;
const SWAHILI_KENYA: u16 = 0x0441;
const SWEDISH: u16 = 0x041D;
const SWEDISH_FINLAND: u16 = 0x081D;
const TAMIL: u16 = 0x0449;
const TATAR_TATARSTAN: u16 = 0x0444;
const TELUGU: u16 = 0x044A;
const THAI: u16 = 0x041E;
const TURKISH: u16 = 0x041F;
const UKRAINIAN: u16 = 0x0422;
const URDU_PAKISTAN: u16 = 0x0420;
const URDU_INDIA: u16 = 0x0820;
const UZBEK_LATIN: u16 = 0x0443;
const UZBEK_CYRILLIC: u16 = 0x0843;
const VIETNAMESE: u16 = 0x042A;
const HID_USAGE_DATA_DESCRIPTOR: u16 = 0x04FF;
const HID_VENDOR_DEFINED_1: u16 = 0xF0FF;
const HID_VENDOR_DEFINED_2: u16 = 0xF4FF;
const HID_VENDOR_DEFINED_3: u16 = 0xF8FF;
const HID_VENDOR_DEFINED_4: u16 = 0xFCFF;
#[test]
fn it_recognizes_afrikaans_as_afrikaans_language() {
assert_eq!(
super::from_lang_id(AFRIKAANS).primary_language(),
PrimaryLanguage::Afrikaans
);
}
#[test]
fn it_recognizes_albanian_as_albanian_language() {
assert_eq!(
super::from_lang_id(ALBANIAN).primary_language(),
PrimaryLanguage::Albanian
);
}
#[test]
fn it_recognizes_arabic_from_saudi_arabia_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_SAUDI_ARABIA).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_saudi_arabia_as_saudi_arabia_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_SAUDI_ARABIA).sub_language(),
SubLanguage::SaudiArabia
);
}
#[test]
fn it_recognizes_arabic_from_iraq_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_IRAQ).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_iraq_as_iraq_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_IRAQ).sub_language(),
SubLanguage::Iraq
);
}
#[test]
fn it_recognizes_arabic_from_egypt_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_EGYPT).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_egypt_as_egypt_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_EGYPT).sub_language(),
SubLanguage::Egypt
);
}
#[test]
fn it_recognizes_arabic_from_libya_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_LIBYA).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_libya_as_libya_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_LIBYA).sub_language(),
SubLanguage::Libya
);
}
#[test]
fn it_recognizes_arabic_from_algeria_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_ALGERIA).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_algeria_as_algeria_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_ALGERIA).sub_language(),
SubLanguage::Algeria
);
}
#[test]
fn it_recognizes_arabic_from_morocco_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_MOROCCO).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_morocco_as_morocco_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_MOROCCO).sub_language(),
SubLanguage::Morocco
);
}
#[test]
fn it_recognizes_arabic_from_tunisia_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_TUNISIA).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_tunisia_as_tunisia_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_TUNISIA).sub_language(),
SubLanguage::Tunisia
);
}
#[test]
fn it_recognizes_arabic_from_oman_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_OMAN).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_oman_as_oman_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_OMAN).sub_language(),
SubLanguage::Oman
);
}
#[test]
fn it_recognizes_arabic_from_yemen_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_YEMEN).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_yemen_as_yemen_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_YEMEN).sub_language(),
SubLanguage::Yemen
);
}
#[test]
fn it_recognizes_arabic_from_syria_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_SYRIA).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_syria_as_syria_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_SYRIA).sub_language(),
SubLanguage::Syria
);
}
#[test]
fn it_recognizes_arabic_from_jordan_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_JORDAN).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_jordan_as_jordan_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_JORDAN).sub_language(),
SubLanguage::Jordan
);
}
#[test]
fn it_recognizes_arabic_from_lebanon_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_LEBANON).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_lebanon_as_lebanon_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_LEBANON).sub_language(),
SubLanguage::Lebanon
);
}
#[test]
fn it_recognizes_arabic_from_kuwait_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_KUWAIT).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_kuwait_as_kuwait_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_KUWAIT).sub_language(),
SubLanguage::Kuwait
);
}
#[test]
fn it_recognizes_arabic_from_uae_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_UAE).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_uae_as_uae_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_UAE).sub_language(),
SubLanguage::UnitedArabEmirates
);
}
#[test]
fn it_recognizes_arabic_from_bahrain_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_BAHRAIN).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_bahrain_as_bahrain_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_BAHRAIN).sub_language(),
SubLanguage::Bahrain
);
}
#[test]
fn it_recognizes_arabic_from_qatar_as_arabic_language() {
assert_eq!(
super::from_lang_id(ARABIC_QATAR).primary_language(),
PrimaryLanguage::Arabic
);
}
#[test]
fn it_recognizes_arabic_from_qatar_as_qatar_sub_language() {
assert_eq!(
super::from_lang_id(ARABIC_QATAR).sub_language(),
SubLanguage::Qatar
);
}
#[test]
fn it_recognizes_armenian_as_armenian_language() {
assert_eq!(
super::from_lang_id(ARMENIAN).primary_language(),
PrimaryLanguage::Armenian
);
}
#[test]
fn it_recognizes_assamese_as_assamese_language() {
assert_eq!(
super::from_lang_id(ASSAMESE).primary_language(),
PrimaryLanguage::Assamese
);
}
#[test]
fn it_recognizes_azeri_latin_as_azeri_language() {
assert_eq!(
super::from_lang_id(AZERI_LATIN).primary_language(),
PrimaryLanguage::Azeri
);
}
#[test]
fn it_recognizes_azeri_latin_as_latin_sub_language() {
assert_eq!(
super::from_lang_id(AZERI_LATIN).sub_language(),
SubLanguage::Latin
);
}
#[test]
fn it_recognizes_azeri_cyrillic_as_azeri_language() {
assert_eq!(
super::from_lang_id(AZERI_CYRILLIC).primary_language(),
PrimaryLanguage::Azeri
);
}
#[test]
fn it_recognizes_azeri_cyrillic_as_cyrillic_sub_language() {
assert_eq!(
super::from_lang_id(AZERI_CYRILLIC).sub_language(),
SubLanguage::Cyrillic
);
}
#[test]
fn it_recognizes_basque_as_basque_language() {
assert_eq!(
super::from_lang_id(BASQUE).primary_language(),
PrimaryLanguage::Basque
);
}
#[test]
fn it_recognizes_belarussian_as_belarussian_language() {
assert_eq!(
super::from_lang_id(BELARUSSIAN).primary_language(),
PrimaryLanguage::Belarussian
);
}
#[test]
fn it_recognizes_bengali_as_bengali_language() {
assert_eq!(
super::from_lang_id(BENGALI).primary_language(),
PrimaryLanguage::Bengali
);
}
#[test]
fn it_recognizes_bulgarian_as_bulgarian_language() {
assert_eq!(
super::from_lang_id(BULGARIAN).primary_language(),
PrimaryLanguage::Bulgarian
);
}
#[test]
fn it_recognizes_burmese_as_burmese_language() {
assert_eq!(
super::from_lang_id(BURMESE).primary_language(),
PrimaryLanguage::Burmese
);
}
#[test]
fn it_recognizes_catalan_as_catalan_language() {
assert_eq!(
super::from_lang_id(CATALAN).primary_language(),
PrimaryLanguage::Catalan
);
}
#[test]
fn it_recognizes_chinese_from_taiwan_as_chinese_language() {
assert_eq!(
super::from_lang_id(CHINESE_TAIWAN).primary_language(),
PrimaryLanguage::Chinese
);
}
#[test]
fn it_recognizes_chinese_from_taiwan_as_taiwan_sub_language() {