2

I am using Chinese in my app. I have made a Localizable.string file in English and one in Chinese.

I am doing it OK, and everything is working fine, but there are some string responses from the server. How can I convert them?

For example, "Account not found" comes from the server. How can I show it in Chinese in the app, because it is not defined in Localizable.string?

I could use an 'if' condition to check the response, but what do I do if the server can respond in several several different ways?

If something is not clear from my question, then please ask in the comments. I will be pleased to clarify the question.

Thank you

Robin Summerhill
  • 13,695
  • 3
  • 41
  • 37
Chatar Veer Suthar
  • 15,541
  • 26
  • 90
  • 154

1 Answers1

0

Ideally, the server you depend on should return error codes rather than display text. Then your app (or the front-end in general) should map these error codes into display text in the appropriate language.

There are cases where this may not be possible. If this is what you have, i.e. if the server is meant to include display text in its responses, then really the only reliable way to solve this is to make the server's display text localizable. You should include a language identifier (or an accept-language list) in the requests and the server should make use of its own localized resources to return localized display text in its responses.

Clafou
  • 15,250
  • 7
  • 58
  • 89