stefalda / ReactNativeLocalization

Class to localize the ReactNative interface
MIT License
898 stars 123 forks source link

Error when providing json on run-time - ReferenceError: key is not defined #194

Open jarnakantaria-gep opened 3 years ago

jarnakantaria-gep commented 3 years ago

My initial json looks like

localization_en-US.js

let myArray = [
{ key: "key1", value: "value1"},
{ key: "key2", value: "value2"}
{ key: "key3", value: "value3"}
{ key: "key4", value: "value4"}
]
    let finalJson = {};
    for (var i = 0; i< enArray.length; i++) {
        finalJson[enArray[i].key] = enArray[i].value
    }
    console.log("en ARR = ", finalJson)

export default finalJson;

I get an error : ReferenceError: key is not defined and the app doesn't open.

I need to provide that enArray json because i am convering csv to json and that key-value is the kind of response I receive. and react-native-localization expects the json in other format, which I am doing via the for loop.

Any solution you can think of? I need to push this to release on immediate basis.

Thank you.