Localize remaining hardcoded UI strings and persist language preference

Replaces the last hardcoded English strings (initial-scene modals, game
menu save status messages) with locale-loaded text, adds a shared
LOCALE_LIST so the settings dropdown and locale manager stay in sync,
and persists the chosen language into savemeta_t across all platforms.
Also fixes two message buffers that were too small for their longest
translations.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 21:39:24 -05:00
parent 1ddc298a74
commit 7357b4a5df
19 changed files with 417 additions and 50 deletions
+14
View File
@@ -31,6 +31,12 @@ void saveJsonWriterAddFloatLinux(
yyjson_mut_obj_add_real(writer->doc, writer->root, key, (double)value);
}
void saveJsonWriterAddUInt8Linux(
savejsonwriterlinux_t *writer, const char_t *key, const uint8_t value
) {
yyjson_mut_obj_add_uint(writer->doc, writer->root, key, (uint64_t)value);
}
void saveJsonWriterAddStringLinux(
savejsonwriterlinux_t *writer, const char_t *key, const char_t *value
) {
@@ -122,6 +128,14 @@ float_t saveJsonReadFloatLinux(
return (float_t)yyjson_get_num(val);
}
uint8_t saveJsonReadUInt8Linux(
yyjson_val *root, const char_t *key, const uint8_t defaultValue
) {
yyjson_val *val = yyjson_obj_get(root, key);
if(!val || !yyjson_is_num(val)) return defaultValue;
return (uint8_t)yyjson_get_uint(val);
}
void saveJsonReadStringLinux(
yyjson_val *root, const char_t *key, char_t *out, const size_t maxLen,
const char_t *defaultValue
+15
View File
@@ -42,6 +42,13 @@ void saveJsonWriterAddFloatLinux(
savejsonwriterlinux_t *writer, const char_t *key, const float_t value
);
/**
* Adds a "key": <uint> field to the root object.
*/
void saveJsonWriterAddUInt8Linux(
savejsonwriterlinux_t *writer, const char_t *key, const uint8_t value
);
/**
* Adds a string field to the root object. The value is copied into the
* document, so the caller's buffer doesn't need to outlive the call.
@@ -120,6 +127,14 @@ float_t saveJsonReadFloatLinux(
yyjson_val *root, const char_t *key, const float_t defaultValue
);
/**
* Reads a uint8 field, falling back to defaultValue if the key is
* missing or not a number.
*/
uint8_t saveJsonReadUInt8Linux(
yyjson_val *root, const char_t *key, const uint8_t defaultValue
);
/**
* Reads a string field into out, falling back to defaultValue if the key
* is missing or not a string. Always null-terminates.
+4
View File
@@ -120,6 +120,9 @@ errorret_t saveMetaLoadLinux(savemeta_t *out) {
out->deadzone = saveJsonReadFloatLinux(
root, "deadzone", SAVE_META_DEADZONE_DEFAULT
);
out->language = saveJsonReadUInt8Linux(
root, "language", SAVE_META_LANGUAGE_DEFAULT
);
out->exists = true;
yyjson_doc_free(doc);
@@ -136,6 +139,7 @@ errorret_t saveMetaWriteLinux(savemeta_t *meta) {
errorChain(saveJsonWriterInitLinux(&writer));
saveJsonWriterAddUInt32Linux(&writer, "version", meta->version);
saveJsonWriterAddFloatLinux(&writer, "deadzone", meta->deadzone);
saveJsonWriterAddUInt8Linux(&writer, "language", meta->language);
errorret_t ret = saveJsonWriterSaveLinux(&writer, path);
saveJsonWriterDisposeLinux(&writer);