Files
deck_in_a_dash/engine/src/i18n.h
T
ml 1a654da3e9
build / build (push) Successful in 30s
Introduces watch/, a real Pebble watchapp (built via pebble build) that
shows the daily tarot/astrology reading on-device: persistence, reading
computation, and UI screens, driven by the existing engine/interpreter
code linked in unchanged where possible.

Required engine-side changes to make that linking work:
- A compact low-precision ephemeris (lowprec_ephemeris.c) replacing the
  vendored ~127KB Astronomy Engine, which doesn't fit the watch's ~64KB
  app budget.
- Hand-rolled sqrt/atan2/sin/cos replacements for that ephemeris and
  astro.c's Ascendant calculation - Pebble's statically-linked libm
  hard-faults on real hardware under this app's -fPIE link for all four.
- narrative.c/guidance.c refactored from FILE*/fprintf onto snprintf-
  based buffers, since Pebble's SDK blocks fprintf at compile time.
2026-07-14 17:10:22 +02:00

42 lines
2.0 KiB
C

#ifndef DECK_I18N_H
#define DECK_I18N_H
#include <stdbool.h>
/* 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