1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 15:02:59 +00:00
fftcgtool/fftcg/language.py

49 lines
1.2 KiB
Python
Raw Normal View History

from __future__ import annotations
from dataclasses import dataclass, InitVar, field
@dataclass(frozen=True)
2021-08-23 16:16:56 +00:00
class Language:
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
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
object.__setattr__(self, "short", "en")
2021-08-23 16:16:56 +00:00
@property
def image_suffix(self):
# supported languages for face URLs
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
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"
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"]
])