In Windows Phone 7 per localizzare il titolo nell'Application list e l'Application Tile è necessario compilare una DLL di risorse con C++ con Visual Studio 2010. In questo articolo sono descritti i dettagli della procedura How to: Localize an Application Title for Windows Phone.

Se non hai a disposizione una versione completa di Visual Studio 2010 (la Express non permette la creazione di file risorse .rc), puoi usare i seguenti file e compilare a mano.

I passaggi sono
  • Crea una cartella e inserisci i file: AppResLib.vcxproj, AppResLib.rc, resource.h e buid.bat
  • apri il file AppResLib.rc e cambia la descrizione delle due risorse: AppTitle e AppTileString, rispettivamente il titolo nell'Application list e nell'Application Tile
  • compila la DLL con il comando build.bat, che genera il file AppResLib.dll
  • copia la DLL AppResLib.dll nella root del tuo progetto Windows Phone 7
  • copia le DLL AppResLib.dll.0000.mu nella root del tuo progetto Windows Phone 7
  • imposta la proprietà Build Action a Content su tutti i file AppResLib
  • modifica il file WMAppManifest.xml, del tuo progetto, per fargli usare AppResLib.dll (vedi le stringhe @AppResLib.dll,-100 e @AppResLib.dll,-200)

La AppResLib.dll si riferisce alla lingua di default. Per localizzare l'applicazione nelle altre lingue vanno aggiunta altre DLL, assicurandoti di rinominare la AppResLib.dll secondo la seguente lista:
  • English (United Kingdom): AppResLib.dll.0809.mui
  • French (France): AppResLib.dll.040c.mui
  • German (Germany): AppResLib.dll.0407.mui
  • Italian (Italy): AppResLib.dll.0410.mui
  • Spanish (Spain): AppResLib.dll.0c0a.mui
Quindi ogni applicazione avrà nella root, il file AppResLib.dll ed uno o più dei file elencati qua sopra.

Ecco i file necessari per la compilazione:

File: AppResLib.vcxproj

XML

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build"
   ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="AppResLib.rc" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="resource.h" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{3D5992F5-E36A-4526-8F4C-295D3EB07192}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>AppResLib</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LinkIncremental>true</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;APPRESLIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <NoEntryPoint>true</NoEntryPoint>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;APPRESLIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <NoEntryPoint>true</NoEntryPoint>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>

File: AppResLib.rc

C++

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
//#include "afxres.h"
#include "windows.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "\r\n"
    "\0"
END
#endif    // APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////
//
// String Table: le stringhe da modificare per localizzare il titolo
//

STRINGTABLE
BEGIN
    AppTitle                "1 Title for Application list"
END

STRINGTABLE
BEGIN
    AppTileString           "2 Title for Application tile"
END

#endif    // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

File: resource.h

C++

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AppResLib.rc
//
#define AppTitle                        100
#define AppTileString                   200

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        101
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

File: build.bat

DOS / Batch file

REM richede il Framework 4

del AppResLib.dll
%systemroot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release
copy release\AppResLib.dll .

File: WMAppManifest.xml

XML

<?xml version="1.0" encoding="utf-8"?>

<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment"
            AppPlatformVersion="7.0">
  <App xmlns="" ProductID="{00000000-0000-0000-0000-000000000000}"
       ...       
       Title="@AppResLib.dll,-100"
       ...
       >

    ...

    <Tokens>
      <PrimaryToken TokenID="SgartSample" TaskName="_default">
        <TemplateType5>
          ...
          <Title>@AppResLib.dll,-200</Title>
          ...
        </TemplateType5>
      </PrimaryToken>
    </Tokens>
  </App>
</Deployment>
In alternativa al comando build.bat, puoi scaricare Microsoft Visual C++ 2010 Express e seguire L'How to Microsoft. L'unica differenza è che non puoi creare il fire .rc ma dovrai inserire manualmente nel progetto i file AppResLib.rc, resource.h. Fatto questo puoi compilare normalmente il progetto
16/07/2012 Ho trovato questo tool che non richiede Visual Studio WP7 Localize
Tags:
Silverlight7 Windows Phone 710
Potrebbe interessarti anche: