I18n
Parameters
dict[str, dict[str, str]]
Each keyword argument should be a locale code (e.g., “en”, “fr”) with a dictionary value, which maps translation keys to translated strings.
Methods
call
str
required
The key to identify the translation string (e.g., “submit_button”).
I18nData
A I18nData object containing the translation key.
Properties
dict[str, dict[str, str]]
Returns the dictionary of translations provided during initialization. These can be passed to the frontend for use in its translation system.
Example
I18nData
Constructor
str
required
The translation key to be translated in the frontend.
Methods
to_dict
dict[str, Any]
A dictionary representation of the I18nData object.
Properties
str
The translation key.
Usage Notes
- Locale codes should follow BCP 47 format (e.g., ‘en’, ‘en-US’, ‘fr’, ‘es’)
- Translation lookup happens on the frontend based on the browser’s locale and the provided translation dictionaries
- You can use I18nData objects anywhere you would use a string in Gradio components
- The actual translation is performed in the frontend, allowing for dynamic language switching based on user preferences