Localization in Visual Studio 2005 Web Application

May 18, 2008

A significant improvement in the web application localization have been done in VS2005. Now, the values are assigned automatically in a much better way.

To make your web page localizable:

1- Go to (Tools)

2- Click (Generate Local Resource)

3- wait until getting the following message:Finished creating resource content and adding ‘meta:’ attributes, the progress is now done.

you will find that a new folder named “App_LocalResources” have been created. In this folder you will find that a resource file have been created having the name <your page name>.asp.resx . In this file you will find that all of your controls properties have been added as entries in the resouce file but “Resource1” appended to the controls names.

Now, to add another language to your application you have to copy the resx file and add your culture name before the resx extention. (e.g. Default.asp.ar-eg.resx)

Localization have been improved in this version of Visual Studio but in needs more and more enhancement.


Localization in SharePoint ASPX Pages

May 16, 2008

To add a text from a resource file into your SharePoint ASPX page you have to place this code where ever you want this text to places.

<%$Resources:MyResource, MyName%>

where:

– MyResource: is the resource file name.

-MyName: is the resource entry key.

Your resource files must be placed in this directory:

..\12\CONFIG\Resources\

all resource files in this directory are copied to the global resources for every web application when it’s creating.

if the webapplication already exists place the resources files in this directory:

C:\Inetpub\wwwroot\wss\VirtualDirectories\<port>\App_GlobalResources\

where <port> is the the web application port


Using Resources Files in SharePoint Web Parts

May 4, 2008
  1. First you need to have your resource files. Place them directly under the project node. For Example add:
    1. MyResource.resx

      Add a new resource entry in the file:

          Key: hello

          Value: Hello

    2. MyResource.ar-sa.resx

      Add a new resource entry in the file:

          Key: hello

          Value:أهلا

    Take care that these resources files must be embedded resources.

  1. In the render function add the following code:

    ResourceManager rm = new
    ResourceManager(“projectname.MyResources”,this.GetType().Assembly);

    writer.Write(rm.GetString(“hello”));

To deploy this web part, use the regular procedure of deploying web part. But you must take care that you will need to deploy the every resources dlls in “..\bin\debug” subdirectory to the Global Assembly Cash (in” windows\assembly” directory). You will find a subdirectory for each culture you have in the project under this directory you will find a projectname.resources.dll file you have to deploy this file to the GAC.