localization

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

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

func Localize(language int, messageID string) string

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

func Localizers() [7]*i18n.Localizer

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL