Skip to content

Commit

Permalink
Fix translations with country code not working
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Mar 10, 2024
1 parent 402b79f commit 3b5837a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/GenerationLibrary/Generation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions Sources/Localized/System.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Tests/PluginTests/Localized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ hello(name):
en: Hello, (name)!
de: Hallo, (name)!
fr: Salut, (name)!
pt_BR: Olá, (name)!

house:
en: House
Expand Down

0 comments on commit 3b5837a

Please sign in to comment.