#ifndef DECK_I18N_H #define DECK_I18N_H #include /* Loads a `key=value` translation file (# comments and blank lines * ignored, same format as dist/user.properties) into a process-global * catalog, replacing whatever was loaded before. Returns false if the * file can't be opened (the catalog is left as it was in that case). * * This uses stdio, so - like main.c and reading_print_text/_html - it's * a desktop-only entry point: Pebble's SDK doesn't provide fopen/fgets * at all (a compile-time error, not just a runtime failure), so this * function isn't even compiled when building for the watch (guarded * #ifndef PBL_SDK_3 in i18n.c) - see i18n_load_table() below, its * watch-side equivalent. */ #ifndef PBL_SDK_3 bool i18n_load(const char *path); #endif /* The watch's non-file-based equivalent of i18n_load(): points i18n_get() * at two parallel arrays (keys[i] -> values[i], `count` entries) instead * of parsing a file - for a compiled-in translation table generated from * engine/i18n's .lang files at watch-app build time (see the watch * app's own build tooling). Zero-copy - just stores the three pointers - * so `keys`/`values` must outlive the call (a `static const char *const` * array is the expected caller, living in flash/ROM, not a local/heap * buffer). This is what keeps the watch from needing i18n_load()'s * ~140KB g_entries[] catalog, which its RAM budget can't afford. * Available on every platform, since it has no platform-specific * dependencies, but only the watch actually calls it today. */ void i18n_load_table(const char *const *keys, const char *const *values, int count); /* Returns the translation for `key` from the loaded catalog, or * `fallback` if no catalog is loaded or `key` isn't in it. Every caller * in this codebase passes the built-in English text as `fallback`, so a * missing file or a partially-translated one degrades to English rather * than showing raw keys or blank strings. */ const char *i18n_get(const char *key, const char *fallback); #endif