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

Documenting String key enum cases w/ default translation #58

Closed
MrAlek opened this issue Nov 10, 2015 · 2 comments
Closed

Documenting String key enum cases w/ default translation #58

MrAlek opened this issue Nov 10, 2015 · 2 comments

Comments

@MrAlek
Copy link
Contributor

MrAlek commented Nov 10, 2015

Something that xcres has been doing for a while is to document each generated string key with the default translation for that key. That way, you can see the output string when alt-clicking the enum or using auto-complete which is really nice. Currently, the string value isn't exposed as a variable in the strings template engine.

Example input:

"confirmation_alert_title" = "Do you really want to do this action?";
"confirmation_alert_cancel_title" = "Abort";

Desired output:

enum L10n {
  /// Do you really want to do this action?
  case ConfirmationAlertTitle

  /// Abort
  case ConfirmationAlertCancelTitle
}
@AliSoftware
Copy link
Collaborator

That's an interesting addition, and should be pretty easy to add.

The only thing to change in my code is to store the translation, which is already captured here, as an additional property in the Entry struct.
Then, inject that Entry.translation in the Stencil's context here in addition to the key and params keys, so that this translation can be used in the string templates.

Then using that in the default string template would be as simple as inserting /// {{ string.translation }} here.

It would be really nice if you could propose a PR to do those simple changes 😉
(dont forget to fix unit tests accordingly and credit yourself in the CHANGELOG if you do)

@MrAlek
Copy link
Contributor Author

MrAlek commented Nov 10, 2015

Glad you like the idea :) I'll look at the code and send you a PR tomorrow!

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

No branches or pull requests

2 participants