-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
allLocales.py
71 lines (59 loc) · 1.35 KB
/
allLocales.py
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
import os
import re
keywords = [
# https://github.com/JetBrains/kotlin/blob/v1.4.10/core/descriptors/src/org/jetbrains/kotlin/renderer/KeywordStringsGenerated.java
"package",
"as",
"typealias",
"class",
"this",
"super",
"val",
"var",
"fun",
"for",
"null",
"true",
"false",
"is",
"in",
"throw",
"return",
"break",
"continue",
"object",
"if",
"try",
"else",
"while",
"do",
"when",
"interface",
"typeof"
]
locales = []
def methodName(locale):
x = locale.replace('-r', '').replace('-', '')
while x in keywords:
x += "99"
return x
print(' - "en-US"')
for filename in os.listdir("app/src/main/res"):
m = re.match("^values-([a-z]{2})-r([A-Z]{2})$", filename)
m2 = re.match("^values-([a-z]{2})$", filename)
if m:
print(' - "%s-%s"' % (m.group(1), m.group(2)))
if m or m2:
locales.append(filename.split("values-")[1])
for locale in locales:
print('''
@Test
@Config(qualifiers = "%s")
fun %s() {
readStringFromContext_LocalizedString()
}''' % (locale, methodName(locale)))
print(' <locale android:name="en" />')
for locale in locales:
if len(locale) == 6:
locale = locale.replace('-r', '-')
print(' <locale android:name="%s" />' % (locale, ))