Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
I18n Class Reference

Compile-time UI string table for EN/FR localization. More...

#include <I18n.hpp>

+ Collaboration diagram for I18n:

Public Types

enum class  Language { EN , FR }
 
enum class  Key {
  HUD_FPS , HUD_MAP , HUD_TIME_UNIT , HUD_UPTIME_UNKNOWN ,
  HUD_UPTIME_PREFIX , HUD_UPTIME_H , HUD_UPTIME_M , HUD_UPTIME_S ,
  HUD_PORT , HUD_MACHINE , LABEL_TILE , LABEL_PLAYER ,
  LABEL_EGG , TILE_EMPTY , TILE_HEADER , PLAYER_TEAM ,
  PLAYER_LEVEL , PLAYER_INVENTORY_EMPTY , PLAYER_INVENTORY , EGG_TEAM ,
  PANEL_PLAYER_LIST , PANEL_LVL , BTN_FOLLOW , BTN_STOP_FOLLOW ,
  SPEED_LABEL , PLAYER_HEAD_LEVEL , WIN_GAME_OVER , WIN_TEAM_WON ,
  WIN_DURATION , WIN_DURATION_UNKNOWN , WIN_TICKS , WIN_QUIT ,
  RESOURCE_FOOD , RESOURCE_LINEMATE , RESOURCE_DERAUMERE , RESOURCE_SIBUR ,
  RESOURCE_MENDIANE , RESOURCE_PHIRAS , RESOURCE_THYSTAME , _COUNT
}
 

Static Public Member Functions

static void setLanguage (Language lang)
 
static Language getLanguage ()
 
static const char * get (Key key)
 
static const char * resourceName (int index)
 Resource name by index (0–6), matching Resources[] ordering.
 

Static Private Attributes

static Language _lang = I18n::Language::EN
 
static constexpr const char * _strings [2][static_cast< int >(Key::_COUNT)]
 

Detailed Description

Compile-time UI string table for EN/FR localization.

Strings are stored as a static constexpr 2D array indexed by [language][key]. This gives O(1) lookup with zero allocation and no I/O — deliberately chosen over a config file, since languages are a compile-time concern and a missing file is an unnecessary failure mode.

To add a language: extend the Language enum and add a column to _strings. To add a string: add a Key entry and a corresponding value in each language column.

Definition at line 14 of file I18n.hpp.

Member Enumeration Documentation

◆ Key

enum class I18n::Key
strong
Enumerator
HUD_FPS 
HUD_MAP 
HUD_TIME_UNIT 
HUD_UPTIME_UNKNOWN 
HUD_UPTIME_PREFIX 
HUD_UPTIME_H 
HUD_UPTIME_M 
HUD_UPTIME_S 
HUD_PORT 
HUD_MACHINE 
LABEL_TILE 
LABEL_PLAYER 
LABEL_EGG 
TILE_EMPTY 
TILE_HEADER 
PLAYER_TEAM 
PLAYER_LEVEL 
PLAYER_INVENTORY_EMPTY 
PLAYER_INVENTORY 
EGG_TEAM 
PANEL_PLAYER_LIST 
PANEL_LVL 
BTN_FOLLOW 
BTN_STOP_FOLLOW 
SPEED_LABEL 
PLAYER_HEAD_LEVEL 
WIN_GAME_OVER 
WIN_TEAM_WON 
WIN_DURATION 
WIN_DURATION_UNKNOWN 
WIN_TICKS 
WIN_QUIT 
RESOURCE_FOOD 
RESOURCE_LINEMATE 
RESOURCE_DERAUMERE 
RESOURCE_SIBUR 
RESOURCE_MENDIANE 
RESOURCE_PHIRAS 
RESOURCE_THYSTAME 
_COUNT 

Definition at line 18 of file I18n.hpp.

◆ Language

enum class I18n::Language
strong
Enumerator
EN 
FR 

Definition at line 16 of file I18n.hpp.

Member Function Documentation

◆ get()

static const char * I18n::get ( Key  key)
inlinestatic

Definition at line 86 of file I18n.hpp.

References _lang, and _strings.

Referenced by EntityTooltipWidget::_positionButton(), EntityTooltipWidget::_rebuild(), WinScreen::_rebuildPanel(), RaylibRenderer::_render2D(), HudWidget::draw(), SpeedSlider::draw(), WinScreen::draw(), EntityTooltipWidget::handleInput(), PlayerPanel::handleInput(), and resourceName().

+ Here is the caller graph for this function:

◆ getLanguage()

static Language I18n::getLanguage ( )
inlinestatic

Definition at line 84 of file I18n.hpp.

References _lang.

Referenced by RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ resourceName()

static const char * I18n::resourceName ( int  index)
inlinestatic

Resource name by index (0–6), matching Resources[] ordering.

Definition at line 92 of file I18n.hpp.

References get(), and RESOURCE_FOOD.

Referenced by EntityTooltipWidget::_rebuild().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLanguage()

static void I18n::setLanguage ( Language  lang)
inlinestatic

Definition at line 83 of file I18n.hpp.

References _lang.

Referenced by RaylibRenderer::handleInput(), and App::run().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _lang

I18n::Language I18n::_lang = I18n::Language::EN
staticprivate

Definition at line 98 of file I18n.hpp.

Referenced by get(), getLanguage(), and setLanguage().

◆ _strings

constexpr const char* I18n::_strings[2][static_cast< int >(Key::_COUNT)]
staticconstexprprivate

Definition at line 100 of file I18n.hpp.

Referenced by get().


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