Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 16, 2009 06:55 PM by porfanides
Jul 16, 2009 06:55 PM|LINK
In the recent weeks, I have been looking into Localization/Globalization of local reports and I have found various acceptable solutions, all of which use one variation or another of loading the report definition as an XML stream and localizing based on the
parsed results. One example of such a solution is here:
However, I wanted to look deeper into things and see if I could come up with an alternative, using custom code in the report, in order to make the localization appear more like how it'd be done on a web form. My results so far have been less than great,
but I have made some amount of progress and I wanted to see if that's as far as it will ever go, or if any of you have suggestions on how to proceed further. Before I continue, let me explain that I am implementing a Web Site where some of the pages contain
a ReportViewer control processing Local reports. I am using VS2008 for this. For globalization, I am not using satelite assemblies in this project. Instead, I just have some resx files in my App_GlobalResources folder.
In localizing the report, I have 2 main goals: 1) Dynamically change the report's Language property (so that currency, numeric, date, etc formatting matches the locale), 2) Dynamically load the text in all necessary textbox controls, to match the correct
For #1, I looked at the report properties and noticed that I can use an expression for the language. That's good. That means that I could write code which identifies the current culture and returns the result, then use the expression to make a call to
my code. So I added the following in the Code of the report:
Basically, this function gets the current culture and looks for resource files matching the current culture or any one of its parents, all the way up to the Default if a more appropriate resource is not found. Here, I hardcoded the base filename (Labels).
When the best match is discovered, I initialize my ResXResourceSet with this file, and then request the string. If any errors occur, I just return the resourceKey. I know this is a bit dirty, but by this time I was just eager to find any solution that works.
Anyhow, once again, this code works fine in the code-behind of a webpage. Moreover, it gives no compilation errors and when the report runs, it's processed without crashing as a whole. However, the only result I have been able to get in my textbox is the
And this is where I now stand. Overall, it has been a fun experiment and it taught me quite a few things already. I feel like I have made good progress and that I might perhaps be close to achieving globalization in this manner, but I have no idea what
is causing my #Error or how to fix it, or if at all any additional fixes are possible or I've hit the final, unbreakable wall.
I hope to receive feedback from the community regarding this matter and I look forward to your comments.
localisation mulltilanguage culture session