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

intl-get template helper now returns an object instead of just the message string #84

Closed
terryroe opened this issue Mar 25, 2015 · 3 comments · Fixed by #85
Closed

intl-get template helper now returns an object instead of just the message string #84

terryroe opened this issue Mar 25, 2015 · 3 comments · Fixed by #85

Comments

@terryroe
Copy link

We were using intl-get in templates like so:

{{intl-get 'messages.key.otherKey'}}

and it would return the message string.

It appears that this no longer works and intl-get returns an object. We now have to change all our code from above to something like this:

{{format-message (intl-get 'messages.key.otherKey')}}

Was the first example above an intended use of intl-get? Or was it always supposed to be used with format-message?

@jasonmit
Copy link
Member

Correct, intl-get returns an object with a property translation and locale, where the translation derived from. This is to tell the downstream format-message which locale to pass through to the format functions.

What is the use case for using intl-get within your templates outside of format-message/format-html-message? I can make this backwards compat. by overriding toString, but I wasn't aware of people using the helper outside the context of subexpression :)

@terryroe
Copy link
Author

Jason,

We'd discovered that intl-get "worked" without using format-message. It wasn't clear that you "had" to use format-message. The docs didn't really say. Now they do, but it's still not quite clear. Here's the line that mentions it, but the wording of the line doesn't make it as obvious as I think it could: "Will return the message from the current locale, or locale explicitly passed as an argument, message object."

So, it looks like we were using it in an unexpected way, and we just need to do it the correct way with format-message.

Thanks for your help.

TR

@jasonmit
Copy link
Member

Leaving this opened for now to update the docs to be more clear.

Thanks for the good feedback.

Edit: this PR will assert that intl-get is only used as a subexpression and wrote some tests to prevent that regression. #85

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

Successfully merging a pull request may close this issue.

2 participants