build: move locales out into dedicated file
parent
d65466362d
commit
9feaec9c9c
|
|
@ -4,7 +4,7 @@ const std = @import("std");
|
|||
const builtin = @import("builtin");
|
||||
const Config = @import("Config.zig");
|
||||
const gresource = @import("../apprt/gtk/build/gresource.zig");
|
||||
const internal_os = @import("../os/main.zig");
|
||||
const locales = @import("../os/i18n_locales.zig").locales;
|
||||
|
||||
const domain = "com.mitchellh.ghostty";
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
|
|||
var steps = std.ArrayList(*std.Build.Step).init(b.allocator);
|
||||
defer steps.deinit();
|
||||
|
||||
inline for (internal_os.i18n.locales) |locale| {
|
||||
inline for (locales) |locale| {
|
||||
// There is no encoding suffix in the LC_MESSAGES path on FreeBSD,
|
||||
// so we need to remove it from `locale` to have a correct destination string.
|
||||
// (/usr/local/share/locale/en_AU/LC_MESSAGES)
|
||||
|
|
@ -155,7 +155,7 @@ fn createUpdateStep(b: *std.Build) !*std.Build.Step {
|
|||
"po/" ++ domain ++ ".pot",
|
||||
);
|
||||
|
||||
inline for (internal_os.i18n.locales) |locale| {
|
||||
inline for (locales) |locale| {
|
||||
const msgmerge = b.addSystemCommand(&.{ "msgmerge", "--quiet", "--no-fuzzy-matching" });
|
||||
msgmerge.addFileArg(b.path("po/" ++ locale ++ ".po"));
|
||||
msgmerge.addFileArg(xgettext.captureStdOut());
|
||||
|
|
|
|||
|
|
@ -1,59 +1,10 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const build_config = @import("../build_config.zig");
|
||||
const locales = @import("i18n_locales.zig");
|
||||
|
||||
const log = std.log.scoped(.i18n);
|
||||
|
||||
/// Supported locales for the application. This must be kept up to date
|
||||
/// with the translations available in the `po/` directory; this is used
|
||||
/// by our build process as well runtime libghostty APIs.
|
||||
///
|
||||
/// The order also matters. For incomplete locale information (i.e. only
|
||||
/// a language code available), the first match is used. For example, if
|
||||
/// we know the user requested `zh` but has no script 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.
|
||||
///
|
||||
/// Note for "most common" locales, this is subjective and based on
|
||||
/// the perceived userbase of Ghostty, which may not be representative
|
||||
/// of general populations or global language distribution. Also note
|
||||
/// that ordering may be weird when we first merge a new locale since
|
||||
/// we don't have a good way to determine this. We can always reorder
|
||||
/// with some data.
|
||||
pub const locales = [_][:0]const u8{
|
||||
"zh_CN.UTF-8",
|
||||
"de_DE.UTF-8",
|
||||
"fr_FR.UTF-8",
|
||||
"ja_JP.UTF-8",
|
||||
"nl_NL.UTF-8",
|
||||
"nb_NO.UTF-8",
|
||||
"ru_RU.UTF-8",
|
||||
"uk_UA.UTF-8",
|
||||
"pl_PL.UTF-8",
|
||||
"ko_KR.UTF-8",
|
||||
"mk_MK.UTF-8",
|
||||
"tr_TR.UTF-8",
|
||||
"id_ID.UTF-8",
|
||||
"es_BO.UTF-8",
|
||||
"es_AR.UTF-8",
|
||||
"pt_BR.UTF-8",
|
||||
"ca_ES.UTF-8",
|
||||
"it_IT.UTF-8",
|
||||
"bg_BG.UTF-8",
|
||||
"ga_IE.UTF-8",
|
||||
"hu_HU.UTF-8",
|
||||
"he_IL.UTF-8",
|
||||
};
|
||||
|
||||
/// Set for faster membership lookup of locales.
|
||||
pub const locales_map = map: {
|
||||
var kvs: [locales.len]struct { []const u8 } = undefined;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
// NOTE: This is in a separate file because our build depends on it and
|
||||
// we want to minimize the transitive dependencies of the build binary
|
||||
// itself.
|
||||
|
||||
/// Supported locales for the application. This must be kept up to date
|
||||
/// with the translations available in the `po/` directory; this is used
|
||||
/// by our build process as well runtime libghostty APIs.
|
||||
///
|
||||
/// The order also matters. For incomplete locale information (i.e. only
|
||||
/// a language code available), the first match is used. For example, if
|
||||
/// we know the user requested `zh` but has no script 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.
|
||||
///
|
||||
/// Note for "most common" locales, this is subjective and based on
|
||||
/// the perceived userbase of Ghostty, which may not be representative
|
||||
/// of general populations or global language distribution. Also note
|
||||
/// that ordering may be weird when we first merge a new locale since
|
||||
/// we don't have a good way to determine this. We can always reorder
|
||||
/// with some data.
|
||||
pub const locales = [_][:0]const u8{
|
||||
"zh_CN.UTF-8",
|
||||
"de_DE.UTF-8",
|
||||
"fr_FR.UTF-8",
|
||||
"ja_JP.UTF-8",
|
||||
"nl_NL.UTF-8",
|
||||
"nb_NO.UTF-8",
|
||||
"ru_RU.UTF-8",
|
||||
"uk_UA.UTF-8",
|
||||
"pl_PL.UTF-8",
|
||||
"ko_KR.UTF-8",
|
||||
"mk_MK.UTF-8",
|
||||
"tr_TR.UTF-8",
|
||||
"id_ID.UTF-8",
|
||||
"es_BO.UTF-8",
|
||||
"es_AR.UTF-8",
|
||||
"pt_BR.UTF-8",
|
||||
"ca_ES.UTF-8",
|
||||
"it_IT.UTF-8",
|
||||
"bg_BG.UTF-8",
|
||||
"ga_IE.UTF-8",
|
||||
"hu_HU.UTF-8",
|
||||
"he_IL.UTF-8",
|
||||
};
|
||||
Loading…
Reference in New Issue