stefalda / ReactNativeLocalization

Class to localize the ReactNative interface
MIT License
899 stars 124 forks source link

How to get language from an variable? #199

Closed Hameed-asfar closed 3 years ago

Hameed-asfar commented 3 years ago

Hi, I would like to get the language string through a variable, is it possible? or any update available?

            var message_code = "please_fill_all_the_mandatory_fields";
              await this.showSnackbar(strings.message_code)

and my language file

en:{
        please_fill_all_the_mandatory_fields:"Please fill all mandatory fields.",
}

Actually, it looks for the "message_code" value, but I want the value of "please_fill_all_the_mandatory_fields", because i need to get languages dynamically through API response.

Thanks in advance

Hameed-asfar commented 3 years ago

Got the answer need to pass it as array

var message_code = "please_fill_all_the_mandatory_fields";
              await this.showSnackbar(strings[message_code])