Question

Does anyone know how to go about localizing dynamic variables in code using xamarin.ios? I have this done for static variables. The example below explains more:

//this work
var test = NSBundle.MainBundle.LocalizedString(“Qty 1234”,”test text”);

//what i need is to figure out how to localize the below
var test = "Qty" + aValue; //where aValue is dynamically generated number ex:1,2,3,4,5

Moreover, how would i go about adjusting the monotouch.dialog element to now display right-to-left i.e caption on the left and value on the right (for arabic text)? Thanks in advance.

Was it helpful?

Solution

Use String.Format instead of concatenation:

var test = String.Format(NSBundle.MainBundle.LocalizedString(“Qty {0}”,”test text”), aValue);

This should look for the message "Qty {0}" in your Localized.strings, return the translated format for it, and then the {0} will be replaced by aValue.

Monotouch.Dialog is built on top of UITableView, so the answers to this question ( UITableView support for right to left languages) should apply: You have to write your own UITableViewCells

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top