Search code examples
ioscocoa-touchlocalizationdynamic-data

Localise an iOS app using information obtained at runtime


I have a weird requirement where all my data to be displayed in the app is coming from a remote server. The data consists of simple text, numbers, dates and prices. Now, had all this data been static, the task was simple but here the problem is that the data is dynamic (coming from the server) and also the app has to be localised in at least 20 languages. The biggest challenge is to convert the price values into user selected currencies on his device settings on the run.


Solution

  • For currency conversion, you can use the Yahoo API. Examples can be seen in this StackOverflow question.

    http://finance.yahoo.com/currency-converter/#from=USD;to=EUR;amt=1

    This url format could be used to fetch conversion rates in different formats.

    http://download.finance.yahoo.com/d/quotes.csv?s=AUDUSD=X&f=nl1d1t1

    Substitute quotes.csv with appropriate format and parameters with the required codes

    As far as localization of your text coming from the server, that's a much more difficult problem. I think it would be very difficult to translate this "on the fly". The correct solution is to include the language in the request and have the server return any text in the requested language.

    I guess another approach you could take (which may not be feasible depending on how many different strings you are dealing with) is enumerate all the possible strings returned from the server. Then take the more traditional approach of having these strings translated and included in your app.