Skip to content
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

[SwiftGen-L10n] Manage positional placeholders (like %2$@) #6

Closed
AliSoftware opened this issue Jul 22, 2015 · 5 comments
Closed

[SwiftGen-L10n] Manage positional placeholders (like %2$@) #6

AliSoftware opened this issue Jul 22, 2015 · 5 comments

Comments

@AliSoftware
Copy link
Collaborator

As in some languages the various texts are not always in the same order, it's not that rare to have positional placeholders like %2$@ in the Localizable.strings strings representing formats.

We need to be able to handle them properly, by storing the associated type at the right position in the [PlaceholderType] array.

Also check the official rules used by printf for that (like what about %3$@ %2$f %@, does the last %@ use the parameter at index 3 because it's incrementing the position from the last positional character encountered (2+1)? or do it use the first parameter? What are the official rules already?)

AliSoftware added a commit that referenced this issue Aug 2, 2015
…o next level by switching to NSRegularExpression and parse positional specifiers "%n$x")

+ Added associated unit tests

Fix #4, #5, #6
@NachoSoto
Copy link

If I understand this correctly, it should be possible to have the same parameter multiple times, right?
For example:

Text: %1%@; %1%@.

Right now that generates a function with two parameters, but I would expect only one. Can you confirm that's a bug? If so I'll file a separate issue :)

@AliSoftware
Copy link
Collaborator Author

I'd also expect the resulting enum to have only one parameter in such a situation indeed! Good catch

@AliSoftware
Copy link
Collaborator Author

Wait the printf-std syntax is actually %1$@ not %1%@. I thought that was an error when copying your example into the issue but in fact maybe that's why you get that result?

@NachoSoto
Copy link

Yup, I got the syntax wrong! My bad.

@AliSoftware
Copy link
Collaborator Author

Well to be fair this syntax is a little RegEx-like and confusing ^^ what an ugly standard/convention in the first place, thank you C legacy ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants