Added swiftgen step for generating strings that won't be exposed to Weblate but still part of VectorL10n.

This commit is contained in:
Stefan Ceriu
2022-02-28 09:34:37 +02:00
committed by Doug
parent 3c496db894
commit bf8ae6328f
5 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
/*
Copyright 2015 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/** General **/
"Untranslated test" = "Untranslated test";

View File

@@ -0,0 +1,19 @@
// swiftlint:disable all
// Generated using SwiftGen, by O.Halligon https://github.com/SwiftGen/SwiftGen
import Foundation
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
// MARK: - Strings
// swiftlint:disable function_parameter_count identifier_name line_length type_body_length
public extension VectorL10n {
/// Untranslated test
static var untranslatedTest: String {
return VectorL10n.tr("Untranslated", "Untranslated test")
}
}
// swiftlint:enable function_parameter_count identifier_name line_length type_body_length

View File

@@ -90,6 +90,7 @@ targets:
- path: Assets/en.lproj/InfoPlist.strings
- path: Assets/en.lproj/Localizable.strings
- path: Assets/en.lproj/Vector.strings
- path: Assets/en.lproj/Untranslated.strings
- path: Assets/eo.lproj/InfoPlist.strings
- path: Assets/eo.lproj/Localizable.strings
- path: Assets/eo.lproj/Vector.strings

View File

@@ -0,0 +1,64 @@
// swiftlint:disable all
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen
{% if tables.count > 0 %}
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
import Foundation
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
// MARK: - Strings
{% macro parametersBlock types %}{% filter removeNewlines:"leading" %}
{% for type in types %}
_ p{{forloop.counter}}: {{type}}{{ ", " if not forloop.last }}
{% endfor %}
{% endfilter %}{% endmacro %}
{% macro argumentsBlock types %}{% filter removeNewlines:"leading" %}
{% for type in types %}
{% if type == "UnsafeRawPointer" %}
Int(bitPattern: p{{forloop.counter}})
{% else %}
p{{forloop.counter}}
{% endif %}
{{ ", " if not forloop.last }}
{% endfor %}
{% endfilter %}{% endmacro %}
{% macro recursiveBlock table item %}
{% for string in item.strings %}
{% if not param.noComments %}
/// {{string.translation}}
{% endif %}
{% if string.types %}
{{accessModifier}} static func {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String {
return {{className}}.tr("{{table}}", "{{string.key}}", {% call argumentsBlock string.types %})
}
{% else %}
static var {{string.key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}: String {
return {{className}}.tr("{{table}}", "{{string.key}}")
}
{% endif %}
{% endfor %}
{% for child in item.children %}
{% call recursiveBlock table child %}
{% endfor %}
{% endmacro %}
// swiftlint:disable function_parameter_count identifier_name line_length type_body_length
{% set className %}{{param.className|default:"L10n"}}{% endset %}
{{accessModifier}} extension {{className}} {
{% if tables.count > 1 %}
{% for table in tables %}
{{accessModifier}} class {{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
{% filter indent:2 %}{% call recursiveBlock table.name table.levels %}{% endfilter %}
}
{% endfor %}
{% else %}
{% call recursiveBlock tables.first.name tables.first.levels %}
{% endif %}
}
// swiftlint:enable function_parameter_count identifier_name line_length type_body_length
{% else %}
// No string found
{% endif %}

View File

@@ -16,6 +16,13 @@ strings:
params:
className: VectorL10n
publicAccess: true
- inputs: Assets/en.lproj/Untranslated.strings
outputs:
templatePath: Templates/Strings/flat-swift4-vector-untranslated.stencil
output: UntranslatedStrings.swift
params:
className: VectorL10n
publicAccess: true
- inputs: Modules/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings
outputs:
templatePath: Templates/Strings/matrixkit-flat-swift4-vector.stencil