From 3ebd5b839f18aa777474c314e23288c64c992794 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 7 Mar 2025 10:33:09 -0800 Subject: [PATCH] update translating readme --- po/README_TRANSLATORS.md | 10 +++++++--- src/os/i18n.zig | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/po/README_TRANSLATORS.md b/po/README_TRANSLATORS.md index 5db0cf12f..3da3f96b2 100644 --- a/po/README_TRANSLATORS.md +++ b/po/README_TRANSLATORS.md @@ -131,14 +131,18 @@ which should be filled in accordingly. You can then add your translations within the newly created translation file. Afterwards, you need to update the list of known locales within Ghostty's -build system. To do so, open `src/build/GhosttyI18n.zig` and find the list -of locales under the `locale` variable, then append the full locale name +build system. To do so, open `src/os/i81n.zig` and find the list +of locales under the `locales` variable, then add the full locale name into the list. +The order matters, so make sure to place your locale in the correct position. +Read the comment above the variable for more details on the order. If you're +unsure, place it at the end of the list. + ```zig const locales = [_][]const u8{ "zh_CN.UTF-8", - // <- Add your locale here + // <- Add your locale here (probably) } ``` diff --git a/src/os/i18n.zig b/src/os/i18n.zig index a9000e18d..15255578a 100644 --- a/src/os/i18n.zig +++ b/src/os/i18n.zig @@ -11,6 +11,17 @@ const log = std.log.scoped(.i18n); /// a language code available), the first match is used. For example, if /// we know the user requested `zh` but has no region code, then we'd pick /// the first locale that matches `zh`. +/// +/// For ordering, we prefer: +/// +/// 1. The most common locales first, since there are places in the code +/// where we do linear searches for a locale and we want to minimize +/// the number of iterations for the common case. +/// +/// 2. Alphabetical for otherwise equally common locales. +/// +/// 3. Most preferred locale for a language without a country code. +/// pub const locales = [_][:0]const u8{ "zh_CN.UTF-8", };