Albert Gao
Albert Gao

Reputation: 3769

Why VS2012 doesn't create new language file for me?

What I want:
add new languages support for my windows phone app

What I refer:
MSDN:http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff637520(v=vs.105).aspx
The Document say:

Visual Studio has created a new resource file for each supported language that is a copy of the neutral resource file (AppResources.resx) and renamed it to include the locale code that reflects the new resource file’s Culture.

What happened?
After I add new languages in the project properties windows,and I save and build the solution. Nothing happened.....

Why and how to solve it?

Upvotes: 0

Views: 183

Answers (1)

Johan Falk
Johan Falk

Reputation: 4359

Unfortunatly the automatic generation of the AppResources.resx files only seems to work for Windows Phone 8 apps. For Windows Phone 7 apps you have to do it all manually. This is how to localize your app in Windows Phone 7:

Step 1: Choose languages in "Supported Cultures" in project properties (same as for WP8)

Step 2: Right click on project in solution explorer -> Add -> New Item...

Step 3: Select the type Resources File and name it AppResources.resx

Step 4: Open the AppResources.resx file and change the Access Modifier to Public:

enter image description here

Step 5: Repeat step 2, 3, and 4 for every other language you want to use, naming the file AppResources.<culture>.resx, for example AppResources.sv.resx for Swedish.

Step 6: Create a class named "LocalizedStrings.cs" with the following code:

public class LocalizedStrings
{
    private static AppResources _localizedResources = new AppResources();

    public AppResources AppResources
    {
        get { return _localizedResources; }
    }
}

Step 7: Open App.xaml, and add the following to <Appllication.Resources>:

<Application.Resources>
    <local:LocalizedStrings x:Key="LocalizedStrings" />
</Application.Resources>

Step 8: You can now use the translations in the following way:

<TextBlock Text="{Binding AppResources.Title, Source={StaticResource LocalizedStrings}}" />

Where Title is the Name column in the AppResources.resx files.

enter image description here

Upvotes: 1

Related Questions