blob: 83652c8d5fb582c8399a9f72542cfeeeca7db309 (
plain)
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
|
string get_abbreviation (string name) {
string abbreviation = null;
if (name != null) {
char letters[2];
var index = 0;
for (var i = 0; i < name.length && index < 2; i++) {
if (name[i].isupper ()) {
letters[index++] = name[i];
}
}
if (index < 2) {
index = 0;
for (var i = 0; i < name.length && index < 2; i++) {
if (name[i].isalpha () && (i == 0 || !name[i - 1].isalpha ())) {
letters[index++] = name[i++].toupper ();
}
}
if (index < 2) {
index = 0;
for (var i = 0; i < name.length && index < 2; i++) {
if (name[i].isalpha ()) {
letters[index++] = name[i];
}
}
}
}
if (index == 2) {
abbreviation = @"$(letters[0])$(letters[1])";
} else if (index == 1) {
abbreviation = @"$(letters[0])";
}
}
return abbreviation;
}
string? get_display_name (string? layout) {
if (layout == null) {
return null;
}
var language = Xkl.get_language_name (layout);
var country = Xkl.get_country_name (layout);
if (language != null && country != null) {
return @"$language ($country)";
} else if (language != null) {
return language;
} else if (country != null) {
return country;
} else {
return null;
}
}
|