forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguages.py
77 lines (69 loc) · 2.01 KB
/
languages.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
72
73
74
75
76
77
"""Helper script to update language list from the frontend source."""
import json
from pathlib import Path
import sys
import requests
from .hassfest.serializer import format_python_namespace
tag = sys.argv[1] if len(sys.argv) > 1 else "dev"
req = requests.get(
f"https://raw.githubusercontent.com/home-assistant/frontend/{tag}/src/translations/translationMetadata.json"
)
data = json.loads(req.content)
languages = set(data.keys())
# Languages which can be used for entity IDs.
# Languages in the set are those which use a writing system based on the Latin
# script. Languages not in this set will instead base the entity ID on English.
# Note: Although vietnamese writing is based on the Latin script, it's too ambiguous
# after accents and diacritics have been removed by slugify
NATIVE_ENTITY_IDS = {
"af", # Afrikaans
"bs", # Bosanski
"ca", # Català
"cs", # Čeština
"cy", # Cymraeg
"da", # Dansk
"de", # Deutsch
"en", # English
"en-GB", # English (GB)
"eo", # Esperanto
"es", # Español
"es-419", # Español (Latin America)
"et", # Eesti
"eu", # Euskara
"fi", # Suomi
"fr", # Français
"fy", # Frysk
"gl", # Galego
"gsw", # Schwiizerdütsch
"hr", # Hrvatski
"hu", # Magyar
"id", # Indonesia
"is", # Íslenska
"it", # Italiano
"ka", # Kartuli
"lb", # Lëtzebuergesch
"lt", # Lietuvių
"lv", # Latviešu
"nb", # Nederlands
"nl", # Norsk Bokmål
"nn", # Norsk Nynorsk"
"pl", # Polski
"pt", # Português
"pt-BR", # Português (BR)
"ro", # Română
"sk", # Slovenčina
"sl", # Slovenščina
"sr-Latn", # Srpski
"sv", # Svenska
"tr", # Türkçe
}
Path("homeassistant/generated/languages.py").write_text(
format_python_namespace(
{
"DEFAULT_LANGUAGE": "en",
"LANGUAGES": languages,
"NATIVE_ENTITY_IDS": NATIVE_ENTITY_IDS,
},
generator="script.languages [frontend_tag]",
)
)