alibaba / react-intl-universal

Internationalize React apps. Not only for Component but also for Vanilla JS.
1.33k stars 154 forks source link

Questions: Is there a way to avoid waring: A message must be provided as a String or AST #107

Closed yuenmadmad closed 5 years ago

yuenmadmad commented 5 years ago

Hello, I was trying to get language data which is an array and try to loop these data into multiple custom react components. It works but have warning message: A message must be provided as a String or AST. How can I get rid of this message OR I can do this by an alternative way. Please inspire me. = =

Thank you!

cwtuan commented 5 years ago

@yuenmadmad Please show me an example reproducing the warning.

yuenmadmad commented 5 years ago

@cwtuan example just created. Not sure if it can be wrote like this, works but have warnings

// App.js
Object.keys(intl.get('common')).map(happy => <div>{happy}</div>)

2019-02-15 1 00 06

cwtuan commented 5 years ago

Should just use intl.get('common.happy1'). Why do you need to loop that?

yuenmadmad commented 5 years ago
{
  "cards": [ 
     {
        "title": "title with diff languages1",
        "imgUrl": "blablabal1.png"
     },
     {
        "title": "title with diff languages2",
        "imgUrl": "blablabal2.png"
     }
  ]
}

Case like slider shd to loop