Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change English numbers to Arabic/Persian representations when a control is being rendered?

Tags:

c#

wpf

English numbers (12345678) and some other symbols like decimal are different in Persian (۱۲۳۴۵۶۷۸۹۰) or (۳/۱ instead of 3.1). I want the language to be optional in my controls.

For example, when I set the TextProperty of a TextBlock to "2345", I want it to be shown both "2345" and "۲۳۴۵", optionally.

Can I change a specific font when controls are being rendered? I mean I override render or some other methods and for example add:

if (char=='5')
{
    char='۵';
}

or is there any other way? thanks;

like image 270
RoN Avatar asked Sep 07 '25 06:09

RoN


1 Answers

I use a simple code which i write:

private string toPersianNumber(string input)
{
   string[] persian = new string[10] { "۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹" };

   for (int j=0; j<persian.Length; j++)
       input = input.Replace(j.ToString(), persian[j]);

     return input;
}
like image 139
Shadmehr Vadoodi Avatar answered Sep 08 '25 20:09

Shadmehr Vadoodi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!