Search code examples
c#cultureinfoculturehebrewright-to-left

can I get the text direction from the culture code?


If I have the culture code for a country/language combination, is it possible to from this, find the text direction.

For example for en-US how can I get from this that the text direction is left to right? And in turn from ar-EG, how do I know the text direction is right to left?


Solution

  • This can easily be done using the TextInfo.IsRightToLeft property of CultureInfo

    Example:

    CultureInfo.GetCultureInfo("ar-EG").TextInfo.IsRightToLeft; // Return True
    CultureInfo.GetCultureInfo("en-us").TextInfo.IsRightToLeft; // Return False
    CultureInfo.GetCultureInfo("he-il").TextInfo.IsRightToLeft; // Return True