Last active
October 22, 2015 20:57
-
-
Save SCullman/e3359dd41b889018760d to your computer and use it in GitHub Desktop.
DNN, ko and localization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var resources = <%=Resources%>; | |
var viewModel = {localize:resources}; | |
ko.applyBindings(viewModel); | |
</script> | |
<span data-bind="text:localize.Message"></span> | |
<span data-bind="text:localize.Message_Help"></span> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
protected string Resources | |
{ | |
get | |
{ | |
using (var rsxr = new ResXResourceReader(MapPath(LocalResourceFile + ".ascx.resx"))) | |
{ | |
var res = rsxr.OfType<DictionaryEntry>() | |
.ToDictionary( | |
entry => entry.Key.ToString().Replace(".Text", "").Replace(".", "_"), | |
entry => DotNetNuke.UI.Utilities.ClientAPI.GetSafeJSString( | |
LocalizeString(entry.Key.ToString()))); | |
return JsonConvert.SerializeObject(res); | |
}; | |
} | |
} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<root> | |
<data name="Message.Help" xml:space="preserve"> | |
<value>Help us to save the world</value> | |
</data> | |
<data name="Message.Text" xml:space="preserve"> | |
<value>Hello World</value> | |
</data> | |
</root> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment