-
Notifications
You must be signed in to change notification settings - Fork 733
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
Strings: support using NSNumber
as variable in stringsdict
#777
base: develop
Are you sure you want to change the base?
Conversation
Hey 👋 I'm Eve, the friendly bot watching over SwiftGen 🤖 Thanks a lot for your contribution! Seems like everything is in order 👍 You did a good job here! 🤝 Generated by 🚫 Danger |
Does Localizable.strings(dict) support |
Yeah, stringsdict supports
With the stringsdict file look like:
|
Since the rest of the SwiftGen is operating based on string format specifier, to avoid huge structural changes and maintain support for normal .strings file (with %@ as normal object), I picked |
Aha, all right, if it works, we probably should support it, cumbersome as it might be 😅 Quick question: does your comment of "allows more precision" actually work though? AFAIK Regarding the actual implementation, I'll try to take a look at it later. I understand the trick you did with ℝ, but I'm hoping I can find something simple specific for the |
|
Shouldn't that be Regardless of that, in general programmers should never pass a Float/Double/... directly into a user-visible Which gets back to my initial point: why pass real numbers to something that expects countable numbers? AFAIK |
Since I agree that in general, user facing numbers should be formatted explicitly to string for the optimal experience. However, given There are situations where the call site cares more about showing the fractional value (like quantity, weight, time) accurately with the correct unit that doesn't necessarily bother with formatting numbers super nicely (like 1 minute / 2.5 minutes, 1 kg / 6.18 kgs). Providing support for |
If we add this, in the Swift templates we should generate something that accepts
Yes. they do. In the case of
Bad examples, for those cases people should use You're glossing over the fact that what'll actually happen is that people will try something like |
Yeah make sense. Originally I thought the Turns out there is a different variant from the superclass
For this, I guess I'm a little unsure when exactly should stringsdict plurals be used directly then? Given it doesn't format integer with desired separator (for
|
NSNumber
as variable in stringsdict
@djbe anything I can do to help moving this forward? while I agree that in most cases it makes sense to use formatters, I do think this can be helpful. Maybe putting it behind a flag would make it less invasive? |
develop
branch (gitflow)develop
as the "base" branch for this Pull Request I'm about to createCHANGELOG.md
file to explain my changes and credit myself(or added
#trivial
to the PR title if I think it doesn't warrant a mention in the CHANGELOG)This PR added the ability to use
%@
inNSStringFormatValueTypeKey
for the stringsdict file. The generated Swift interface will take inNSNumber
which allows localized string to be formatted more accurately when dealing with floating number with high precisions.I wonder if this is something that this project is interested in merging?