Locale¶
locale
¶
Locale and internationalization support for imdbinfo.
This module provides functions to configure language locales for IMDb API requests. The library supports multiple locales for different regions and languages.
Supported Locales
"en"— English (default)"fr-ca"— French (Canada)"fr"— French"hi"— Hindi"de"— German"it"— Italian"es"— Spanish"pt"— Portuguese"es-es"— Spanish (Spain)
Examples:
>>> from imdbinfo import set_locale, get_movie
>>> set_locale("it") # Set global locale to Italian
>>> movie = get_movie("tt0133093") # All requests now use Italian
Override locale per-request:
>>> from imdbinfo import get_movie
>>> movie = get_movie("tt0133093", locale="it") # Italian for this call only
SUPPORTED_LOCALES = ('en', 'fr-ca', 'fr', 'hi', 'de', 'it', 'es', 'pt', 'es-es')
module-attribute
¶
DEFAULT_LOCALE = 'en'
module-attribute
¶
set_locale(locale: str)
¶
Set the global locale for all IMDb API requests.
Once set, all subsequent calls to imdbinfo functions will use the configured
locale unless overridden with a per-call locale parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locale
|
str
|
Locale code. Must be one of: |
required |
Warnings
If an invalid locale is provided or the locale type is not a string,
a warning is logged and the default locale ("en") is used.
Examples:
get_locale()
¶
Get the currently configured global locale.
Returns:
| Type | Description |
|---|---|
str
|
The currently configured locale code. Returns empty string for English
( |
Examples: