Documentation ¶
Overview ¶
Package localization is responsible for localizing strings for different languages.
Exported function(s): Init, Localize, Localizers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(path string)
Init is a function that sets up the localization bundle and localizers for different languages.
It loads localization files from a specified path and creates localizers for each supported language. The supported languages are German, British English, American English, Spanish, French, Dutch, and Portuguese.
Parameter:
- path: A string representing the path to the directory containing the localization files. Each file should be named as "active.<language_code>.json".
Returns: None. This function initializes global variables within the package.
Note: This function should be called before using the Localize function to ensure that the localizers are properly set up.
func Localize ¶
Localize is a function that retrieves and returns a localized string based on the provided language and message ID.
Parameters:
- language: An integer representing the index of the language in the localizers array. The language should correspond to one of the supported languages (0: German, 1: British English, 2: American English, 3: Spanish, 4: French, 5: Dutch, 6: Portuguese).
- messageID: A string representing the ID of the message to be localized. This ID should correspond to a key in the localization files.
Returns:
- A string containing the localized message corresponding to the provided message ID and language. If the message ID does not exist in the localization files for the specified language, the function will return the message ID as is.
Note: The Init function should be called before using this function to ensure that the localizers are properly set up.
func Localizers ¶
Localizers is a function that provides access to the array of localizer objects used for string localization.
Parameters: None.
Returns:
- An array of pointers to i18n.Localizer objects. Each localizer corresponds to a supported language (0: German, 1: British English, 2: American English, 3: Spanish, 4: French, 5: Dutch, 6: Portuguese).
Note: The Init function should be called before using this function to ensure that the localizers are properly set up.
Types ¶
This section is empty.