New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to change Locale #1095
Comments
I was just about to ask the same question. If an app has its own sense of how to localize their strings, I wonder if its correct that the String init from above gets the current locale as parameter. Apple is also not very specific about what happens with that locale (considering my format string has some string placeholders, I assume nothing will happen, but not sure about other types than strings?!). |
Locale affects the rule for plurals in Localized.stringdict. You may check it with two locales which has different cases for one, two, many, other. If I change locale in runtime without changing in Settings App, Locale.current is still will be the same. This can lead to incorrect string format as the result because for definition the correct plural case will being use Locale.current but not Locale(identifier: <new_locale_identifier>). |
Ah yeah, that makes total sense! Our app has its own sense of localization and I assume that will likely break if the OS locale is different from the one of the app, which makes that lookup function a little useless for us now. I know we can always create our own template, but that would be much nicer thb.. |
The built-in templates support custom Read the template docs here: https://github.com/SwiftGen/SwiftGen/blob/stable/Documentation/templates/strings/structured-swift5.md |
While that's true, in the end, even when using the lookup function, the last line of the |
Ah right, well in that case you should use custom templates (see docs). |
Could you please advise me, how can I change Locale.current here:
`private static func tr(_ table: String, _ key: String, _ args: CVarArg..., fallback value: String) -> String {
let format = BundleToken.bundle.localizedString(forKey: key, value: value, table: table)
return String(format: format, locale: Locale.current, arguments: args)
}`
The text was updated successfully, but these errors were encountered: