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.

Advertisements

Dumb Localization in .NET 1.1 Web Applications

May 18, 2008

A lot of people always asking about how to localize ASP applications in .NET 1.1

Don’t expect too much from Visual Studio 2003 it provide nothing in this case.

if you want to build a localized web application you have to do it with your code.

and all of the localized controls MUST be server controls as you usually use a resource manager to retrieve the values from resource files and assign it to controls in runtime.

Take care that you need to retrieve the user culture (browser language) from the request object. Because the currentCulture is the server system culture.

You can made a loop to assign the resource entries to the controls properties but it will stay a very stupid process. Always there are keys forgetting and miss-spilling.

The conclusion: It was horrible believe me!!!


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


My SharePoint Variations Notes

May 16, 2008
  • Features:
    • Building multilingual sites by building a site (called Label) for every language and transferring the changes from source language site to all other sites.
    • Redirecting the user to the site matching the browser language.
    • Placing a control to change the language in the top navigation bar.
    • A service is running every 20 min to propagate changes from the source language site to all other sites.
  • Limitations:
    • Transferring changes from the source language to others. So changes in any language other than the source are not reflected in other sites.
    • Pushing a new version from a page to all sites even if there is a minor change like spelling mistake.
    • One to one relationship with site collection (one variation per site collection).
    • Lists changes are transfer only when it’s contained in a new site created.
    • When creating sites using features the target sites created without localization.
    • The localization is working only when creating new sub site and the label sites.
    • List view web part references the source site list in every site it is propagated to(because it use the list ID).
    • Variation fails when trying to push a page when there is a page with the same name but with different content type in the destination site.
    • Permissions are not propagated.
    • Works only on publishing pages.
    • Can’t change default page layout.
    • Don’t support site restore.
    • Variation sites must be in the same level and their parent site must be the root of the variation.
  • Risks (from blogs):
    • Sometimes variations cause performance issues.
    • May cause an expected behavior with heavy look and feel customizations.
  • Variations in other Blogs:

Multilingual System Design: (1)Overview

May 13, 2008

A lot of multinational companies and organizations in general have audiences around the world with different languages and cultures. These organizations have an increasing need to develop their information systems targeting these audiences with their own languages. Not only the interface but also the content of the system must match the audience language.

In this series I am suggesting a design for a multilingual system. This system has a multilingual content viewed in multilingual user interface. I used this design in many systems and was very useful. Especially when in case of medium to large systems. The systems done with this design are used in RTL and LTR orientation. But this model is design for windows application. I think it needs many modifications to fit to web based applications.

This design is designed in comply with Microsoft technologies. I tried to make it generic but when it gets specific it will tends to be Microsoftian. Because I made this design to be implemented with MS SQL and .NET technologies.

Let us start with a general overview on the system. The system is consisting of four layers:

  • Database Layer.
  • Data Access Layer
  • Logic Layer.
  • User Interface Layer.

The database layer deals with the multilingual content. Not only data structures but also the basic logic that manipulating the data. Data access layer is the layer used to retrieve data from database. Logic layer is the least layer that multilingual design affects but we will see that there are some modifications need to be done in this layer to be complied with the multilingual functionality. Finally the user interface layer is used to display the multilingual content but in a multilingual interface so the forms, messages…etc that used to view and take commands from user is also multilingual.

In the next post I will start with Data Layer ISA…


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.