CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
I18n.h File Reference

Internationalization with English fallbacks in code and overlay translations loaded at runtime from a VFAT JSON file. More...

#include "cdc_core/Raii.h"
#include <cstdint>
#include <cstddef>
#include <functional>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  cdc::ui::I18nEntry
 Single English translation entry. More...
struct  cdc::ui::OverlayLanguage
 Internationalization singleton. More...
class  cdc::ui::I18n

Namespaces

namespace  cdc
namespace  cdc::ui
 Centralized key-code constants for cdc_views.

Functions

const char * cdc::ui::tr (const char *key)
 Look up a translation by string key.

Detailed Description

Internationalization with English fallbacks in code and overlay translations loaded at runtime from a VFAT JSON file.

Architecture:

  • English fallbacks live in code as I18nEntry tables registered by each module at startup. They sit in rodata and are always available.
  • Every other language lives in its own flat file /plugins/i18n/lang_<code>.json on the plugins FAT partition, e.g. lang_de.json. The file is a flat { "<key>": "<value>", ... } object and its core.lang_name value is the language's own display name (endonym). Adding a language is just dropping a new lang_<code>.json; it appears in the picker automatically.
  • The active language's file is parsed into a PSRAM-backed key-value table; the set of selectable languages is discovered by scanning the directory.
  • Plugin manifest strings keep their own i18n_strings map and are queried via host_i18n_tr_key - unchanged by this rewrite.

Key conventions:

  • core.* for firmware-wide strings.
  • mod_<name>.* for module-specific strings.
  • Keys are 7-bit ASCII, snake_case, no spaces.

Definition in file I18n.h.