mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
use splitScalar instead of hardcoding
Signed-off-by: Aaron Ruan <i@ar212.com>
This commit is contained in:
@ -127,18 +127,20 @@ pub fn canonicalizeLocale(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fixZhLocale(locale: []const u8) []const u8 {
|
fn fixZhLocale(locale: []const u8) []const u8 {
|
||||||
if (locale.len == 10 and std.mem.eql(u8, locale[0..2], "zh")) {
|
var it = std.mem.splitScalar(u8, locale, '-');
|
||||||
const script = locale[3..7];
|
const name = it.next() orelse return locale;
|
||||||
const region = locale[8..10];
|
if (!std.mem.eql(u8, name, "zh")) return locale;
|
||||||
|
|
||||||
if (std.mem.eql(u8, script, "Hans")) {
|
const script = it.next() orelse return locale;
|
||||||
if (std.mem.eql(u8, region, "SG")) return "zh_SG";
|
const region = it.next() orelse return locale;
|
||||||
return "zh_CN";
|
|
||||||
} else if (std.mem.eql(u8, script, "Hant")) {
|
if (std.mem.eql(u8, script, "Hans")) {
|
||||||
if (std.mem.eql(u8, region, "HK")) return "zh_HK";
|
if (std.mem.eql(u8, region, "SG")) return "zh_SG";
|
||||||
if (std.mem.eql(u8, region, "MO")) return "zh_MO";
|
return "zh_CN";
|
||||||
return "zh_TW";
|
} else if (std.mem.eql(u8, script, "Hant")) {
|
||||||
}
|
if (std.mem.eql(u8, region, "MO")) return "zh_MO";
|
||||||
|
if (std.mem.eql(u8, region, "HK")) return "zh_HK";
|
||||||
|
return "zh_TW";
|
||||||
}
|
}
|
||||||
|
|
||||||
return locale;
|
return locale;
|
||||||
|
Reference in New Issue
Block a user