scelis / twine

Twine is a command line tool for managing your strings and their translations.
Other
840 stars 151 forks source link

Support for string interpolation #258

Closed florianreinhart closed 5 years ago

florianreinhart commented 6 years ago

It would be great to use other keys inside localization strings, e.g.

[APP_NAME]
    en = My Awesome App
[THANK_YOU_TEXT]
    en = Thank you for using \(APP_NAME)
[RATING_TEXT]
    en = Rate \(APP_NAME)

The generated .strings file should look like this:

"APP_NAME" = "My Awesome App";
"THANK_YOU_TEXT" = "Thank you for using My Awesome App";
"RATING_TEXT" = "Rate My Awesome App";

The interpolation syntax is taken from Swift. We could also use ${KEY} or something else.

sebastianludwig commented 6 years ago

Hello @florianreinhart, thank you for taking the time to open an issue with your suggestion!

A few random thoughts:

scelis commented 6 years ago

Thanks for the suggestion! My gut says this might be a bit of feature bloat, especially when you consider how this would affect localization and translation efforts using the standard twine workflows. You can already kinda do this by using a bit of code and string formatting.

[APP_NAME]
    en = My Awesome App
[THANK_YOU_TEXT]
    en = Thank you for using %@
[RATING_TEXT]
    en = Rate %@
let appName = NSLocalizedString("APP_NAME")
let text = NSLocalizedString("THANK_YOU_TEXT", appName)