Make generated sources public
This commit is contained in:
parent
a00d5d4031
commit
402b79f862
@ -46,9 +46,9 @@ public enum Generation {
|
|||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
"""
|
"""
|
||||||
enum Localized {
|
public enum Localized {
|
||||||
|
|
||||||
static var yml: String {
|
public static var yml: String {
|
||||||
\"""
|
\"""
|
||||||
\(indent(yml, by: indentTwo))
|
\(indent(yml, by: indentTwo))
|
||||||
\"""
|
\"""
|
||||||
@ -56,7 +56,7 @@ public enum Generation {
|
|||||||
|
|
||||||
\(generateEnumCases(dictionary: dictionary))
|
\(generateEnumCases(dictionary: dictionary))
|
||||||
|
|
||||||
var string: String { string(for: System.getLanguage()) }
|
public var string: String { string(for: System.getLanguage()) }
|
||||||
|
|
||||||
\(try generateTranslations(dictionary: dictionary, defaultLanguage: defaultLanguage))
|
\(try generateTranslations(dictionary: dictionary, defaultLanguage: defaultLanguage))
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public enum Generation {
|
|||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
"""
|
"""
|
||||||
enum Loc {
|
public enum Loc {
|
||||||
|
|
||||||
\(generateStaticLocVariables(dictionary: dictionary))
|
\(generateStaticLocVariables(dictionary: dictionary))
|
||||||
|
|
||||||
@ -111,11 +111,11 @@ public enum Generation {
|
|||||||
let key = parse(key: entry.key)
|
let key = parse(key: entry.key)
|
||||||
if key.1.isEmpty {
|
if key.1.isEmpty {
|
||||||
result.append("""
|
result.append("""
|
||||||
static var \(entry.key): String { Localized.\(entry.key).string }
|
public static var \(entry.key): String { Localized.\(entry.key).string }
|
||||||
|
|
||||||
""")
|
""")
|
||||||
} else {
|
} else {
|
||||||
var line = "static func \(key.0)("
|
var line = "public static func \(key.0)("
|
||||||
for argument in key.1 {
|
for argument in key.1 {
|
||||||
line += "\(argument): CustomStringConvertible, "
|
line += "\(argument): CustomStringConvertible, "
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ public enum Generation {
|
|||||||
static func generateTranslations(dictionary: [String: [String: String]], defaultLanguage: String) throws -> String {
|
static func generateTranslations(dictionary: [String: [String: String]], defaultLanguage: String) throws -> String {
|
||||||
var result = ""
|
var result = ""
|
||||||
for language in getLanguages(dictionary: dictionary) {
|
for language in getLanguages(dictionary: dictionary) {
|
||||||
var variable = indent("var \(language): String {", by: indentOne)
|
var variable = indent("public var \(language): String {", by: indentOne)
|
||||||
variable += indent("\nswitch self {", by: indentTwo)
|
variable += indent("\nswitch self {", by: indentTwo)
|
||||||
for entry in dictionary {
|
for entry in dictionary {
|
||||||
let key = parse(key: entry.key)
|
let key = parse(key: entry.key)
|
||||||
@ -222,7 +222,7 @@ public enum Generation {
|
|||||||
dictionary: [String: [String: String]],
|
dictionary: [String: [String: String]],
|
||||||
defaultLanguage: String
|
defaultLanguage: String
|
||||||
) -> String {
|
) -> String {
|
||||||
var result = "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 where language != defaultLanguage {
|
||||||
result += indent("if language.hasPrefix(\"\(language)\") {", by: indentTwo)
|
result += indent("if language.hasPrefix(\"\(language)\") {", by: indentTwo)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user