Closed mgorbach closed 8 years ago
That's a great idea! :+1: In fact I use that convention with dots too and I agree that would be cool :sunglasses:
Note: I'm a little busy atm so even if it would be a cool to have this feature, I'll probably not be my top priority and I'll probably not implement it very soon. But don't hesitate to start a PR to try it, I'll still be around to help on the implementation if needs be :wink:
@mgorbach: Until this is implemented, you might want to check out https://github.com/JiriTrecak/Laurine which does exactly what you need. It doesn't support the images, colors etc. though – only Localizations. I'm currently using swiftgen for everything except Localizations alongside Laurine for exactly this reason.
Taking a pass at this now.
Laurine seems to be a little slowish and also not really maintained any more. Therefore I'd like this feature to be added to SwiftGen and plan to help getting it done when I have some time. Note that I'm using the uppercase variant of @mgorbach's suggested structure with underscores instead of dashes as separators. I'll try to make both variants convert to respective sub structures when I start implementing this. Stay tuned. You can expect first results within the next few weeks.
:+1:
As promised I implemented one approach to tackle this issue. See #148 for additional details. Please note that i think we can release this much earlier than in v2.0.0 (which it is marked for right now) as my implementation doesn't break any existing features (or at least shouldn't – tests are passing, too).
This is now merged (and will be in next release) thanks to the work by @Dschee in #148 but as explained in https://github.com/AliSoftware/SwiftGen/pull/148#issuecomment-229018218 that work is only the first working step, providing a template that generates nested structs.
I hope people are gonna get inspired from the work done by @Dschee to add more templates in the future, for example some structured templates based on structs
instead of enums
(to be able to use dot chain instead of nested chain) and propose some other template variants depending on how they want the generated code to look in their projects 👍
In our app, we use structured identifiers as the string keys for localizable strings, such as
error.title.password-required
. Before integratingswiftgen
, we structured these ourselves intostruct
or orenum
definitions that had a hierarchy, i.e. one forerror
, one fortitle
. It would be great ifswiftgen
could do the same thing and pick up the structure from dot-delimited string keys.