Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Fix generation not working for single language
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Mar 4, 2024
1 parent edf10b1 commit a00d5d4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Sources/GenerationLibrary/Generation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,25 @@ public enum Generation {
defaultLanguage: String
) -> String {
var result = "func string(for language: String) -> String {\n"
for language in getLanguages(dictionary: dictionary) where language != defaultLanguage {
let languages = getLanguages(dictionary: dictionary)
for language in languages where language != defaultLanguage {
result += indent("if language.hasPrefix(\"\(language)\") {", by: indentTwo)
result += indent("\nreturn \(language)", by: indentThree)
result += indent("\n} else", by: indentTwo)
}
result += """
{
return \(defaultLanguage)
}
if languages.count <= 1 {
result += """
return \(defaultLanguage)
}
"""
} else {
result += """
{
return \(defaultLanguage)
}
}
"""
}
"""
return result
}

Expand Down

0 comments on commit a00d5d4

Please sign in to comment.