libgui 3.00
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiTextTranslator Class Reference

Hashed msgid -> UTF-8 string table loaded from a single binary .lang blob (see loadLanguage()). More...

#include <GuiTextTranslator.h>

Public Member Functions

constexpr GuiTextTranslator ()
 constexpr on purpose: an instance defined at namespace scope is then constant-initialized (it is laid out in the binary and no constructor runs at startup), so it is already valid for any static initializer in any translation unit, whatever the link order.
 
bool loadLanguage (const uint8_t *buffer, size_t size)
 Loads and parses a translation file from a memory buffer.
 
const char * getText (const char *msgid) const
 Retrieves the translated UTF-8 string for a given ASCII message ID.
 
void clear ()
 Clears the current translation dictionary and frees memory.
 

Detailed Description

Hashed msgid -> UTF-8 string table loaded from a single binary .lang blob (see loadLanguage()).

GuiText and other classes call getText() to resolve a message ID to translated text.

Definition at line 15 of file GuiTextTranslator.h.

Constructor & Destructor Documentation

◆ GuiTextTranslator()

GuiTextTranslator::GuiTextTranslator ( )
inlineconstexpr

constexpr on purpose: an instance defined at namespace scope is then constant-initialized (it is laid out in the binary and no constructor runs at startup), so it is already valid for any static initializer in any translation unit, whatever the link order.

Definition at line 21 of file GuiTextTranslator.h.

◆ ~GuiTextTranslator()

GuiTextTranslator::~GuiTextTranslator ( )

Definition at line 14 of file GuiTextTranslator.cpp.

Member Function Documentation

◆ clear()

void GuiTextTranslator::clear ( )

Clears the current translation dictionary and frees memory.

Definition at line 189 of file GuiTextTranslator.cpp.

◆ getText()

const char * GuiTextTranslator::getText ( const char * msgid) const

Retrieves the translated UTF-8 string for a given ASCII message ID.

Parameters
msgidThe English text/ID to translate
Returns
The translated string, or the original msgid if not found

Definition at line 279 of file GuiTextTranslator.cpp.

◆ loadLanguage()

bool GuiTextTranslator::loadLanguage ( const uint8_t * buffer,
size_t size )

Loads and parses a translation file from a memory buffer.

Parameters
bufferPointer to the loaded file data
sizeLength of the buffer in bytes
Returns
true if successful, false otherwise

Definition at line 221 of file GuiTextTranslator.cpp.


The documentation for this class was generated from the following files: