Open ArsSirek opened 7 years ago
Could you show the detail of this case? How do you use defaultMessage
method?
Hi, I wrote an example showing my usage, wasn't sure how to provide it, so I forked and added it here in examples folder #10
And there is a branch on that fork, that shows a problem I mentioned in this issue to reproduce you can,
Actually, variables are ignored in the case of using intl.get('something', {foo}).d('something {foo} bar')
, so this seems like a bug, as this call results in 'something {foo} bar'. Kind of meaningless to have defaults if this is the case.
@Panoplos
It should be intl.get('something', {foo}).d(`something ${foo} bar`)
The documentation doesn't mention this.
Or rather, it does in the API section, but why is the default variable tag spec different from the locale data?
We have a script that automatically scrapes out defaults to build the base locale, having these be different requires us to remove the $
.
@Panoplos The defaultMesssage is now ES6 Template literals format. And the locale file is ICU format.
I will make this intl.get('something', {foo}).d('something {foo} bar')
work, too, in next release.
Thanks for the suggestion.
@cwtuan Hi, is there any progress.
@liuyiliuyi After reconsideration, I'd like to remain the current behavior for this API, because this proposal may make break changes.
And you could use react-intl-universal-extract
to extract the text in source code to locale files. It will remove the $
automatically.
Hi, Not sure if it is a bug, but with my usage of extract-intl, I had a case, when the locale message was actually an empty string, so we passed this null check variables had no effect, and the defaultMessage is shown in the end with {variable} as in "locale.json".
I don't know what is a right thing to do, but it seems to me that the desired result would be to have variables inserted into defaultMessage as well.
Thanks!