Language Packs


We have already looked at resources for localizing Web Parts, features, and site definitions. Language packs for solution packages enable the deployment of localized resources based on installed resources. Language pack solutions share the same Name and SolutionId as the core solution package, but they include only localized resources and are identified to STSADM by the -lcid switch. For example, for the LitwareWebParts.wsp package, we can create a LitwareWebParts.wsp package in an en-US folder with the same solution name and GUID identifier as the LitwareWebParts.wsp package. It will contain only the Resource files required for the localized solution. Listings 9-5 through 9-8 display the Litware Web Parts language packs for US English and Japanese.

Listing 9-5: The US English language pack CAB definition

image from book
  US English Web Part Language Pack ; ** cab.en-US.ddf ** ; en-US localized LitwareWebParts .OPTION EXPLICIT     ; Generate errors .Set CabinetNameTemplate=LitwareWebParts.wsp .set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory .Set CompressionType=MSZIP;** All files are compressed in cabinet files .Set UniqueFiles="ON" .Set Cabinet=on .Set DiskDirectory1=Package\en-US Solution\manifest.en-US.xml manifest.xml bin\en-US\LitwareWebParts.resources.dll en-US\LitwareWebParts.resources.dll ;*** <the end> 
image from book

Listing 9-6: The US English language pack solution manifest

image from book
  <!-- manifest.en-US.xml --> <Solution SolutionId=""       xmlns="http://schemas.microsoft.com/sharepoint/">       <Assemblies>         <Assembly DeploymentTarget="GlobalAssemblyCache"             Location="en-US\LitwareWebParts.resources.dll" />       </Assemblies> </Solution> 
image from book

Listing 9-7: The Japanese language pack CAB definition

image from book
  Japanese Web Part Language Pack ; ** cab.ja-JP.ddf ** ; ja-JP localized LitwareWebParts .OPTION EXPLICIT     ; Generate errors .Set CabinetNameTemplate=LitwareWebParts.wsp .set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory .Set CompressionType=MSZIP;** All files are compressed in cabinet files .Set UniqueFiles="ON" .Set Cabinet=on .Set DiskDirectory1=Package\ja-JP Solution\manifest.ja-JP.xml manifest.xml bin\ja-JP\LitwareWebParts.resources.dll ja-JP\LitwareWebParts.resources.dll ;*** <the end> 
image from book

Listing 9-8: The Japanese language pack solution manifest

image from book
  <!-- manifest.ja-JP.xml --> <Solution SolutionId=""       xmlns="http://schemas.microsoft.com/sharepoint/">   <Assemblies>     <Assembly DeploymentTarget="GlobalAssemblyCache"         Location="ja-JP\LitwareWebParts.resources.dll" />   </Assemblies> </Solution> 
image from book

After defining the localized language packs, the commands to add them are the same as the core solutions except that the locale is identified by using the lcid parameter. The addsolution and deploysolution commands are used when deploying the LitwareWebParts.wsp language pack in the Package\en-US subfolder.

 stsadm -o addsolution -filename Package\en-US\LitwareWebParts.wsp -lcid 1033 stsadm -o deploysolution -name LitwareWebParts.wsp -lcid 1033 –immediate -allowGacDeployment

The final build script for the Litware Web Parts project is used both on the development box and as a template for the deployment script for production release. It builds the Web Part solution package and language packs as well as adds and deploys the solution package. The complete build script is shown in Listing 9-9 and is available in this chapter’s code samples.

Listing 9-9: The final Litware Web Parts build script

image from book
  Litware Web Parts Build Script if EXIST package\LitwareWebParts.wsp del package\LitwareWebParts.wsp makecab /f Solution\cab.ddf makecab /f Solution\cab.en-US.ddf makecab /f Solution\cab.ja-JP.ddf @SET SPDIR="c:\program files\common files\microsoft shared\web server extensions\12" %SPDIR%\bin\stsadm -o deactivatefeature -name litwarewebparts -url http://localhost %SPDIR%\bin\stsadm -o retractsolution -name LitwareWebParts.wsp -lcid 1033 -immediate %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deletesolution -name LitwareWebParts.wsp -lcid 1033 -override %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o retractsolution -name LitwareWebParts.wsp -immediate -url http://localhost %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deletesolution -name LitwareWebParts.wsp -override %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o addsolution -filename package\LitwareWebParts.wsp %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deploysolution -name LitwareWebParts.wsp -immediate   -allowGacDeployment -allowCasPolicies -url http://localhost %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o addsolution -filename Package\en-US\LitwareWebParts.wsp   -lcid 1033 %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deploysolution -name LitwareWebParts.wsp -lcid 1033 -immediate   -allowGacDeployment %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o activatefeature -name litwarewebparts -url http://localhost 
image from book

Localizing a Site Definition

Revisiting the site definition from earlier in this chapter, it is easy to add a Japanese language pack by adding a localized WEBTEMP file and a LitwareMarketplace resources file. For the Japanese language pack, the WEBTEMP file is localized and deployed to the locale directory TEMPLATE\1041\XML, and the resources are used by the site definition. Additionally, if you wish to make the resources available to custom application pages, you can use the ApplicationResourceFiles node in the solution manifest. The Japanese site definition language pack containing the .ddf file is shown in Listing 9-10, and Listing 9-11 contains the solution manifest.

Listing 9-10: The Japanese site definition language pack CAB definition

image from book
  Japanese Site Definition Language Pack ; ** ja-JP\LitwareMarketplace.wsp (Pattison/Larson) ** .OPTION EXPLICIT     ; Generate errors .Set CabinetNameTemplate=LitwareMarketplace.wsp .set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory .Set CompressionType=MSZIP;** All files are compressed in cabinet files .Set UniqueFiles="ON" .Set Cabinet=on .Set DiskDirectory1=Package Solution\manifest.ja-JP.xml manifest.xml RESOURCES\LitwareMarketplace.ja-JP.resx Resources\LitwareMarketplace.ja-JP.resx TEMPLATE\1041\XML\webtemp.LitwareMarketplace.xml 1041\XML\webtemp.LitwareMarketplace.xml ;*** <the end> 
image from book

Listing 9-11: The Japanese site definition language pack solution manifest

image from book
  <!-- manifest.ja-JP.xml --> <Solution SolutionId=""       xmlns="http://schemas.microsoft.com/sharepoint/">   <SiteDefinitionManifests>     <SiteDefinitionManifest Location="LitwareMarketplace" >       <WebTempFile Location="1041\XML\webtemp.LitwareMarketplace.xml"/>     </SiteDefinitionManifest>   </SiteDefinitionManifests>   <RootFiles>     <RootFile Location="Resources\LitwareMarketplace.ja-JP.resx"/>   </RootFiles> </Solution> 
image from book

The final build script for the Litware site definition is shown in Listing 9-12. This build script incorporates the language resources built earlier in the chapter and includes default and Japanese language resources.

Listing 9-12: Final build script for the Litware site definition

image from book
  Litware Site Definition Build Script makecab /f Solution\cab.ddf makecab /f Solution\cab.ja-JP.ddf @SET SPDIR="c:\program files\common files\microsoft shared\web server extensions\12" %SPDIR%\bin\stsadm -o retractsolution -name LitwareMarketplace.wsp   -immediate -lcid 1041 %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deletesolution -name LitwareMarketplace.wsp -override -lcid 1041 %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o retractsolution -name LitwareMarketplace.wsp -immediate %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deletesolution -name LitwareMarketplace.wsp -override %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o addsolution -filename PACKAGE\LitwareMarketplace.wsp %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o addsolution -filename PACKAGE\LitwareMarketplace.wsp -lcid 1041 %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deploysolution -name LitwareMarketplace.wsp -immediate -force %SPDIR%\bin\stsadm -o execadmsvcjobs %SPDIR%\bin\stsadm -o deploysolution -name LitwareMarketplace.wsp -immediate   -force -lcid 1041 %SPDIR%\bin\stsadm -o execadmsvcjobs 
image from book




Inside Microsoft Windows Sharepoint Services Version 3
Inside Microsoft Windows Sharepoint Services Version 3
ISBN: 735623201
EAN: N/A
Year: 2007
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net