babel の API リファレンス
babel (python-babel/babel) の公開 API 129 件 —— クラス 11、関数 45、メソッド 73。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: python-babel/babel
| 種別 | 件数 |
|---|---|
| クラス | 11 |
| 関数 | 45 |
| メソッド | 73 |
API 一覧
class
babel.core.LocaleRepresentation of a specific locale.
method
babel.core.Locale.character_order() -> strThe text direction for the language.
method
babel.core.Locale.currency_formats() -> localedata.LocaleDataDictLocale patterns for currency number formatting.
method
babel.core.Locale.currency_symbols() -> localedata.LocaleDataDictMapping of currency codes to symbols.
method
babel.core.Locale.date_formats() -> localedata.LocaleDataDictLocale patterns for date formatting.
method
babel.core.Locale.datetime_formats() -> localedata.LocaleDataDictLocale patterns for datetime formatting.
method
babel.core.Locale.datetime_skeletons() -> localedata.LocaleDataDictLocale patterns for formatting parts of a datetime.
method
babel.core.Locale.day_period_rules() -> localedata.LocaleDataDictDay period rules for the locale.
method
babel.core.Locale.days() -> localedata.LocaleDataDictLocale display names for weekdays.
method
babel.core.Locale.decimal_formats() -> localedata.LocaleDataDictLocale patterns for decimal number formatting.
method
babel.core.Locale.default_numbering_system() -> strThe default numbering system used by the locale.
method
babel.core.Locale.display_name() -> str | NoneThe localized display name of the locale.
method
babel.core.Locale.english_name() -> str | NoneThe english display name of the locale.
method
babel.core.Locale.eras() -> localedata.LocaleDataDictLocale display names for eras.
method
babel.core.Locale.first_week_day() -> intThe first day of a week, with 0 being Monday.
method
babel.core.Locale.get_display_name(locale:Locale | str | None=None) -> str | NoneReturn the display name of the locale using the given locale.
method
babel.core.Locale.get_language_name(locale:Locale | str | None=None) -> str | NoneReturn the language of this locale in the given locale.
method
babel.core.Locale.get_script_name(locale:Locale | str | None=None) -> str | NoneReturn the script name in the given locale.
method
babel.core.Locale.get_territory_name(locale:Locale | str | None=None) -> str | NoneReturn the territory name in the given locale.
method
babel.core.Locale.interval_formats() -> localedata.LocaleDataDictLocale patterns for interval formatting.
method
babel.core.Locale.language_name() -> str | NoneThe localized language name of the locale.
method
babel.core.Locale.languages() -> localedata.LocaleDataDictMapping of language codes to translated language names.
method
babel.core.Locale.list_patterns() -> localedata.LocaleDataDictPatterns for generating lists ..
method
babel.core.Locale.measurement_systems() -> localedata.LocaleDataDictLocalized names for various measurement systems.
method
babel.core.Locale.meta_zones() -> localedata.LocaleDataDictLocale display names for meta time zones.
method
babel.core.Locale.months() -> localedata.LocaleDataDictLocale display names for months.
method
babel.core.Locale.number_symbols() -> localedata.LocaleDataDictSymbols used in number formatting by number system.
method
babel.core.Locale.ordinal_form() -> PluralRulePlural rules for the locale.
method
babel.core.Locale.parse(identifier:Locale | str | None, sep:str='_', resolve_likely_subtags:bool=True) -> LocaleCreate a `Locale` instance for the given locale identifier.
method
babel.core.Locale.percent_formats() -> localedata.LocaleDataDictLocale patterns for percent number formatting.
method
babel.core.Locale.periods() -> localedata.LocaleDataDictLocale display names for day periods (AM/PM).
method
babel.core.Locale.plural_form() -> PluralRulePlural rules for the locale.
method
babel.core.Locale.quarters() -> localedata.LocaleDataDictLocale display names for quarters.
method
babel.core.Locale.scientific_formats() -> localedata.LocaleDataDictLocale patterns for scientific number formatting.
method
babel.core.Locale.script_name() -> str | NoneThe localized script name of the locale if available.
method
babel.core.Locale.scripts() -> localedata.LocaleDataDictMapping of script codes to translated script names.
method
babel.core.Locale.territories() -> localedata.LocaleDataDictMapping of script codes to translated script names.
method
babel.core.Locale.territory_name() -> str | NoneThe localized territory name of the locale if available.
method
babel.core.Locale.text_direction() -> strThe text direction for the language in CSS short-hand form.
method
babel.core.Locale.time_formats() -> localedata.LocaleDataDictLocale patterns for time formatting.
method
babel.core.Locale.time_zones() -> localedata.LocaleDataDictLocale display names for time zones.
method
babel.core.Locale.unit_display_names() -> localedata.LocaleDataDictDisplay names for units of measurement.
method
babel.core.Locale.variants() -> localedata.LocaleDataDictMapping of script codes to translated script names.
method
babel.core.Locale.weekend_end() -> intThe day the weekend ends, with 0 being Monday.
method
babel.core.Locale.weekend_start() -> intThe day the weekend starts, with 0 being Monday.
method
babel.core.Locale.zone_formats() -> localedata.LocaleDataDictPatterns related to the formatting of time zones.
func
babel.core.get_global(key:_GLOBAL_KEY) -> Mapping[str, Any]Return the dictionary for the given key in the global data.
method
babel.dates.DateTimeFormat.format_frac_seconds(num:int) -> strReturn fractional seconds.
method
babel.dates.DateTimeFormat.format_period(char:str, num:int) -> strReturn period from parsed datetime according to format pattern.
method
babel.dates.DateTimeFormat.format_weekday(char:str='E', num:int=4) -> strReturn weekday from parsed datetime according to format pattern.
method
babel.dates.DateTimeFormat.get_week_number(day_of_period:int, day_of_week:int | None=None) -> intReturn the number of the week of a day within a period.
method
babel.dates.DateTimeFormat.get_week_of_month() -> intReturn the week of the month.
method
babel.dates.DateTimeFormat.get_week_of_year() -> intReturn the week of the year.
func
babel.dates.format_date(date:datetime.date | None=None, format:_PredefinedTimeFormat | str='medium', locale:Locale | str | None=None) -> strReturn a date formatted according to the given pattern.
func
babel.dates.get_period_id(time:_Instant, tzinfo:datetime.tzinfo | None=None, type:Literal['selection'] | None=None, locale:Locale | str | None=None) -> strGet the day period ID for a given time.
func
babel.dates.get_timezone(zone:str | datetime.tzinfo | None=None) -> datetime.tzinfoLooks up a timezone by name and returns it.
func
babel.dates.parse_date(string:str, locale:Locale | str | None=None, format:_PredefinedTimeFormat | str='medium') -> datetime.dateParse a date from a string.
func
babel.dates.parse_pattern(pattern:str | DateTimePattern) -> DateTimePatternParse date, time, and datetime format patterns.
func
babel.dates.parse_time(string:str, locale:Locale | str | None=None, format:_PredefinedTimeFormat | str='medium') -> datetime.timeParse a time from a string.
func
babel.dates.split_interval_pattern(pattern:str) -> list[str]Split an interval-describing datetime pattern into multiple pieces.
func
babel.dates.tokenize_pattern(pattern:str) -> list[tuple[str, str | tuple[str, int]]]Tokenize date format patterns.
func
babel.dates.untokenize_pattern(tokens:Iterable[tuple[str, str | tuple[str, int]]]) -> strTurn a date format pattern token stream back into a string.
func
babel.languages.get_official_languages(territory:str, regional:bool=False, de_facto:bool=False) -> tuple[str, ...]Get the official language(s) for the given territory.
func
babel.lists.format_list(lst:Sequence[str], style:Literal['standard', 'standard-short', 'or', 'or-short', 'unit', 'unit-short', 'unit-narrow']='standard', locale:Locale | str | None=None) -> strFormat the items in `lst` as a list.
class
babel.localedata.AliasRepresentation of an alias in the locale data.
method
babel.localedata.Alias.resolve(data:Mapping[str | int | None, Any]) -> Mapping[str | int | None, Any]Resolve the alias based on the given data.
func
babel.localedata.clear_caches() -> NoneClear locale data caches.
func
babel.localedata.exists(name:str) -> boolCheck whether locale data is available for the given locale.
func
babel.localedata.load(name:os.PathLike[str] | str, merge_inherited:bool=True) -> dict[str, Any]Load the locale data for the given locale.
func
babel.localedata.normalize_locale(name:str) -> str | NoneNormalize a locale ID by stripping spaces and apply proper casing.
func
babel.localedata.resolve_locale_filename(name:os.PathLike[str] | str) -> strResolve a locale identifier to a `.dat` path on disk.
func
babel.localtime._win32.valuestodict(key) -> dict[str, Any]Convert a registry key's values to a dictionary.
func
babel.localtime.get_localzone() -> datetime.tzinfoReturns the current underlying local timezone object.
class
babel.messages.catalog.CatalogRepresentation of a message catalog.
method
babel.messages.catalog.Catalog.delete(id:_MessageID, context:str | None=None) -> NoneDelete the message with the specified ID and context.
method
babel.messages.catalog.Catalog.get(id:_MessageID, context:str | None=None) -> Message | NoneReturn the message with the specified ID and context.
method
babel.messages.catalog.Catalog.header_comment() -> strThe header comment for the catalog.
method
babel.messages.catalog.Catalog.num_plurals() -> intThe number of plurals used by the catalog or locale.
method
babel.messages.catalog.Catalog.plural_expr() -> strThe plural expression used by the catalog or locale.
method
babel.messages.catalog.Catalog.plural_forms() -> strReturn the plural forms declaration for the locale.
class
babel.messages.catalog.MessageRepresentation of a single message in a catalog.
method
babel.messages.catalog.Message.check(catalog:Catalog | None=None) -> list[TranslationError]Run various validation checks on the message.
method
babel.messages.catalog.Message.fuzzy() -> boolWhether the translation is fuzzy.
method
babel.messages.catalog.Message.pluralizable() -> boolWhether the message is plurizable.
method
babel.messages.catalog.Message.python_format() -> boolWhether the message contains Python-style parameters.
func
babel.messages.checkers.num_plurals(catalog:Catalog | None, message:Message) -> NoneVerify the number of plurals in the translation.
func
babel.messages.checkers.python_format(catalog:Catalog | None, message:Message) -> NoneVerify the format string placeholders in the translation.
class
babel.messages.frontend.CommandLineInterfaceCommand-line interface.
class
babel.messages.frontend.ConfigurationErrorRaised for errors in configuration files.
func
babel.messages.frontend.listify_value(arg, split=None)Make a list out of an argument.
func
babel.messages.jslexer.tokenize(source:str, jsx:bool=True, dotted:bool=True, template_string:bool=True, lineno:int=1) -> Generator[Token, None, None]Tokenize JavaScript/JSX source.
func
babel.messages.jslexer.unquote_string(string:str) -> strUnquote a string with JavaScript rules.
func
babel.messages.pofile.denormalize(string:str) -> strReverse the normalization done by the `normalize` function.
func
babel.messages.pofile.normalize(string:str, prefix:str='', width:int=76) -> strConvert a string into a format that is appropriate for .po files.
func
babel.messages.pofile.unescape(string:str) -> strReverse `escape` the given string.
class
babel.numbers.NumberFormatErrorException raised when a string cannot be parsed into a number.
func
babel.numbers.format_number(number:float | decimal.Decimal | str, locale:Locale | str | None=None) -> strReturn the given number formatted for a specific locale.
func
babel.numbers.get_currency_precision(currency:str) -> intReturn currency's precision.
func
babel.numbers.get_decimal_precision(number:decimal.Decimal) -> intReturn maximum precision of a decimal instance's fractional part.
func
babel.numbers.get_decimal_quantum(precision:int | decimal.Decimal) -> decimal.DecimalReturn minimal quantum of a number, as defined by precision.
func
babel.numbers.is_currency(currency:str, locale:Locale | str | None=None) -> boolReturns `True` only if a currency is recognized by Babel.
func
babel.numbers.list_currencies(locale:Locale | str | None=None) -> set[str]Return a `set` of normalized currency codes.
func
babel.numbers.normalize_currency(currency:str, locale:Locale | str | None=None) -> str | NoneReturns the normalized identifier of any currency code.
func
babel.numbers.parse_number(string:str, locale:Locale | str | None=None, *numbering_system:Literal['default'] | str='latn') -> intParse localized number string into an integer.
func
babel.numbers.parse_pattern(pattern:NumberPattern | str) -> NumberPatternParse number format patterns
func
babel.numbers.parse_precision(p)Calculate the min and max allowed digits
func
babel.numbers.validate_currency(currency:str, locale:Locale | str | None=None) -> NoneCheck the currency code is recognized by Babel.
class
babel.plural.PluralRuleRepresents a set of language pluralization rules.
method
babel.plural.PluralRule.parse(rules:Mapping[str, str] | Iterable[tuple[str, str]] | PluralRule) -> PluralRuleCreate a `PluralRule` instance for the given rules.
method
babel.plural.PluralRule.rules() -> Mapping[str, str]The `PluralRule` as a dict of unicode plural rules.
method
babel.plural.PluralRule.tags() -> frozenset[str]A set of explicitly defined tags in this rule.
class
babel.plural.RuleErrorRaised if a rule is malformed.
func
babel.plural.cldr_modulo(a:float, b:float) -> floatJavaish modulo.
func
babel.plural.in_range_list(num:float | decimal.Decimal, range_list:Iterable[Iterable[float | decimal.Decimal]]) -> boolInteger range list test.
func
babel.plural.to_gettext(rule:Mapping[str, str] | Iterable[tuple[str, str]] | PluralRule) -> strThe plural rule as gettext expression.
func
babel.plural.within_range_list(num:float | decimal.Decimal, range_list:Iterable[Iterable[float | decimal.Decimal]]) -> boolFloat range test.
method
babel.support.Format.currency(number:float | Decimal | str, currency:str) -> strReturn a number in the given currency formatted for the locale.
method
babel.support.Format.date(date:_datetime.date | None=None, format:_PredefinedTimeFormat | str='medium') -> strReturn a date formatted according to the given pattern.
method
babel.support.Format.decimal(number:float | Decimal | str, format:str | None=None) -> strReturn a decimal number formatted for the locale.
method
babel.support.Format.number(number:float | Decimal | str) -> strReturn an integer number formatted for the locale.
method
babel.support.Format.percent(number:float | Decimal | str, format:str | None=None) -> strReturn a number formatted as percentage for the locale.
method
babel.support.Format.scientific(number:float | Decimal | str) -> strReturn a number formatted using scientific notation for the locale.
class
babel.support.TranslationsAn extended translation catalog class.
method
babel.support.Translations.add(translations:Translations, merge:bool=True)Add the given translations to the catalog.
method
babel.support.Translations.merge(translations:Translations)Merge the given translations into the catalog.
class
babel.util.FixedOffsetTimezoneFixed offset in minutes east from UTC.
func
babel.util.distinct(iterable:Iterable[_T]) -> Generator[_T, None, None]Yield all items in an iterable collection that are distinct.
func
babel.util.parse_encoding(fp:IO[bytes]) -> str | NoneDeduce the encoding of a source file from magic comment.
func
babel.util.pathmatch(pattern:str, filename:str) -> boolExtended pathname pattern matching.
この情報について
掲載しているシグネチャは python-babel/babel の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。