7

[VS2010/ASP.NET Web Forms]

Hi,

In a report (RDLC) I need to provide localization/globalization in two languages (pt-BR and en-US) to the following elements: - Labels/Captions (fixed text) - Report Viewer UI interface (buttons and tooltips to controls like find, next, previous, etc.). - fields formating, according to the current culture

What is the best way to achive this?

  • To translate the fixed captions/labels I´ve found some solutions that make a manual translation of RDLC´s XML definition, using the LabelLocID of a report TextBox as an auxiliar. But it seems very ugly and toilful!

  • To translate the UI interface, I´ve found solutions that suggest the use of a custom IReportingViewerMessage MSDN. Is there some other solution to do this automatically?

  • To format data fields, I can set the the language attribute of the report and textbox (in a RDLC), but I need to set this according to the current culture. How could I do this?

Thanks!

2 Answers 2

10

I have had success with localizing reports by feeding in the culture I would like to display as a parameter to the report. Here is the basic outline:

  1. Setup a report parameter that represents the culture code you want to display. Let's call it pReportCulture. I set a static value as a default for "en-US"

  2. Set the Language of your report to the value of the parm : Language =Parameters!pReportCulture.Value. This should setup the culture of all textboxes etc in the report.

  3. Make sure to put a date or currency format on fields that you localize. Use the .toString("c") or other valid formats. If you do any custom text parsing you will lose the auto localization from the culture setting.

That should take care of most the the localization display.

4
  • Jellie, thank you for the answer. I think that this solution handles only the data field formating, isn´t? How about globalization of fixed labels/captions texts? Jun 21, 2011 at 16:18
  • @rperson, are you talking about multi-language translation of text based on the culture? If so and you only have the 2 to contend with you could table all the strings and load a dataset based on the culture parameter. You would then need to use an expression to display each one from the dataset.
    – Tj Kellie
    Jun 21, 2011 at 19:17
  • I could resolve the issue of fields formatting using parameters, as well as the fields caption, as you have suggested. The UI localization I resolved using a IReportViewerMessages and Resources (resx). Thank you! Jun 21, 2011 at 19:30
  • 1
    This approach does not work for charts. Chart titles, axis titles, groups
    – Smith
    Jul 30, 2016 at 21:13
0

Do rigth click in your .rdlc report (blank place). In properties, set the Languague option to you country culture.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.