Click here to Skip to main content
13,762,761 members
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 10 Dec 2008
Licenced CPOL

Localization of RDLC Reports into an Arabic Locale

, 10 Dec 2008
Rate this:
Please Sign up or sign in to vote.
Localize RDLC into Arabic Locale or any other language with the correct right-to-left alignment.


The metadata of an RDLC report is defined using XML. This property makes it easier for changing the definition of an RDLC report at runtime. Currently, many developers are facing a problem in localizing RDLC reports into different languages. The most common approach used is to build a different report for each language. In this article, we will present an easy to use approach to localize reports in different locales. And, since Arabic language (same as Hebrew) uses the Right-To-Left direction property, my example will be based on the Arabic Locale to provide the most comprehensive example. I will use Windows Reporting in this example. I will be using .NET 2.0 and Visual Studio 2005.

The Linguist

The linguist is the class that will replace the words in the report with the words from the correct locale. The words and their language replacements will be placed in an XML file. Each XML file represents a language. (We could have used the Resources method of .NET which is actually equivalent to this method, because the resource files are after all XML files; but, this is also another solution to look at.)

You need to place the text that you want to replace in the report in the LocID property of the RDLC label, textbox, or any other object. Then, a loop will pass by all the objects, replacing the work or phrase in LocID property with the correct word or phrase, and setting it to the Text or Value property of the object.

string languageId = Context.Current.CurrentLanguage.Id;
XmlDocument xmldoc = new XmlDocument();

if (languageCache.ContainsKey(languageId))
   xmldoc = languageCache[languageId];
   string xmlFilePath = System.Windows.Forms.Application.StartupPath + 
       "\\Localization\\Languages\\" + languageId + ".xml";
   if (System.IO.File.Exists(xmlFilePath))
      languageCache.Add(languageId, xmldoc);
      return keyName;

StringBuilder xpathExpression = new StringBuilder();

XmlNode node = xmldoc.SelectSingleNode(xpathExpression.ToString());
if (node != null)
   value = node.InnerText;

if (value == "") value = keyName;

To accomplish this, we need to set the tables and the other report controls used to start from the right – to do this, we must:

  1. Set the columns to start in the reverse order – meaning, let the first column be the last.
  2. Change the text align property: the right - make it left, and the left - make it right.
  3. Change the headers and footers of the tables.
  4. Work on the groups, and also reverse the alignment property and the column definitions.
XmlNode alignNode = null;
XmlNodeList textAlignNodes = doc.SelectNodes("//nm:TextAlign", nsmgr);
foreach (XmlNode node in textAlignNodes)
    if (node.InnerText == "Right")
        node.InnerText = "Left";
    else if (node.InnerText == "Left")
        node.InnerText = "Right";

    alignNode = node;

XmlNodeList styleNodes = doc.SelectNodes("//nm:Textbox/nm:Style", nsmgr);
foreach (XmlNode node in styleNodes)
   if (node.SelectSingleNode("./nm:TextAlign", nsmgr) == null)
      if (alignNode != null)
         XmlNode nodeForAlign = alignNode.Clone();

         nodeForAlign.InnerText = "Right";


//reorder details cells
    "/nm:Report/nm:Body/nm:ReportItems/nm:Table/nm:" + 
    "nm:TableCell", doc, nsmgr);

//reorder table groupings cell
ReorderMultipleGroupNodes(doc, nsmgr);

//reorder footer cells
    "/nm:Report/nm:Body/nm:ReportItems/nm:" + 
    "./nm:TableCells", "./nm:TableCells/nm:TableCell", doc, nsmgr);

//reorder header cells
    "/nm:Report/nm:Body/nm:ReportItems/nm:Table/" + 
    "./nm:TableCells/nm:TableCell", doc, nsmgr);

//reverse column definitions
ReorderNodes("/nm:Report/nm:Body/" + 
    "nm:TableColumn", doc, nsmgr);

Points of Interest

This code can more developed to fit other objects and controls of the report such as the List control and also the floating objects - other than this, this code is very much efficient in Arab-izing tables however complex they are (heavy grouping, use of subreports, ...). To complete this development, we can also replace the toolbar with a custom toolbar with Arabic labels and tooltips - this was done and published in more than one article in The Code Project.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ali Hamdar
Software Developer (Senior) Integrated Digital Systems - IDS
Lebanon Lebanon
Been programming since 2001 interested in finance, security, workflows, SharePoint and algorithms. He is an MCSD, MCDBA, MCAD, MCSD, (again), MCTS, MCPD and MCT.
My Blog:

You may also be interested in...

Comments and Discussions

QuestionAnother way Pin
Mikhail016-Aug-13 4:44
memberMikhail016-Aug-13 4:44 
GeneralBest Localization Plug-in for Visual Studio. Pin
Alexander Nesterenko17-Dec-08 22:47
memberAlexander Nesterenko17-Dec-08 22:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.181112.3 | Last Updated 10 Dec 2008
Article Copyright 2008 by Ali Hamdar
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid