I have two resource file Resource.resx and Resource.ar.resx with the same keys but different english and arabic data in the following code the text in the is working fine showing english and arabic data with the change in the dropdownlist while the text of the save button always shows English not arabic
</tr>
<tr>
<td><span><%=Resources.Resource.Citations%></span></td>
<td>
<input runat="server" id="taCitations" type="number" style="width: 600px;" /></td>
</tr>
</table>
<asp:Button ID="btnSave" runat="server" Text="<%$Resources:Resource, Save%>" CssClass="btn" OnClick="btnSave_Click" />
I have a dropdownlist in master page
<asp:DropDownList ID="ddlLang" runat="server" AutoPostBack="true">
<asp:ListItem Text="English" Value="en-US">
<asp:ListItem Text="Arabic" Value="ar-sa" />
</asp:DropDownList>
and my work to change language is in preRender of the master page
protected void Page_PreRender(object sender, EventArgs e)
{
if (Request.Form["__EVENTTARGET"] != null && Request.Form["__EVENTTARGET"].Contains("ddlLang"))
{
//Set the Language.
Language = Request.Form[Request.Form["__EVENTTARGET"]];
}
if (Language == "en-US")
{
Body.Attributes["dir"] = "ltr";
tdAppParticulars.Attributes["align"] = "right";
}
else
{
Body.Attributes["dir"] = "rtl";
tdAppParticulars.Attributes["align"] = "left";
}
Thread.CurrentThread.CurrentCulture = new CultureInfo(Language);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(Language);
List<ExtFormInstruction1> lefi = bal.ExtFormInstructionByType("External Reviewers");
formInstructions = new Hashtable();
formIDs = new Hashtable();
string currentItemURL = "";
foreach (ExtFormInstruction1 row in lefi)
{
string itemURL = row.Page;
formInstructions[row.Page] = Language == "ar-sa" ? "" : row.Instruction;
formIDs[row.Page] = row.FormID;
if (Language == "en-US")
{
lblPageTitle.Text = row.Title;
}
else if (Language == "ar-sa")
{
lblPageTitle.Text = bal.GetFormByPage(row.Page.Replace(".aspx", "Ar.aspx"))[0].Title;
}
}
MakeMenu(Language);
if (IsPostBack)
{
return;
}
lblApplicantEmail.Text = bal.GetApplicant(ApplicationID)[0].NameString;
lblEmployee.Text = erBAL.GetExtRevByID(ExtReviewerID)[0].Name;
/* printer friendly */
if (Utils.IsPrintMode())
{
tdLeftMenu.Visible = false;
lnkPrint.Visible = false;
}
lnkPrint.NavigateUrl = currentItemURL + "?print=1";
}
the Language is a property in master page
public string Language
{
set
{
Session["Language"] = value;
}
get
{
if (Session["Language"] != null)
{
return Session["Language"].ToString();
}
else
{
return "en-US";
}
}
}
I would rather do it like this:
And in the Resource.resx file, the entries will be like
Similarly in Resource.ar.resx file