-
Notifications
You must be signed in to change notification settings - Fork 23
/
uLanguages.pas
63 lines (47 loc) · 1.14 KB
/
uLanguages.pas
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
unit uLanguages;
{$MODE objfpc}
// Wikipedia: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
interface
type
TIso6391Code = String[2]; // ISO 639-1 Code
TIso6393Code = String[3]; // ISO 639-3 Code
TLcid = Cardinal; // Windows Language Code Identifier
function Iso6391FromLcid(ALcid: TLcid): TIso6391Code;
function Iso6393FromLcid(ALcid: TLcid): TIso6393Code;
implementation
uses SysUtils;
type
TLangCodesRecord = record
Iso6391Code: TIso6391Code;
Iso6393Code: TIso6393Code;
Lcid: TLcid;
end;
{$I languagecodes.inc}
function FindByLcid(ALcid: TLcid): TLangCodesRecord;
var
LangInfo: TLangCodesRecord;
begin
for LangInfo in CodesArr do
begin
if LangInfo.Lcid = ALcid then
Exit(LangInfo);
end;
raise Exception.Create('LCID not found');
end;
function Iso6391FromLcid(ALcid: TLcid): TIso6391Code;
begin
Result := '';
try
Result := FindByLcid(ALcid).Iso6391Code;
except
end;
end;
function Iso6393FromLcid(ALcid: TLcid): TIso6393Code;
begin
Result := '';
try
Result := FindByLcid(ALcid).Iso6393Code;
except
end;
end;
end.