Posted on 05/11/2014 17:06:30
Dynamicweb 8.6 will have a public API for getting (and creating) translations. Until then, you can use a function like this to get a translation from a Translation.xml file
string GetTranslation(string key, string culture) {
var path = System.Web.HttpContext.Current.Server.MapPath("~/Files/Templates/Designs/Translations.xml");
var doc = new System.Xml.XPath.XPathDocument(path);
var navigator = doc.CreateNavigator();
var node = navigator.SelectSingleNode("/translations/key[@name='"+key+"']/translation[@culture='"+culture+"']");
return node != null ? node.Value : null;
}
In a real application you'll probably want to cache the translations, but the function above shows the general idea.
Best regards,
Mikkel