how to implement localization in React-native app

114 Views Asked by At

I want to implement localization in my React Native project , I know I can use i18n but My translation file is little different as bellow. I am not sure how to implement this. These files are being used in my Angular website and I am trying to use the same in my React native App, So I can not change bellow files.

en.json

[
    {
        "term": "modal.alert.close",
        "definition": "Close",
        "context": "",
        "term_plural": "",
        "reference": "",
        "comment": ""
    },
    {
        "term": "has-expired",
        "definition": "<ph name=\"INTERPOLATION\"><ex>{{alert.uniqueId}}<\/ex>{{alert.uniqueId}}<\/ph> has expired.",
        "context": "",
        "term_plural": "",
        "reference": "",
        "comment": ""
    },

]

 

de.json

[
    {
        "term": "modal.alert.close",
        "definition": "Schlie\u00dfen",
        "context": "",
        "term_plural": "",
        "reference": "",
        "comment": ""
    },
 {
        "term": "has-expired",
        "definition": "<ph name=\"INTERPOLATION\"><ex>{{alert.uniqueId}}<\/ex>{{alert.uniqueId}}<\/ph> ist abgelaufen.",
        "context": "",
        "term_plural": "",
        "reference": "",
        "comment": ""
    },
]
1

There are 1 best solutions below

0
On
"definition": "<ph name=\"INTERPOLATION\"><ex>{{alert.uniqueId}}<\/ex>{{alert.uniqueId}}<\/ph> has expired.",

above string contains different syntax which is extracted by Angular i18n. so it is not supported by react native i18n parser yet.

for this scenario you have to use extractor which are available for react native.