package core:text/i18n
⌘K
Ctrl+K
or
/
Index
Types (4)
Constants (2)
Variables (2)
Procedure Groups (4)
Types
Error ¶
Error :: enum int { // General return values. None = 0, Empty_Translation_Catalog, Duplicate_Key, // Couldn't find, open or read file. File_Error, // File too short. Premature_EOF, // GNU Gettext *.MO file errors. MO_File_Invalid_Signature, MO_File_Unsupported_Version, MO_File_Invalid, MO_File_Incorrect_Plural_Count, // Qt Linguist *.TS file errors. TS_File_Parse_Error, TS_File_Expected_Context, TS_File_Expected_Context_Name, TS_File_Expected_Source, TS_File_Expected_Translation, TS_File_Expected_NumerusForm, Bad_Str, Bad_Id, }
Related Procedures With Returns
- parse_mo_file
- parse_mo_from_bytes
- parse_qt_linguist_file
- parse_qt_linguist_from_bytes
- read_u16
- read_u32
- parse_mo (procedure groups)
- parse_qt (procedure groups)
Parse_Options ¶
Parse_Options :: struct { merge_sections: bool, }
Related Procedures With Parameters
- parse_mo_file
- parse_mo_from_bytes
- parse_qt_linguist_file
- parse_qt_linguist_from_bytes
- parse_mo (procedure groups)
- parse_qt (procedure groups)
Translation ¶
Translation :: struct { k_v: map[string]map[string][]string, // k_v[section][key][plural_form] = ... intern: strings.Intern, pluralize: proc(number: int) -> int, }
Related Procedures With Parameters
- destroy
- get_by_section
- get_by_slot_by_section
- get_by_slot_single_section
- get_single_section
- get (procedure groups)
- get_by_slot (procedure groups)
Related Procedures With Returns
- parse_mo_file
- parse_mo_from_bytes
- parse_qt_linguist_file
- parse_qt_linguist_from_bytes
- parse_mo (procedure groups)
- parse_qt (procedure groups)
Constants
DEFAULT_PARSE_OPTIONS ¶
DEFAULT_PARSE_OPTIONS :: Parse_Options{merge_sections = false}
MAX_PLURALS ¶
MAX_PLURALS :: min(max(#config(ODIN_i18N_MAX_PLURAL_FORMS, 10), 1), 255)
Allow between 1 and 255 plural forms. Default: 10.
Variables
TS_XML_Options ¶
TS_XML_Options: xml.Options = …
Procedures
destroy ¶
destroy :: proc(catalog: ^Translation = ACTIVE, allocator := context.allocator) {…}
Same for destroy:
- 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, key: string, number: int = 0, catalog: ^Translation = ACTIVE) -> (value: string) {…}
Several ways to use:
- get(section, key), which defaults to the singular form and i18n.ACTIVE catalog, or - get(section, key, number), which returns the appropriate plural from the active catalog, or - get(section, key, number, catalog) to grab text from a specific one.
get_by_slot_by_section ¶
get_by_slot_by_section :: proc(section, key: string, slot: int = 0, catalog: ^Translation = ACTIVE) -> (value: string) {…}
Several ways to use:
- get_by_slot(key), which defaults to the singular form and i18n.ACTIVE catalog, or - 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.
get_by_slot_single_section ¶
get_by_slot_single_section :: proc(key: string, slot: int = 0, catalog: ^Translation = ACTIVE) -> (value: string) {…}
Several ways to use:
- get_by_slot(key), which defaults to the singular form and i18n.ACTIVE catalog, or - 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.
get_single_section ¶
get_single_section :: proc(key: string, number: int = 0, catalog: ^Translation = ACTIVE) -> (value: string) {…}
Several ways to use:
- get(key), which defaults to the singular form and i18n.ACTIVE catalog, or - get(key, number), which returns the appropriate plural from the active catalog, or - get(key, number, catalog) to grab text from a specific one.
parse_mo_file ¶
parse_mo_file :: proc(filename: string, options: Parse_Options = DEFAULT_PARSE_OPTIONS, pluralizer: proc(_: int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {…}
parse_mo_from_bytes ¶
parse_mo_from_bytes :: proc(data: []u8, options: Parse_Options = DEFAULT_PARSE_OPTIONS, pluralizer: proc(_: int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {…}
parse_qt_linguist_file ¶
parse_qt_linguist_file :: proc(filename: string, options: Parse_Options = DEFAULT_PARSE_OPTIONS, pluralizer: proc(_: int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {…}
parse_qt_linguist_from_bytes ¶
parse_qt_linguist_from_bytes :: proc(data: []u8, options: Parse_Options = DEFAULT_PARSE_OPTIONS, pluralizer: proc(_: int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {…}
read_u32 ¶
Helpers.
Procedure Groups
get ¶
get :: proc{ get_single_section, get_by_section, }
get_by_slot ¶
get_by_slot :: proc{ get_by_slot_single_section, get_by_slot_by_section, }
parse_mo ¶
parse_mo :: proc{ parse_mo_file, parse_mo_from_bytes, }
parse_qt ¶
parse_qt :: proc{ parse_qt_linguist_file, parse_qt_linguist_from_bytes, }
Source Files
Generation Information
Generated with odin version dev-2023-10 (vendor "odin") Windows_amd64 @ 2023-10-03 21:09:46.598886800 +0000 UTC