Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Constants for the Google Translate text-to-speech integration."""
2 
3 from dataclasses import dataclass
4 
5 CONF_TLD = "tld"
6 DEFAULT_LANG = "en"
7 DEFAULT_TLD = "com"
8 DOMAIN = "google_translate"
9 
10 # INSTRUCTIONS TO UPDATE LIST:
11 #
12 # Removal:
13 # Removal is as simple as deleting the line containing the language code no longer
14 # supported.
15 #
16 # Addition:
17 # In order to add to this list, follow the below steps:
18 # 1. Find out if the language is supported: Go to Google Translate website and try
19 # translating any word from English into your desired language.
20 # If the "speech" icon is grayed out or no speech is generated, the language is
21 # not supported and cannot be added. Otherwise, proceed:
22 # 2. Grab the language code from https://cloud.google.com/translate/docs/languages
23 # 3. Add the language code in SUPPORT_LANGUAGES, making sure to not disturb the
24 # alphabetical nature of the list.
25 
26 SUPPORT_LANGUAGES = [
27  "af",
28  "am",
29  "ar",
30  "bg",
31  "bn",
32  "bs",
33  "ca",
34  "cs",
35  "cy",
36  "da",
37  "de",
38  "el",
39  "en",
40  "es",
41  "et",
42  "eu",
43  "fi",
44  "fil",
45  "fr",
46  "gl",
47  "gu",
48  "ha",
49  "hi",
50  "hr",
51  "hu",
52  "id",
53  "is",
54  "it",
55  "iw",
56  "ja",
57  "jw",
58  "km",
59  "kn",
60  "ko",
61  "la",
62  "lt",
63  "lv",
64  "ml",
65  "mr",
66  "ms",
67  "my",
68  "ne",
69  "nl",
70  "no",
71  "pa",
72  "pl",
73  "pt",
74  "ro",
75  "ru",
76  "si",
77  "sk",
78  "sq",
79  "sr",
80  "su",
81  "sv",
82  "sw",
83  "ta",
84  "te", # codespell:ignore te
85  "th",
86  "tl",
87  "tr",
88  "uk",
89  "ur",
90  "vi",
91  # dialects
92  "zh-CN",
93  "zh-cn",
94  "zh-tw",
95  "en-us",
96  "en-ca",
97  "en-uk",
98  "en-gb",
99  "en-au",
100  "en-gh",
101  "en-in",
102  "en-ie",
103  "en-nz",
104  "en-ng",
105  "en-ph",
106  "en-za",
107  "en-tz",
108  "fr-ca",
109  "fr-fr",
110  "pt-br",
111  "pt-pt",
112  "es-es",
113  "es-us",
114 ]
115 
116 SUPPORT_TLD = [
117  "com",
118  "ad",
119  "ae",
120  "com.af",
121  "com.ag",
122  "com.ai",
123  "al",
124  "am",
125  "co.ao",
126  "com.ar",
127  "as",
128  "at",
129  "com.au",
130  "az",
131  "ba",
132  "com.bd",
133  "be",
134  "bf",
135  "bg",
136  "com.bh",
137  "bi",
138  "bj",
139  "com.bn",
140  "com.bo",
141  "com.br",
142  "bs",
143  "bt",
144  "co.bw",
145  "by",
146  "com.bz",
147  "ca",
148  "cd",
149  "cf",
150  "cg",
151  "ch",
152  "ci",
153  "co.ck",
154  "cl",
155  "cm",
156  "cn",
157  "com.co",
158  "co.cr",
159  "com.cu",
160  "cv",
161  "com.cy",
162  "cz",
163  "de",
164  "dj",
165  "dk",
166  "dm",
167  "com.do",
168  "dz",
169  "com.ec",
170  "ee",
171  "com.eg",
172  "es",
173  "com.et",
174  "fi",
175  "com.fj",
176  "fm",
177  "fr",
178  "ga",
179  "ge",
180  "gg",
181  "com.gh",
182  "com.gi",
183  "gl",
184  "gm",
185  "gr",
186  "com.gt",
187  "gy",
188  "com.hk",
189  "hn",
190  "hr",
191  "ht",
192  "hu",
193  "co.id",
194  "ie",
195  "co.il",
196  "im",
197  "co.in",
198  "iq",
199  "is",
200  "it",
201  "je",
202  "com.jm",
203  "jo",
204  "co.jp",
205  "co.ke",
206  "com.kh",
207  "ki",
208  "kg",
209  "co.kr",
210  "com.kw",
211  "kz",
212  "la",
213  "com.lb",
214  "li",
215  "lk",
216  "co.ls",
217  "lt",
218  "lu",
219  "lv",
220  "com.ly",
221  "co.ma",
222  "md",
223  "me",
224  "mg",
225  "mk",
226  "ml",
227  "com.mm",
228  "mn",
229  "ms",
230  "com.mt",
231  "mu",
232  "mv",
233  "mw",
234  "com.mx",
235  "com.my",
236  "co.mz",
237  "com.na",
238  "com.ng",
239  "com.ni",
240  "ne",
241  "nl",
242  "no",
243  "com.np",
244  "nr",
245  "nu",
246  "co.nz",
247  "com.om",
248  "com.pa",
249  "com.pe",
250  "com.pg",
251  "com.ph",
252  "com.pk",
253  "pl",
254  "pn",
255  "com.pr",
256  "ps",
257  "pt",
258  "com.py",
259  "com.qa",
260  "ro",
261  "ru",
262  "rw",
263  "com.sa",
264  "com.sb",
265  "sc",
266  "se",
267  "com.sg",
268  "sh",
269  "si",
270  "sk",
271  "com.sl",
272  "sn",
273  "so",
274  "sm",
275  "sr",
276  "st",
277  "com.sv",
278  "td",
279  "tg",
280  "co.th",
281  "com.tj",
282  "tl",
283  "tm",
284  "tn",
285  "to",
286  "com.tr",
287  "tt",
288  "com.tw",
289  "co.tz",
290  "com.ua",
291  "co.ug",
292  "co.uk",
293  "com.uy",
294  "co.uz",
295  "com.vc",
296  "co.ve",
297  "vg",
298  "co.vi",
299  "com.vn",
300  "vu",
301  "ws",
302  "rs",
303  "co.za",
304  "co.zm",
305  "co.zw",
306  "cat",
307 ]
308 
309 
310 @dataclass
311 class Dialect:
312  """Language and TLD for a dialect supported by Google Translate."""
313 
314  lang: str
315  tld: str
316 
317 
318 MAP_LANG_TLD: dict[str, Dialect] = {
319  "en-us": Dialect("en", "com"),
320  "en-gb": Dialect("en", "co.uk"),
321  "en-uk": Dialect("en", "co.uk"),
322  "en-au": Dialect("en", "com.au"),
323  "en-ca": Dialect("en", "ca"),
324  "en-in": Dialect("en", "co.in"),
325  "en-ie": Dialect("en", "ie"),
326  "en-za": Dialect("en", "co.za"),
327  "fr-ca": Dialect("fr", "ca"),
328  "fr-fr": Dialect("fr", "fr"),
329  "pt-br": Dialect("pt", "com.br"),
330  "pt-pt": Dialect("pt", "pt"),
331  "es-es": Dialect("es", "es"),
332  "es-us": Dialect("es", "com"),
333 }