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

37 lines
1 KiB
Python

from __future__ import annotations
from dataclasses import dataclass, InitVar, field
@dataclass(frozen=True)
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()
# supported languages
if short_init in ["de", "es", "fr", "ja", "it"]:
object.__setattr__(self, "short", short_init)
else:
# everything else is english
object.__setattr__(self, "short", "en")
@property
def image_suffix(self):
# supported languages for face URLs
if self.short in ["de", "es", "fr", "it"]:
return self.short
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":
return ""
else:
return "_EN"