2021-08-24 15:29:12 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2021-08-25 14:13:07 +00:00
|
|
|
from dataclasses import dataclass, InitVar, field
|
2021-08-24 15:29:12 +00:00
|
|
|
|
2021-08-25 14:13:07 +00:00
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
2021-08-23 16:16:56 +00:00
|
|
|
class Language:
|
2021-08-25 14:13:07 +00:00
|
|
|
short: str = field(init=False)
|
|
|
|
short_init: InitVar[str] = field(default="")
|
|
|
|
|
|
|
|
def __post_init__(self, short_init: str):
|
|
|
|
short_init = short_init.lower()
|
2021-08-23 16:16:56 +00:00
|
|
|
|
|
|
|
# supported languages
|
2021-08-25 14:13:07 +00:00
|
|
|
if short_init in ["de", "es", "fr", "ja", "it"]:
|
|
|
|
object.__setattr__(self, "short", short_init)
|
2021-08-23 16:16:56 +00:00
|
|
|
else:
|
|
|
|
# everything else is english
|
2021-08-25 14:13:07 +00:00
|
|
|
object.__setattr__(self, "short", "en")
|
2021-08-24 15:29:12 +00:00
|
|
|
|
2021-08-23 16:16:56 +00:00
|
|
|
@property
|
|
|
|
def image_suffix(self):
|
|
|
|
# supported languages for face URLs
|
2021-08-25 14:13:07 +00:00
|
|
|
if self.short in ["de", "es", "fr", "it"]:
|
|
|
|
return self.short
|
2021-08-23 16:16:56 +00:00
|
|
|
else:
|
|
|
|
return "eg"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def key_suffix(self):
|
|
|
|
# supported languages for Square API
|
2021-08-25 14:13:07 +00:00
|
|
|
if self.short in ["de", "es", "fr", "it"]:
|
|
|
|
return f"_{self.short.upper()}"
|
|
|
|
elif self.short == "ja":
|
2021-08-23 16:16:56 +00:00
|
|
|
return ""
|
|
|
|
else:
|
|
|
|
return "_EN"
|
2021-09-01 17:01:53 +00:00
|
|
|
|
2021-09-02 00:54:16 +00:00
|
|
|
|
|
|
|
API_LANGS = frozenset([
|
|
|
|
Language(short)
|
|
|
|
for short in ["de", "en", "es", "fr", "it", "ja"]
|
|
|
|
])
|
|
|
|
|
|
|
|
IMG_LANGS = frozenset([
|
|
|
|
Language(short)
|
|
|
|
for short in ["de", "en", "es", "fr", "it"]
|
|
|
|
])
|