You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone 馃憢
In my project we use SwiftGen (SwiftGen v6.6.2 (Stencil v0.15.1, StencilSwiftKit v2.10.1, SwiftGenKit v6.6.2)) and Lokalise.
I am trying to make plural translations generated from Lokalise work with SwiftGen. I know that SwiftGen does not support plural keys such as the following:
<key>some.translation</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@format@</string>
<key>format</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>li</string>
<key>one</key>
<string>Some %1$@ text %3$@ with 2 arguments</string>
<key>other</key>
<string>Some %1$@ text %2$li with 3 - %3$@ - arguments</string>
</dict>
</dict>
but, unfortunately, we have bunch of these. At the moment, such a translation leads to code such as this:
This is obviously wrong therefore, I've written my own template, which detect plurals based on the SwiftGen implementation detail - each plural is preceded by a "Plural format key". In short, I ended up with the generated code looking like this:
but this is not an ideal solution either. Firstly, developers need to be constantly aware of what types and in what order the translation accepts, and secondly, the whole approach relies on implementation details. Therefore, I have 3 questions:
Would it make sense to add a Boolean flag or other tag to make the templates know which key is plural or singular?
Are there any plans to support this type of plural out of the box? Lokalise is a fairly popular translation management service, so I expect this is a common problem.
What's your opinion about this in general? Do you recommend any other approach?
The text was updated successfully, but these errors were encountered:
I'm also facing a similar issue where the fallback for stringsdict isn't working as expected. In swiftgen official README example, it shows that the fallback shouldn't be "Pural format key ....". Here is the example from swiftgen.
internal enum L10n {
/// Some alert body there
internal static let alertMessage = L10n.tr("Localizable", "alert__message", fallback: #"Some alert body there"#)
/// Title for an alert
internal static let alertTitle = L10n.tr("Localizable", "alert__title", fallback: #"Title of the alert"#)
internal enum Apples {
/// You have %d apples
internal static func count(_ p1: Int) -> String {
return L10n.tr("Localizable", "apples.count", p1, fallback: #"You have %d apples"#)
}
}
internal enum Bananas {
/// A comment with no space above it
internal static func owner(_ p1: Int, _ p2: Any) -> String {
return L10n.tr("Localizable", "bananas.owner", p1, String(describing: p2), fallback: #"Those %d bananas belong to %@."#)
}
}
}
Hello everyone 馃憢
In my project we use SwiftGen (
SwiftGen v6.6.2 (Stencil v0.15.1, StencilSwiftKit v2.10.1, SwiftGenKit v6.6.2)
) and Lokalise.I am trying to make plural translations generated from Lokalise work with SwiftGen. I know that SwiftGen does not support plural keys such as the following:
but, unfortunately, we have bunch of these. At the moment, such a translation leads to code such as this:
This is obviously wrong therefore, I've written my own template, which detect plurals based on the SwiftGen implementation detail - each plural is preceded by a "Plural format key". In short, I ended up with the generated code looking like this:
but this is not an ideal solution either. Firstly, developers need to be constantly aware of what types and in what order the translation accepts, and secondly, the whole approach relies on implementation details. Therefore, I have 3 questions:
The text was updated successfully, but these errors were encountered: