Binding string from Resources.resjson in ListView template
-
01 Ağustos 2012 Çarşamba 12:05
Hello,
I have a ListView with some template (in this case it's a group header). I bind the p textContent to the underlying list item.
<div class="headerTemplate" data-win-control="WinJS.Binding.Template"> <p class="group-title win-type-x-large" data-win-bind="textContent: title WinJS.Binding.oneTime; groupKey: key WinJS.Binding.oneTime" onclick="WinJS.Navigation.navigate('/pages/groupDetail/groupDetail.html', { groupKey: event.srcElement.groupKey })" role="link"> </p> </div>
Now I began localizing my app so what I need to do is to bind the localized group header title from the resources file. How can I do that, i.e. reference the data item and resource label at the same time?
Thanks
Tüm Yanıtlar
-
03 Ağustos 2012 Cuma 09:43Moderatör
Hi
To help localize a Metro style app, you can add one or more Resources File item templates (.resjson files) to your project.
For more info, see Globalizing your app, it provide a best practice scenario to globalize and localize your Metro style app.
Hope it helpful.
-
03 Ağustos 2012 Cuma 09:48
Hi,
I already have .resjson file and I'm able to successfully bind static text. But what about binding inside a ListView template? Let's say my datasource contains strings like "LABEL_1" and "LABEL_2", and I'd like to bind these identifiers to resource file so that user eventually sees "LABEL_1" and "LABEL_2" in his own language.
Hope I didn't complicate it too much ;) Thanks.
-
06 Ağustos 2012 Pazartesi 11:09Moderatör
Hi
You should have different language Datasource.
If you use a web service, you need to provide each language version.
For example you request data from a web service, request string is:
var userInputLanguage = Windows.Globalization.Language.currentInputMethodLanguageTag;
var requestStr = "http://www.webservice.net/json.aspx?";
requestStr+="language="+userInputLanguage;
If your current input language is US English this requestStr will be http://www.webservice.net/json.aspx?language=en-us
Then do the binding as usual.
If you use Other data source you can also refer to this experience.
Here is a example about Listview working with datasource and another example about Application resources and localization sample.
- Yanıt Olarak İşaretleyen Docentus 06 Ağustos 2012 Pazartesi 12:22
-
06 Ağustos 2012 Pazartesi 12:23
Hi,
Seems reasonable to have a language distinction in the datasource, thanks for the tip :)
Regards