libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiTextTranslator.h
1/****************************************************************************
2 * libgui
3 * Daryl Borth 2026
4 * GuiTextTranslator.h
5 ***************************************************************************/
6#pragma once
7
8#include <cstdint>
9#include <cstddef>
10
15class GuiTextTranslator
16{
17 public:
18 GuiTextTranslator();
19 ~GuiTextTranslator();
20
25 bool loadLanguage(const uint8_t* buffer, size_t size);
26
30 const char* getText(const char* msgid) const;
31
33 void clear();
34
35 private:
36 struct MSG
37 {
38 uint32_t id;
39 char* msgstr;
40 MSG* next;
41 };
42
43 MSG* head;
44
46 static uint32_t hashString(const char* str);
47 static char* expandEscape(const char* str);
48
50 const char* memFGets(char* dst, int maxlen, const char* src, const char* eof) const;
51
52 MSG* findMessage(uint32_t id) const;
53 MSG* setMessage(const char* msgid, const char* msgstr);
54};
const char * getText(const char *msgid) const
Retrieves the translated UTF-8 string for a given ASCII message ID.
bool loadLanguage(const uint8_t *buffer, size_t size)
Loads and parses a translation file from a memory buffer.
void clear()
Clears the current translation dictionary and frees memory.