Comments (6)
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>).
from swiftgen.
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?!).
from swiftgen.
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..
from swiftgen.
The built-in templates support custom lookupFunction
s, so you can do whatever crazy locale stuff you'd like. I would NOT recommend it at all (see @diamid6 comment about inconsistencies), but I know how projects & client requirements work 🤷
Read the template docs here: https://github.com/SwiftGen/SwiftGen/blob/stable/Documentation/templates/strings/structured-swift5.md
from swiftgen.
While that's true, in the end, even when using the lookup function, the last line of the tr
function is always return String(format: format, locale: Locale.current, arguments: args)
. There the result returned from the lookup function is passed to the String(format:locale:)
initializer and the locale that's passed there cannot be changed. This can lead to unexpected behavior in some cases.
from swiftgen.
Ah right, well in that case you should use custom templates (see docs).
from swiftgen.
Related Issues (20)
- Adding Extra parameter when running SwiftGen through Xcode HOT 1
- Error: `swiftgen.yml` is not a config file HOT 4
- String template is not able to generate a function with a string parameter and a plural int HOT 2
- Make `SwiftUI` types the default and not `UIKit` types. HOT 1
- Color Generated with SwiftUI HOT 2
- disable Font typealias? HOT 1
- Addition of .string file changes all previous strings usage HOT 1
- Feature Request: Public access to either the fallback string or the ability to specify locale HOT 2
- Add ability to refer file name of JSON HOT 3
- Support for visionOS HOT 2
- Is this repo deprecated? HOT 4
- Add an XcodeBuiltToolPlugin for swiftgen HOT 5
- [Homebrew] Error: swiftgen has been disabled because it does not build! HOT 10
- Apple privacy manifest support HOT 2
- SwiftGen Errors on Swift 6 HOT 10
- Subsequent builds after first build always fail
- Fatal error: Unable to initialize font
- 'InitialSceneType' requires that 'StoryboardScene.UILoadingViewController' inherit from 'UIViewController'
- Warning: SwiftGen not installed, download it from https://github.com/SwiftGen/SwiftGen HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftgen.