core/text/i18n

i18n

Types

4

Error

Error :: enum int { // General return values. None = 0, Empty_Translation_Catalog = 1, Duplicate_Key = 2, // Couldn't find, open or read file. File_Error = 3, // File too short. Premature_EOF = 4, // GNU Gettext *.MO file errors. MO_File_Invalid_Signature = 5, MO_File_Unsupported_Version = 6, MO_File_Invalid = 7, MO_File_Incorrect_Plural_Count = 8, // Qt Linguist *.TS file errors. TS_File_Parse_Error = 9, TS_File_Expected_Context = 10, TS_File_Expected_Context_Name = 11, TS_File_Expected_Source = 12, TS_File_Expected_Translation = 13, TS_File_Expected_NumerusForm = 14, Bad_Str = 15, Bad_Id = 16, }Source

Section

Section :: map[string][]stringSource

The main data structure. This can be generated from various different file formats, as long as we have a parser for them.

Constants

2

Variables

2

TS_XML_Options

TS_XML_Options :: xml.Options = xml.Options{ flags = { .Input_May_Be_Modified, .Must_Have_Prolog, .Must_Have_DocType, .Ignore_Unsupported, .Unbox_CDATA, .Decode_SGML_Entities, }, expected_doctype = "TS", }Source

Procedures

11

destroy

destroy :: proc(catalog: ^Translation, allocator: mem.Allocator = context.allocator)Source
  • destroy(), to clean up the currently active catalog catalog i18n.ACTIVE
  • destroy(catalog), to clean up a specific catalog.

get_by_section

get_by_section :: proc(section: string, key: string, catalog: ^Translation) -> (value: string)Source

Returns the first translation string for the passed key in a specific section or context.

It is also aliases with `get()`.

	Two ways to use it:
	- get(section, key), which defaults to the `i18n.ACTIVE` catalogue, or
	- get(section, key, catalog) to grab text from a specific loaded catalogue

	Inputs:
	- section: the catalogue section (sometimes also called 'context') in which to look up the translation
	- key:     the string to translate
	- catalog: the catalogue to use for the translation (defaults to i18n.ACTIVE)

	Returns:   the translated string, or the original `key` if no translation was found.

get_by_section_with_quantity

get_by_section_with_quantity :: proc(section: string, key: string, quantity: int, catalog: ^Translation) -> (value: string)Source

Returns the translation string for the passed key in a specific plural form (if present in the catalogue)

in a specific section or context.
	It is also aliases with `get_n()`.

	Two ways to use it:
	- get(section, key, quantity), which returns the appropriate plural from the active catalogue, or
	- get(section, key, quantity, catalog) to grab text from a specific loaded catalogue

	Inputs:
	- section: the catalogue section (sometime also called 'context') from which to lookup the translation
	- key:     the string to translate
	- qantity: the quantity of item to be used to select the correct plural form
	- catalog: the catalogue to use for the translation (defaults to i18n.ACTIVE)

	Returns:   the translated string, or the original `key` if no translation was found

get_by_slot_by_section

get_by_slot_by_section :: proc(section: string, key: string, slot: int, catalog: ^Translation) -> (value: string)Source

Two ways to use:

  • get_by_slot(key, slot), which returns the requested plural from the active catalog, or
  • get_by_slot(key, slot, catalog) to grab text from a specific one.
If a file format parser doesn't (yet) support plural slots, each of the slots will point at the same string.

	Inputs:
	- section: the catalogue section (sometime also called 'context') from which to lookup the translation
	- key:     the string to translate.
	- slot:    the translation slot to choose (slots refer to plural forms specific for each language and their meaning changes from catalogue to catalogue).
	- catalog: the catalogue to use for the translation (defaults to i18n.ACTIVE)

	Returns:   the translated string or the original `key` if no translation was found.

get_by_slot_single_section

get_by_slot_single_section :: proc(key: string, slot: int, catalog: ^Translation) -> (value: string)Source

Two ways to use:

  • get_by_slot(key, slot), which returns the requested plural from the active catalogue, or
  • get_by_slot(key, slot, catalog) to grab text from a specific loaded catalogue.
If a file format parser doesn't (yet) support plural slots, each of the slots will point at the same string.
	- section: the catalogue section (sometime also called 'context') from which to lookup the translation

	Inputs:
	- key:     the string to translate.
	- slot:    the translation slot to choose (slots refer to plural forms specific for each language and their meaning changes from catalogue to catalogue).
	- catalog: the catalogue to use for the translation (defaults to i18n.ACTIVE)

	Returns:   the translated string, or the original `key` if no translation was found.

get_single_section

get_single_section :: proc(key: string, catalog: ^Translation) -> (value: string)Source

Returns the first translation string for the passed key.

It is also aliased with `get()`.

	Two ways to use it:
	- get(key), which defaults to the `i18n.ACTIVE` catalogue, or
	- get(key, catalog) to grab text from a specific loaded catalogue

	Inputs:
	- key:     the string to translate
	- catalog: the catalogue to use for the translation (defaults to i18n.ACTIVE)

	Returns:   the translated string, or the original `key` if no translation was found.

get_single_section_with_quantity

get_single_section_with_quantity :: proc(key: string, quantity: int, catalog: ^Translation) -> (value: string)Source

Returns the translation string for the passed key in a specific plural form (if present in the catalogue).

It is also aliased with `get_n()`.

	Two ways to use it:
	- get_n(key, quantity), which returns the appropriate plural from the active catalogue, or
	- get_n(key, quantity, catalog) to grab text from a specific loaded catalogue

	Inputs:
	- key:      the string to translate
	- quantity: the quantity of item to be used to select the correct plural form
	- catalog:  the catalogue to use for the translation (defaults to i18n.ACTIVE)

	Returns:    the translated string, or the original `key` if no translation was found.

Procedure Groups

5

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.