If you use EPiServer lang-files (in the /lang/ folder) you can access the translations with LanguageManager.Instance.Translate("/general/item1").
if you add
<general>
<welcometext>Welcome to {0}. We have {1}, {2} and {3}. Help yourself!</welcometext>
....
</general>
then I would expect this to work
string message = string.Format(Translate("/general/welcometext"), Translate("/general/storename"), Translate("/general/item1"),Translate("/general/item2"), Translate("/general/item3"));
Thanks alot! Final solution;
protected void Page_Load(object sender, EventArgs e)
{
SetWelcomeText();
}
public void SetWelcomeText() {
string message = LanguageManager.Instance.Translate("/general/item1");
string output = string.Format(LanguageManager.Instance.Translate("/general/infotext"), message);
FancyMainContentTextLiteral.Text = output;
}
ascx;
<asp:Literal runat="server" id="FancyMainContentTextLiteral" />
Hi!
My problem is as follows: I have an .xml file (english.xml) that contains the following nodes,
<general>
<storename>Wendie's</storename>
<item1>French Fries</item1>
<item2>Hamburger</item2>
<item3>Soda</item3>
</general>
What i'd like to do is to have a welcome text when I arrive to my site that says: "Welcome to Wendie's. We have French Fries, Hamburger and Soda. Help yourself!" I'd also like to have it globalized, which means this text has to be inserted into my english.xml, prefferably in a <welcometext>-node or something. How can I accomplish this? My first thought was to use String.Format like:
"Welcome to {0}. We have {1}, {2} and {3}. Help yourself!" and have the numbers represent different nodes in my xml, and thus making it globalized. But how can I accomplish this?
Thanks alot!