Hello,
here is a particular localization scenario i'm not sure how to handle with default localization feature:
App base language is english, translation is french.
1) On app load, swift will pick up 6 random items from a strings array of 100 items.
2) It will display each of those 6 strings on 6 user interface buttons.
3) User will tap on a button: string value is sent back into app.
Here is the problem:
4) App will do processing with this value. Problem is that all internal processing from that values that went out from the array on user interface then back in app, is all done with english values. In particular that user choice is saved in external database, and I can't have saved in database localized versions: all internal processing on array values in english.
How best to handle this situation?
Is it possible from a localized french VALUE, to get corresponding VALUE in base language?
If yes how?
Or should I build my own thing for those cases when random values goes out on UI, then back in app... like an array of tuples containing translated items?
here is a particular localization scenario i'm not sure how to handle with default localization feature:
App base language is english, translation is french.
1) On app load, swift will pick up 6 random items from a strings array of 100 items.
2) It will display each of those 6 strings on 6 user interface buttons.
3) User will tap on a button: string value is sent back into app.
Here is the problem:
4) App will do processing with this value. Problem is that all internal processing from that values that went out from the array on user interface then back in app, is all done with english values. In particular that user choice is saved in external database, and I can't have saved in database localized versions: all internal processing on array values in english.
How best to handle this situation?
Is it possible from a localized french VALUE, to get corresponding VALUE in base language?
If yes how?
Or should I build my own thing for those cases when random values goes out on UI, then back in app... like an array of tuples containing translated items?
You may have another way (I do not recommend, but it will require less change to your code).Is it possible from a localized french VALUE, to get corresponding VALUE in base language?
When you get the answer (in French or whatever language), build the array of localized strings from original array
Code Block let localizedStrings = originalArray.map() { NSLocalizedString($0, comment: "") }
Search for the answer and get the base string
Code Block var baseAnswer = "" if let index = localizedStrings.firstIndex(of: answer) { baseAnswer = originalArray[index] }
Do what you need with baseAnswer