Home > Mobile >  How to know if the strings.xml is the default file?
How to know if the strings.xml is the default file?

Time:11-29

I have 7 strings in the project like this

strings.xml //This is the default
strings.xml (en)
strings.xml (ar)
strings.xml (es)
strings.xml (de)
strings.xml (it)
strings.xml (ru)

And I have JSON in server like this

[
  {
    "default": {
      "Message": "..."
    },
    "en": {
      "Message": "..."
    },
    "ar": {
      "Message": "..."
    },
    "es": {
      "Message": "..."
    },
    "de": {
      "Message": "..."
    },
    "it": {
      "Message": "..."
    },
    "ru": {
      "Message": "..."
    }
  }
]

I want to read the message according to device language but the problem is how to know if the strings.xml is the default file to show default message from JSON?

CodePudding user response:

You can use this method.

In summary, you declare in each strings.xml a string telling which one is currently being used.

  • Related