Locale
The SD.Locale
module provides comprehensive localization support, enabling the loading and retrieval of translations from structured JSON files. It supports dynamic content replacement within translations, making it highly adaptable for various application needs.
Overview
Purpose: Facilitates dynamic language localization in applications, allowing easy management and retrieval of translations based on user or application settings.
Locale.LoadLocale
Purpose: Loads and processes a JSON file corresponding to the specified locale, converting it into an accessible format for the application. Parameters:
locale
(string
): The locale code that determines which JSON file to load, defaulting to 'en' if not specified.
Usage Example:
Locale.T
Purpose: Retrieves a localized string based on a specified key, with optional replacements for dynamic content.
Parameters:
key
(string
): The key corresponding to the localized string in the dictionary.replacements
(table
, optional): A table of key-value pairs where each key corresponds to a placeholder in the string, and the value is the content to replace it with.
Returns:
(
string
): The localized string with placeholders replaced by the corresponding values inreplacements
, or the key itself if no translation is found.
Usage Example:
Last updated