61 lines
2.3 KiB
Plaintext
61 lines
2.3 KiB
Plaintext
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen
|
|
|
|
{% if tables.count > 0 %}
|
|
{% set accessModifier %}{% if param.publicAccess %}public{% else %}public{% endif %}{% endset %}
|
|
import Foundation
|
|
|
|
// swiftlint:disable superfluous_disable_command
|
|
// swiftlint:disable file_length
|
|
{% macro parametersBlock types %}{% filter removeNewlines:"leading" %}
|
|
{% for type in types %}
|
|
_ p{{forloop.counter}}: {{type}}{% if not forloop.last %}, {% endif %}
|
|
{% endfor %}
|
|
{% endfilter %}{% endmacro %}
|
|
{% macro argumentsBlock types %}{% filter removeNewlines:"leading" %}
|
|
{% for type in types %}
|
|
p{{forloop.counter}}{% if not forloop.last %}, {% endif %}
|
|
{% endfor %}
|
|
{% endfilter %}{% endmacro %}
|
|
{% macro recursiveBlock table item sp %}
|
|
{{sp}} {% for string in item.strings %}
|
|
{{sp}} {% if not param.noComments %}
|
|
{{sp}} /// {{string.translation}}
|
|
{{sp}} {% endif %}
|
|
{{sp}} {% if string.types %}
|
|
{{sp}} {{accessModifier}} static func {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String {
|
|
{{sp}} return {{enumName}}.tr("{{table}}", "{{string.key}}", {% call argumentsBlock string.types %})
|
|
{{sp}} }
|
|
{{sp}} {% else %}
|
|
{{sp}} {{accessModifier}} static var {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}: String { return {{enumName}}.tr("{{table}}", "{{string.key}}") }
|
|
{{sp}} {% endif %}
|
|
{{sp}} {% endfor %}
|
|
{{sp}} {% for child in item.children %}
|
|
{{sp}} {% call recursiveBlock table child sp %}
|
|
{{sp}} {% endfor %}
|
|
{% endmacro %}
|
|
|
|
// swiftlint:disable identifier_name line_length type_body_length
|
|
{% set enumName %}{{param.enumName|default:"L10n"}}{% endset %}
|
|
{{accessModifier}} final class {{enumName}} {
|
|
{% if tables.count > 1 %}
|
|
{% for table in tables %}
|
|
{{accessModifier}} final class {{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
|
|
{% call recursiveBlock table.name table.levels " " %}
|
|
}
|
|
{% endfor %}
|
|
{% else %}
|
|
{% call recursiveBlock tables.first.name tables.first.levels "" %}
|
|
{% endif %}
|
|
}
|
|
// swiftlint:enable identifier_name line_length type_body_length
|
|
|
|
extension {{enumName}} {
|
|
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
|
|
return translate(key: key, args)
|
|
}
|
|
}
|
|
|
|
private final class BundleToken {}
|
|
{% else %}
|
|
// No string found
|
|
{% endif %} |