On my site, I defined Dictionarywhich returns strings Persianor Englishdepending on the session. Here is the code for my dictionary:
public static string Find_Term(string term)
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("Accommodation Barges", "بارج اقامتی");
dictionary.Add("Bulk Carriers", "فله بر");
dictionary.Add("Barge", "بارج");
dictionary.Add("Cable Layers", "کابل گذار");
dictionary.Add("Cargo Ships", "باربری");
dictionary.Add("Container Ships", "کانتینر بر");
dictionary.Add("Crew Boats", "پرسنل بر");
dictionary.Add("Cruise Ships", "کروز");
dictionary.Add("Dive Boats", "قایق قواصی");
dictionary.Add("Drilling Rigs", "سکوی حفاری");
dictionary.Add("Fishing Boat", "ماهیگیری");
dictionary.Add("Ferries", "فری");
dictionary.Add("Floating Cranes", "کرن شناور");
dictionary.Add("Floating Hotels", "هتل شناور");
dictionary.Add("Glass Bottom Boats", "کف شیشه ای");
dictionary.Add("Hovercraft", "هاورکرافت");
dictionary.Add("Hydrofoils", "Hydrofoils");
dictionary.Add("Ice Breakers", "یخ شکن");
dictionary.Add("Life Boats", "لایف بوت");
dictionary.Add("Landing Craft", "لندینگ کرافت");
dictionary.Add("Life Rafts", "لایف رافت");
dictionary.Add("Passenger Boats", "مسافر بر");
dictionary.Add("Patrol Boats", "گشت");
dictionary.Add("Pilot Boats", "پایلوت بوت");
dictionary.Add("Platforms", "پلتفرم");
dictionary.Add("Research Vessels", "تحقیقاتی");
dictionary.Add("Salvage Ships", "از رده خارج");
dictionary.Add("Supply Boats", "ساپلای بوت");
dictionary.Add("Support Vessels", "ساپورت بوت");
dictionary.Add("Tankers", "تانکر");
dictionary.Add("Tour Boats", "تور");
dictionary.Add("Towboats", "هدایت کننده");
dictionary.Add("Tugs", "یدک کش");
dictionary.Add("Utility Boats", "یوتیلیتی بوت");
dictionary.Add("All Types", "همه نوع");
dictionary.Add("LogIn", "ورود");
dictionary.Add("Register", "ثبت نام");
dictionary.Add("LogOut", "خروج");
dictionary.Add("Home", "صفحه اصلی");
dictionary.Add("News", "تازه ها");
dictionary.Add("Builder", "سازنده");
dictionary.Add("Request this vessel", "درخواست این شناور");
dictionary.Add("Ship Particular", "مشخصات شناور");
dictionary.Add("Build Year", "سال ساخت");
if (HttpContext.Current.Session["Lang"].ToString() == "fa")
{
return dictionary[term];
}
else
{
return term;
}
}
the return string is used for the text attribute of the key elements on the website. for example, as shown below, it works fine on the button located in the repeater:
<asp:Repeater runat="server" ID="vslCat" DataSourceID="SqlDataSource2">
<ItemTemplate>
<asp:LinkButton runat="server" Text='<%# Dict.Find_Term(Eval("vCat").ToString()) %>' PostBackUrl='<%# Request.RawUrl + "?vslCat=" + Eval("vCat") %>' CssClass="ui-btn ui-mini ui-shadow ui-btn-icon-right ui-icon-carat-r"></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
but on the same element outside the repeater it returns nothing without errors !!!
<asp:LinkButton runat="server" Text='<%# Dict.Find_Term("All Types")%>' CssClass="ui-btn ui-mini ui-shadow ui-btn-icon-right ui-icon-carat-r" PostBackUrl="~/Default2.aspx" ID="btnCatAllen"></asp:LinkButton>
<asp:Repeater runat="server" ID="vslCat" DataSourceID="SqlDataSource2">
<ItemTemplate>
<asp:LinkButton runat="server" Text='<%# Dict.Find_Term(Eval("vCat").ToString()) %>' PostBackUrl='<%# Request.RawUrl + "?vslCat=" + Eval("vCat") %>' CssClass="ui-btn ui-mini ui-shadow ui-btn-icon-right ui-icon-carat-r"></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
I do not know what the problem is!!! let me know if you find any clues.