If you have any Windows Phone 7 apps from the original templates, unlike the Windows Phone 8 app templates they did not come with localization setup already. So lazy me just wrote the strings inline. Fortunately adding localization after updating to Windows Phone 8 is easy.
- Add a Resources folder
- Add new Resources resx to the folder named AppResources.resx
- Ensure Custom Tool is set to PublicResXFileCodeGenerator
- Add a new class named LocalizedStrings to the root of your project
using YourAppNamespace.Resources; namespace YourAppNamespace { /// <summary> /// Provides access to string resources. /// </summary> public class LocalizedStrings { private static AppResources _localizedResources = new AppResources(); public AppResources LocalizedResources { get { return _localizedResources; } } } }
- Add an Application.Resource of your LocalizedStrings class to your App.xaml
<Application.Resources> <local:LocalizedStrings xmlns:local="clr-namespace:YourAppNamespace" x:Key="LocalizedStrings"/> </Application.Resources>
- Add strings in AppResources.resx
- Use localized strings anywhere in your Xaml
CompanyName="{Binding Path=LocalizedResources.CompanyName, Source={StaticResource LocalizedStrings}}"
- To Add other languages and for more details follow How to build a localized app for Windows Phone
Technorati Tags: Windows Phone,Software Development