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 { ) -> String {
var result = "public func string(for language: String) -> String {\n" var result = "public func string(for language: String) -> String {\n"
let languages = getLanguages(dictionary: dictionary) 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("if language.hasPrefix(\"\(language)\") {", by: indentTwo)
result += indent("\nreturn \(language)", by: indentThree) result += indent("\nreturn \(language)", by: indentThree)
result += indent("\n} else", by: indentTwo) result += indent("\n} else", by: indentTwo)

View File

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

View File

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