protected void Page_Load(object sender, EventArgs e)
{
mapResFileName = "MapResources.en-US.resx";
mapResFileName = "MapResources.en-US.resx";
if (m_UserLanguage == "ar")
{
mapResFileName = "MapResources.resx";
}
ClientScript.RegisterStartupScript(this.GetType(), "localizedString",
getReourseFileAsJSON(mapResFileName), true);
}
public string getReourseFileAsJSON(String resourceFileName)
{
try
{
string mapResString = "localizedString={'userLang':'" + m_UserLanguage + "',";
ResXResourceReader rsxr = new ResXResourceReader(
String.Format("{0}{1}\\{2}", System.AppDomain.CurrentDomain.BaseDirectory.ToString(), "App_GlobalResources", resourceFileName));
foreach (DictionaryEntry d in rsxr)
{
mapResString += "'" +
d.Key.ToString() + "':'" + d.Value.ToString() + "',";
}
mapResString += "};";
return mapResString;
}
catch (Exception exc)
{
return "File Not Found";
}
}
No comments:
Post a Comment