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.


Purpose: Facilitates dynamic language localization in applications, allowing easy management and retrieval of translations based on user or application settings.


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:

SD.Locale.LoadLocale('en')  -- Attempts to load 'locales/en.json'


Purpose: Retrieves a localized string based on a specified key, with optional replacements for dynamic content.


  • 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.


  • (string): The localized string with placeholders replaced by the corresponding values in replacements, or the key itself if no translation is found.

Usage Example:

local greeting = SD.Locale.T('greeting.hello', {name = 'John'})
print(greeting)  -- Output could be "Hello, John!" if the JSON contains appropriate data

Last updated