Anas Ghanem

<ItemTemplate ".Net Tips" runat="Weblogs.asp.net" Country="WestBank" />

Automaticly detects the alignemt of the active culture

This is a simple class which automaticly detects the alignemt of the active culture ( "right to left" or "left to right")

public class LangugesAlignHelper

{ //' Check the Current Culture public static bool IsRightToLeft()

{

return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft;

}

// retrun the string representation of the current language alignment

public static string GetCultureAlignString()

{

if (IsRightToLeft()){ return "rtl"; }

else { return "ltr"; }

}

public static string CurrentCultureAlign { get { return GetCultureAlignString(); }

}

}


 

This is an example on how to use the mentioned class to set the document aligment based on the current culture,

<html  dir='<%= LangugesAlignHelper.CurrentCultureAlign %>' >

 

Hope it helps

Anas Ghanem

Posted: Jun 23 2008, 10:48 AM by anas | with no comments
Filed under: ,

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)