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

Advertisements

SharePoint Content Deployment and Migration API

May 16, 2008
  • Using deployment and migration APIs contents may sync between different sites using deployment packages these packages may be translated before they uploaded to the target site.
  • Its move all of the list related data (permissions, pages, web Parts,…).
  • It’s Very strong if we talk about the way it gets the relative data for very item.
  • Reserve ID or create new one.
  • Supports incremental deployment. So, it can deploy new changes only.
  • Limitations:
    • Incremental export/import is supported only in the site scope.
    • In the lists the old items will not be overwritten they will duplicated. But in case of document libraries: the old items overwritten.
    • Unexpected behavior when using to transfer list from a variation site to another variation site have the same list.
    • Can’t export items from different site collections in the same operation.

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:

Errors in Right-to-Left SharePoint

May 4, 2008

In the languages worked left-to-right (like Arabic) its not working well. (see the photos) You will notice that the words will not have the right order.

 

Also there are some bugs in the graphics in case of right-to-left:

 


Localized Custom Properties 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: category – Value: MyNewCategory
          Key: property – Value: MyNewProperty
          Key: description – Value: MyNewDescription

    2. MyResource.ar-sa.resx

      Add a new resource entry in the file:
          Key: category – Value: MyNewCategory
          Key: property – Value: MyNewProperty
          Key: description – Value: MyNewDescription
       Take care that these resources files must be embedded resources.

    Place the following attribute before the class:

    [XmlRoot(Namespace = “projectname”)]

  1. Now you have to override the LoadResource function to get the data from your resource files:
  2. public
    override
    string LoadResource(string id)

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

    return rm.GetString(id);
    }
  3. Before the property you place the “ResourcesAttribute” attribute like the following
[ResourcesAttribute(
"property",
"category",
"description")]
[WebPartStorage(Storage.Shared)]
[Browsable(true)]
public string MyProp_Localized
{
   get
   {
     return _ MyProp_Localized;
   }
   set
   {
      _MyProp_Localized = value;
   }
}

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.


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.