0

I'd like to refer multi-language locale data of same keys in my React code. How to do that?

For example, in another scheme like Ruby on Rails, we can fetch expected locale data as below:

I18n.available_locales.map { |locale| I18n.t('hello', locale: locale) }

In the case above, when I18n.available_locales equals to ['en', 'ja'], then we can fetch English and Japanese locale data of same key.

In react-intl, IntlProvider component already has context for locale (like en or ja) so I wonder how can I do that.

Regards,

bekkou68
  • 802
  • 1
  • 9
  • 20
  • react-intl application stores the language in context; you can write code in the root component to change locales; why do you need to display multi locale at a time? – Deadfish Aug 08 '16 at 07:01
  • yeah I know we can simply change display locale in root component when we'd like to switch language. but in this case, I'd like to use multi-language locale data for validating some reserved words of model and the reserved words are multi-language locale data. – bekkou68 Aug 08 '16 at 11:55
  • a bit off topic but we use http://reactrb.org and then use i18n-js gem to get the locale info onto the client. – Mitch VanDuyn Aug 11 '16 at 16:17

0 Answers0