Localized Crystal Reports

11,006

Solution 1

The two options that I can think of are: 1) Have a separate report for each localized version (this gets ugly quick and I don't recommend it very highly) or 2) Have the report generated from an application (say a c# windows/web app) and then you can localize using .net's localization standards and setting all of the localized text (read in from resource files) in the code.

I am not certain about 2008 but we are also on XI R2. We have localized reports for each language but only because we * know * that we will only need three different localized versions.

Solution 2

Found a way to for localization of values such as DateTimes in Crystal Reports.
For instance if date is Aug-2009 and culture is French then would display as août-2009.
All this WITHOUT switching the current Thread culture to French.

Relevant Code snippet (example):

            //Locale must be set BEFORE report is opened 
            if (this.IsEnglish)
            {
                ReportDoc.ReportClientDocument.PreferredViewingLocaleID =
                    CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishCanada;
                ReportDoc.ReportClientDocument.LocaleID =
                    CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishCanada;
                ReportDoc.ReportClientDocument.ProductLocaleID =
                    CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishCanada;
            }
            else
            {
                ReportDoc.ReportClientDocument.PreferredViewingLocaleID =
                    CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrenchCanada;
                ReportDoc.ReportClientDocument.LocaleID =
                    CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrenchCanada;
                ReportDoc.ReportClientDocument.ProductLocaleID =
                    CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleFrenchCanada;
            }

            //Load the report from file path 
            ReportDoc.Load(reportPath.ToString());

Solution 3

A client asked me to do develop a localization strategy for them. I've been meaning to write an article on it. Thanks to you, I've done just that. http://www.cogniza.com/blog/?p=55

Edit:

I was able to use an embedded subreport (in the report-header section) that referenced a database of localization values. I would have added that to my posting, but it was quite complex.

Another option is to create a user-function library (UFL) that handles this tasks. Store the data in a database or XML file. Most likely, however, you will lose the ContentLocale functionality.

Solution 4

We finally got around to implementing report localization. Loading of Crystal Reports is already the laggiest/worst-performing part of the user experience in our app, so we wanted to avoid any performance impact. The other idea that informed our decision was that the translations won't change within a shipped release.

We developed an application that uses the Crystal Reports API (2008 - so there's no RDC) and works in two phases.

First phase is to scrape all of the text and output to an English .resx file. Toughest part of this is identifying translatable text within functions, and replacing embedded fields with tokens indicating "don't translate."

After the localized versions of the resx come back, the second phase of the app takes each report along with each resx and saves out new reports with English replaced with translated text. This also allowed us to switch out the fonts only in Japanese reports to MS Gothic, thereby avoiding the need to license a "universal" font. The Japanese characters in "universal" fonts (e.g. Arial Unicode MS) tend to look like crap.

The Crystal API is byzantine, and you need to be careful with edge cases around detecting translatable strings within functions and embedded fields. Be careful with the builtin fields like PageNofM, they aren't enclosed in curly braces (not to mention that you should replace this with Page {field} of {field} so "page" and "of" can be translated). One pointer, use the controllers to replace existing items with cloned/modified copies, you can't just modify the text content of items in place. Good luck if you go this route, but in the end we think it's the best option.

Share:
11,006
Aidan Ryan
Author by

Aidan Ryan

Developer, musician, comic book fan, LEGO maniac.

Updated on June 15, 2022

Comments

  • Aidan Ryan
    Aidan Ryan almost 2 years

    What is a good method to localize labels (column headings, field labels, headers/footers, etc) on Crystal Reports?

    We are currently on XI R2 SP4 but are looking to migrate to 2008. It looks like 2008 offers better localization of the viewer UI. Does it have a content localization story?