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

I18n with react-Intl message in variable expression is different #1021

Closed
kkak10 opened this issue Jan 26, 2018 · 11 comments · Fixed by #1046
Closed

I18n with react-Intl message in variable expression is different #1021

kkak10 opened this issue Jan 26, 2018 · 11 comments · Fixed by #1046

Comments

@kkak10
Copy link

kkak10 commented Jan 26, 2018

Rails I18n variable Expression is %{variable name}, but react-intl variable expression is {variable name}.

Help Please.

@justin808
Copy link
Member

@kkak10 You need to provide many more details and a reproduction case in order for this report to be helpful.

@kkak10
Copy link
Author

kkak10 commented Jan 29, 2018

@justin808 sorry.

details, I use react-on-rails with i18n.
already written rails i18n yml migrate react i18n js

rails i18n yml

rails i18n in variable expression is %{}

label:
  greeting: 'Hello %{name}'

I success migrate yml file to js file
but react-intl varaible expression is {}.

In javascript react-intl

intl.formatMessage({id: 'label.greeting'}, {name: 'justin808'})
// output is '%Hello justin808'

How remove react-intl in '%'?

@justin808
Copy link
Member

@kkak10 if you can write a test case for this, I can look into seeing how we'd fix this.

@kkak10
Copy link
Author

kkak10 commented Feb 6, 2018

@justin808 where is react-on-rails with react-intl example project or github repository?
I ref to that if being example project.

@justin808
Copy link
Member

@kkak10
Copy link
Author

kkak10 commented Feb 13, 2018

https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/config/locales/en.yml

@justin808 react-webpack-rails-tutorial project include feature i18n, but it's not include variable expression in i18n.

I try react-webpack-rails-tutorial project in variable expression i18n. but occur same issue.

@sepehr500
Copy link
Contributor

@justin808 I can make a PR to fix this issue by removing % when it precedes a {. Is this ok?

@justin808
Copy link
Member

@sepehr500 Please submit a PR with tests and a CHANGELOG entry. Can you confirm that you considered the edge cases? @kkak10 any suggestions?

@sepehr500
Copy link
Contributor

sepehr500 commented Mar 13, 2018

@justin808 The only edge case I can think of is if somebody actually wants to have %{ in their yml. I am trying to see if https://github.com/svenfuchs/rails-i18n handles this with an escape char or something like that, but I do not think they do.

@kkak10
Copy link
Author

kkak10 commented Mar 14, 2018

I don't think the edge case that actually have %{ in resource we mentioned above is a problem.

@sepehr500 Thank you! This is what I wanted to do.

@sepehr500
Copy link
Contributor

@justin808 #1046 is ready for review to fix this issue.

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

Successfully merging a pull request may close this issue.

3 participants