When changing my app’s language to Arabic, for instance, numeric input no longer follows Western formatting (e.g., 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 with a comma decimal separator as in Italy), but appears as ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩. My app’s language is correctly set to “ar”.
string savedLanguage = Preferences.Get(LanguageKey, string.Empty);
if (!string.IsNullOrEmpty(savedLanguage))
{
CultureInfo.CurrentCulture = new CultureInfo(savedLanguage);
CultureInfo.CurrentUICulture = new CultureInfo(savedLanguage);
}
else
{
CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
}
However, I encounter an error when attempting to save an integer or double:
int number = Convert.ToInt32(txtNumber.Text);
The error message reads:
The input string ‘١١’ was not in a correct format
How can I solve the problem in a scalable way for all languages??
Andrea Salvatore is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1