Fix translations with country code not working

This commit is contained in:
david-swift 2024-03-10 10:43:58 +01:00
parent 402b79f862
commit 3b5837a44e
3 changed files with 3 additions and 3 deletions

View File

@ -224,7 +224,7 @@ public enum Generation {
) -> String {
var result = "public func string(for language: String) -> String {\n"
let languages = getLanguages(dictionary: dictionary)
for language in languages where language != defaultLanguage {
for language in languages.sorted().reversed() where language != defaultLanguage {
result += indent("if language.hasPrefix(\"\(language)\") {", by: indentTwo)
result += indent("\nreturn \(language)", by: indentThree)
result += indent("\n} else", by: indentTwo)

View File

@ -21,8 +21,7 @@ public enum System {
guard let lang = ProcessInfo.processInfo.environment["LANG"] else {
return "en"
}
let components = lang.split(separator: "_")
systemLanguage = .init(components.first ?? "en")
systemLanguage = lang
#endif
#if os(macOS)
systemLanguage = Locale.preferredLanguages.first

View File

@ -4,6 +4,7 @@ hello(name):
en: Hello, (name)!
de: Hallo, (name)!
fr: Salut, (name)!
pt_BR: Olá, (name)!
house:
en: House