@@ -356,19 +356,6 @@ def _get_display_name(self, code: list, typename: str, style: tuple):
356356 return names [0 ] if isinstance (code , str ) else names
357357
358358 def _get_options (self , displaytype :str , typename : str , style = STYLE_DIALECT_LONG , translatable_only : bool = True ) -> dict :
359- """Return the options available for the given type.
360-
361- Args:
362- displaytype: The type ("language", "region", "currency") to translate the
363- options to.
364- typename: The type of entry in the database to load.
365- style: Style constant. Can be one of the following:
366- STYLE_DIALECT_LONG, STYLE_DIALECT_SHORT, STYLE_DIALECT_NARROW,
367- STYLE_STANDARD_LONG, STYLE_STANDARD_SHORT, STYLE_STANDARD_NARROW.
368- translatable_only: If True, only the entries that the user's browser was
369- able to translate will be returned. If False, untranslatable entries
370- will show up in English.
371- """
372359 registry = LocalSubtagRegistry (True ).get_tags (typename )
373360 tags = list (registry .keys ()) if isinstance (registry , dict ) else registry
374361 transl = self ._get_display_name (tags , displaytype , style )
@@ -467,7 +454,22 @@ def get_language_options(self, style = STYLE_DIALECT_LONG, translatable_only: bo
467454 return self ._get_options ("language" , "language" , style , translatable_only )
468455
469456 def get_script_options (self , style = STYLE_DIALECT_LONG , translatable_only : bool = False ) -> dict :
470- """Return all known script subtags and their translations as dictionary.
457+ """Return the translated name of the given script(s).
458+
459+ The name of the given script code is returned in the language fluent has
460+ been configured for.
461+
462+ Args:
463+ code: The script code (e.g. "Arab", "Latn", etc.) or list of
464+ script codes to get the translated name for.
465+ style: Style constant. Can be one of the following:
466+ STYLE_DIALECT_LONG, STYLE_DIALECT_SHORT, STYLE_DIALECT_NARROW,
467+ STYLE_STANDARD_LONG, STYLE_STANDARD_SHORT, STYLE_STANDARD_NARROW.
468+ """
469+ return self ._get_options ("script" , "script" , style , translatable_only )
470+
471+ def get_locale_options (self , style = STYLE_DIALECT_LONG , translatable_only : bool = False ) -> dict :
472+ """Return common locales from CLDR and their translations as dictionary.
471473
472474 style: Style constant to determine the style of the translation. Can be one of
473475 the following: STYLE_DIALECT_LONG, STYLE_DIALECT_SHORT,
@@ -477,10 +479,10 @@ def get_script_options(self, style = STYLE_DIALECT_LONG, translatable_only: bool
477479 able to translate will be returned. If False, untranslatable entries
478480 will show up in English.
479481 """
480- return self ._get_options ("script " , "script " , style , translatable_only )
482+ return self ._get_options ("language " , "locale " , style , translatable_only )
481483
482- def get_locale_options (self , style = STYLE_DIALECT_LONG , translatable_only : bool = False ) -> dict :
483- """Return common locales from CLDR and their translations as dictionary.
484+ def get_currency_options (self , style = STYLE_DIALECT_LONG , translatable_only : bool = False ) -> dict :
485+ """Return common currencies from CLDR and their translations as dictionary.
484486
485487 style: Style constant to determine the style of the translation. Can be one of
486488 the following: STYLE_DIALECT_LONG, STYLE_DIALECT_SHORT,
@@ -490,6 +492,10 @@ def get_locale_options(self, style = STYLE_DIALECT_LONG, translatable_only: bool
490492 able to translate will be returned. If False, untranslatable entries
491493 will show up in English.
492494 """
493- return self ._get_options ("language" , "locale" , style , translatable_only )
495+ return self ._get_options ("currency" , "currency" , style , translatable_only )
496+
497+
498+
499+
494500
495501fluent = __Fluent (None , "localization/{locale}/main.ftl" )
0 commit comments