MCPcopy Create free account
hub / github.com/EasyIME/PIME / CSVLocale

Class CSVLocale

python/python3/tornado/locale.py:479–512  ·  view source on GitHub ↗

Locale implementation using tornado's CSV translation format.

Source from the content-addressed store, hash-verified

477
478
479class CSVLocale(Locale):
480 """Locale implementation using tornado's CSV translation format."""
481
482 def __init__(self, code: str, translations: Dict[str, Dict[str, str]]) -> None:
483 self.translations = translations
484 super().__init__(code)
485
486 def translate(
487 self,
488 message: str,
489 plural_message: Optional[str] = None,
490 count: Optional[int] = None,
491 ) -> str:
492 if plural_message is not None:
493 assert count is not None
494 if count != 1:
495 message = plural_message
496 message_dict = self.translations.get("plural", {})
497 else:
498 message_dict = self.translations.get("singular", {})
499 else:
500 message_dict = self.translations.get("unknown", {})
501 return message_dict.get(message, message)
502
503 def pgettext(
504 self,
505 context: str,
506 message: str,
507 plural_message: Optional[str] = None,
508 count: Optional[int] = None,
509 ) -> str:
510 if self.translations:
511 gen_log.warning("pgettext is not supported by CSVLocale")
512 return self.translate(message, plural_message, count)
513
514
515class GettextLocale(Locale):

Callers 1

getMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected