Token replacement of {values} in strings? #1055
Unanswered
subdigital
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I browsed the string parser source and doesn't look like this is supported, and might be a little tricky to implement. I wanted to gather some suggestions before working on a PR to add this.
Our strings have substitutable tokens in them like this:
Our current code generator (which is showing its age) generates functions for these, and the tokens become the argument names of the function, like this (it's in obj-c, but writing Swift here for simplicity):
I know that Swiftgen supports
%d
and%@
, et. al, natively, but given we have thousands of strings and multiple platforms, that part is not really flexible.I'm wondering if this project would be amenable to a solution like this:
Then modify the parser to find & fill out this tokens array with any instance of
\{[^\}+]\}
it finds.Considerations
types
andtokens
would be a little awkward, but possible.Eager to hear the teams thoughts about a solution like this, or if you have any simpler suggestions to achieve the same result.
✌️
Beta Was this translation helpful? Give feedback.
All reactions