An easy way to build a localized app is to use resources file (.resx).
First of all remember to set the default "neutral" language in the project properties! This is an important step because the "AppResources.resx" file is used from all not specified languages.
Add new file, and name it "AppResources.resx" for default language. For a new language, just add a new resource named with the CultureInfo ISO letters:
- AppResources.it-IT.resx for italian language.
- AppResources.cs-CZ.resx for czech language.
- AppResources.fr-FR.resx for french language.
- etc..
Now unload your project and edit the csproj file to add your supported language:
<SupportedCultures>it-IT;en-US;cs-CZ;fr-FR</SupportedCultures>
Create a class to get your resources.
public class LocalizedStrings { private static AppResources localizedResources = new AppResources(); public AppResources Strings { get { return localizedResources; } } }
In your xaml you need to declare your class as resource:
<phone:PhoneApplicationPage.Resources> <local:LocalizedStrings x:Key="LocalizedStrings"/> </phone:PhoneApplicationPage.Resources>
Now you can use your localized string like this:
Text="{Binding Strings.Loading, Source={StaticResource LocalizedStrings}}"Or from code behind:
txtLoading.Text = AppResources.Loading;
To test your app you can insert this code in application launching event:
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("it-IT"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT");
All CultureInfo codes here.
Questo commento è stato eliminato da un amministratore del blog.
RispondiEliminaYou can easily localize the strings of any Windows phone app by using this online software localization tool https://poeditor.com/
RispondiEliminaHello everyone! If you need to explore the market of localization tools, so you can subscribe to a service, I highly recommend reading this article http://aboutlocalization.wordpress.com/2014/09/26/transifex-vs-crowdin-vs-poeditor-vs-get-localization-pricing-comparison/ , because you'll find insights about pricing and useful information.
RispondiEliminaNice blog,thanks for sharing blog with us and you have done a incredible work in this blog to collect the information and i bookmark this blog for the future use.
RispondiEliminaWindows Application Development Services