Returns the Locale for the given locale code. If it is not supported, we raise an exception.
(cls, code: str)
| 252 | |
| 253 | @classmethod |
| 254 | def get(cls, code: str) -> "Locale": |
| 255 | """Returns the Locale for the given locale code. |
| 256 | |
| 257 | If it is not supported, we raise an exception. |
| 258 | """ |
| 259 | if code not in cls._cache: |
| 260 | assert code in _supported_locales |
| 261 | translations = _translations.get(code, None) |
| 262 | if translations is None: |
| 263 | locale = CSVLocale(code, {}) # type: Locale |
| 264 | elif _use_gettext: |
| 265 | locale = GettextLocale(code, translations) |
| 266 | else: |
| 267 | locale = CSVLocale(code, translations) |
| 268 | cls._cache[code] = locale |
| 269 | return cls._cache[code] |
| 270 | |
| 271 | def __init__(self, code: str) -> None: |
| 272 | self.code = code |
no test coverage detected