本地化Microsoft ReportViewer

本地化Microsoft ReportViewer ,网上可找寻的代码不多,以下为可供参考的一篇,亲测有效,需稍加改动。

using System;
using System.Globalization;
using Microsoft.Reporting.WebForms;
 
namespace InfoSupport.SomeApplication
{
    public class DutchReportViewerMessages : IReportViewerMessages, IReportViewerMessages2, IReportViewerMessages3
    {
        #region IReportViewerMessages Members
 
        // English value: Back to Parent Report
        public string BackButtonToolTip
        {
            get { return "Terug naar het vorige rapport"; }
        }
 
        // English value: Change Credentials
        public string ChangeCredentialsText
        {
            get { return "Wijzig Rechten"; }
        }
 
        // English value: Change Credentials
        public string ChangeCredentialsToolTip
        {
            get { return "Wijzig Rechten"; }
        }
 
        // English value: Current Page
        public string CurrentPageTextBoxToolTip
        {
            get { return "Huidige Pagina"; }
        }
 
        // English value: Document Map
        public string DocumentMap
        {
            get { return "Document Map"; }
        }
 
        // English value: Show / Hide Document Map
        public string DocumentMapButtonToolTip
        {
            get { return "Toon / Verberg Document Map"; }
        }
 
        // English value: Export
        public string ExportButtonText
        {
            get { return "Exporteer"; }
        }
 
        // English value: Export
        public string ExportButtonToolTip
        {
            get { return "Exporteer"; }
        }
 
        // English value: Export Formats
        public string ExportFormatsToolTip
        {
            get { return "Exporteer Formaten"; }
        }
 
        // English value: False
        public string FalseValueText
        {
            get { return "Onwaar"; }
        }
 
        // English value: Find
        public string FindButtonText
        {
            get { return "Zoek"; }
        }
 
        // English value: Find
        public string FindButtonToolTip
        {
            get { return "Zoek"; }
        }
 
        // English value: Next
        public string FindNextButtonText
        {
            get { return "Volgende"; }
        }
 
        // English value: Find Next
        public string FindNextButtonToolTip
        {
            get { return "Volgend Resultaat"; }
        }
 
        // English value: First Page
        public string FirstPageButtonToolTip
        {
            get { return "Eerste Pagina"; }
        }
 
        // English value: Enter a valid page number
        public string InvalidPageNumber
        {
            get { return "Voer een geldig paginanummer in"; }
        }
 
        // English value: Last Page
        public string LastPageButtonToolTip
        {
            get { return "Laatste Pagina"; }
        }
 
        // English value: Next Page
        public string NextPageButtonToolTip
        {
            get { return "Volgende Pagina"; }
        }
 
        // English value: The entire report has been searched.
        public string NoMoreMatches
        {
            get { return "Het volledige rapport is doorzocht."; }
        }
 
        // English value: NULL
        public string NullCheckBoxText
        {
            get { return "Geen waarde"; }
        }
 
        // English value: Null
        public string NullValueText
        {
            get { return "Geen waarde"; }
        }
 
        // English value: of
        public string PageOf
        {
            get { return "van"; }
        }
 
        // English value: Show / Hide Parameters
        public string ParameterAreaButtonToolTip
        {
            get { return "Toon / Verberg Parameters"; }
        }
 
        // English value: Password:
        public string PasswordPrompt
        {
            get { return "Wachtwoord:"; }
        }
 
        // English value: Previous Page
        public string PreviousPageButtonToolTip
        {
            get { return "Vorige Pagina"; }
        }
 
        // English value: Print
        public string PrintButtonToolTip
        {
            get { return "Afdrukken"; }
        }
 
        // English value: Loading...
        public string ProgressText
        {
            get { return "Verwerken..."; }
        }
 
        // English value: Refresh
        public string RefreshButtonToolTip
        {
            get { return "Vernieuwen"; }
        }
 
        // English value: Find Text in Report
        public string SearchTextBoxToolTip
        {
            get { return "Zoek naar tekst binnen het rapport"; }
        }
 
        // English value: <Select a Value>
        public string SelectAValue
        {
            get { return "<Selecteer een waarde>"; }
        }
 
        // English value: (Select All)
        public string SelectAll
        {
            get { return "(Selecteer alles)"; }
        }
 
        // English value: Select a format
        public string SelectFormat
        {
            get { return "Selecteer een formaat"; }
        }
 
        // English value: The search text was not found.
        public string TextNotFound
        {
            get { return "De zoektekst is niet gevonden."; }
        }
 
        // English value: Today is {0}
        public string TodayIs
        {
            get { return "Vandaag is {0}"; }
        }
 
        // English value: True
        public string TrueValueText
        {
            get { return "Waar"; }
        }
 
        // English value: Log In Name:
        public string UserNamePrompt
        {
            get { return "Gebruikersnaam:"; }
        }
 
        // English value: View Report
        public string ViewReportButtonText
        {
            get { return "Toon Rapport"; }
        }
 
        // English value: Zoom
        public string ZoomControlToolTip
        {
            get { return "Zoom"; }
        }
 
        // English value: Page Width
        public string ZoomToPageWidth
        {
            get { return "Paginabreedte"; }
        }
 
        // English value: Whole Page
        public string ZoomToWholePage
        {
            get { return "Volledige pagina"; }
        }
 
        #endregion
 
        #region IReportViewerMessages2 Members
 
        // English value: Your browser does not support scripts or has been configured not to allow scripts.
        public string ClientNoScript
        {
            get { return "Uw browser ondersteunt geen JavaScript of deze ondersteuning is uitgeschakeld."; }
        }
 
        // English value: Unable to load client print control.
        public string ClientPrintControlLoadFailed
        {
            get { return "Het laden van het client print control is niet gelukt."; }
        }
 
        // English value: One or more data sources is missing a user name.
        public string CredentialMissingUserNameError(string dataSourcePrompt)
        {
            return "Een of meerdere databronnen missen een gebruikersnaam.";
        }
 
        // English value is different for each Rendering Extension. See comment behind each type.
        public string GetLocalizedNameForRenderingExtension(string format)
        {
            switch (format)
            {
                case "XML"   : return "XML databestand (.xml)";  // XML file with report data
                case "CSV"   : return "CSV databestand (.csv)";  // CSV (comma delimited)
                case "PDF"   : return "PDF document (.pdf)";     // PDF
                case "MHTML" : return "Webarchief (.mhtml)";     // MHTML (web archive)
                case "EXCEL" : return "Excel rekenblad (.xls)";  // Excel
                case "IMAGE" : return "Afbeelding (.tif)";       // TIFF file
                case "WORD"  : return "Word document (.doc)";    // Word
                default      : return null;
            }
        }
 
        // English value: Select a value
        public string ParameterDropDownToolTip
        {
            get { return "Selecteer een waarde"; }
        }
 
        // English value: Please select a value for the parameter '{0}'.
        public string ParameterMissingSelectionError(string parameterPrompt)
        {
            return String.Format(CultureInfo.CurrentCulture, "Selecteer een waarde voor de parameter '{0}'", parameterPrompt);
        }
 
        // English value: Please enter a value for the parameter '{0}'. The parameter cannot be blank.
        public string ParameterMissingValueError(string parameterPrompt)
        {
            return String.Format(CultureInfo.CurrentCulture, "Selecteer een waarde voor de parameter '{0}'. De parameter mag niet leeg zijn.", parameterPrompt);
        }
 
        #endregion
 
        #region IReportViewerMessages3 Members
 
        // English value: Loading...
        public string CalendarLoading
        {
            get { return "Verwerken..."; }
        }
 
        // English value: Cancel
        public string CancelLinkText
        {
            get { return "Annuleer"; }
        }
 
        // English value: pageCount if PageCountMode.Actual, else pageCount suffixed with a ?
        public string TotalPages(int pageCount, PageCountMode pageCountMode)
        {
            return string.Format(CultureInfo.CurrentCulture, "{0}{1}", pageCount, pageCountMode == PageCountMode.Estimate ? "~" : String.Empty);
        }
 
        #endregion
    }
}

https://devillers.nl/blog/localizing-microsoft-reportviewer/

相关msdn链接:https://docs.microsoft.com/zh-cn/previous-versions/visualstudio/visual-studio-2010/dd468082(v=vs.100)

https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/ms255036(v=vs.100)

https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/ms255383%28v%3dvs.100%29

https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/dd468082%28v%3dvs.100%29

可以通过实现三个IReportViewerMessages接口来本地化Microsoft ReportViewer Control 。但是,这些接口的文档缺少原始的字符串值,这反过来又使得难以提供适当的转换。在此博客中,提供了这些值的完整列表以及IReportViewerMessages的荷兰语实现。

Microsoft ReportViewer

Microsoft ReportViewer是一个.NET控件,可以在Windows和Web应用程序中使用它来呈现Microsoft Reports。顾名思义,ReportViewer的功能远不只是查看报告。该控件能够加载(远程)RDL文件,执行其内容并以各种格式(包括HTML,Excel,Word,PDF)呈现最终结果。呈现后,用户可以与控件进行交互,以传递报告参数,浏览多页报告等等。

ReportViewer本地化为荷兰的文化和语言。

ReportViewer本地化为荷兰的文化和语言。

在我当前的项目中,我们将ReportViewer嵌入到ASP MVC Web应用程序中。由于应用程序的受众是荷兰人,因此所有内容(包括ReportViewer)都必须本地化为荷兰文化。不幸的是,可用于ReportViewer的语言包不包括荷兰语,因此我不得不提出一种替代解决方案。

善良

幸运的是,Microsoft在ReportViewer控件中包含了一种机制,该机制允许开发人员覆盖默认消息。这是通过在利用ReportViewer的父应用程序中实现各种接口,然后将这些自定义实现传递给ReportViewer控件来实现的。

更具体地讲,这些接口IReportViewerMessagesIReportViewerMessages2并且IReportViewerMessages3,它驻留在Microsoft.Reporting.WebForms命名空间(或的WinForms,如果你正在使用的)。这些接口实质上只是具有静态硬编码值的只读字符串属性的集合。

坏人

尽管Microsoft足够优雅地记录了 这些 接口,但它们的文档缺少这些字符串属性的原始值。结果,任何想要为这些属性创建有意义的翻译的人都必须从属性的名称和描述而不是原始值中推断出含义。这可能是当面对神秘的名字,如相当具有挑战性ParameterAreaButtonToolTipNullValueTextClientPrintControlLoadFailed

丑陋的

尽管缺乏原始价值是一件令人讨厌的事,但这绝不是一件容易的事。翻译不善可能导致用户面对看似不合适的消息,但应用程序本身仍将保持功能。或者我以为:

输入的字符串格式不正确。

首次尝试本地化ReportViewer会导致FormatException

大多数.NET开发人员都会熟悉此异常,因为它是String.Format被用格式字符串调用的结果,该格式字符串与要格式化的预期对象不匹配。换句话说,我要翻译的一个或多个字符串使用了复合格式设置功能。如果没有这些字符串的原始英文值,则可以猜测这些字符串中的哪些必须包含格式占位符。

解决方案

为了解决此问题,我对ReportViewer程序集进行了反编译,并提取了这些属性的原始字符串值。下面是我的荷兰语IReportViewerMessages接口实现的版本。每个属性均包含英文原始文本,因此您可以将其用作自己的翻译的模板。

 

自然地,如果我没有一些匹配的单元测试就粘贴代码是不负责任的:

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using InfoSupport.SomeApplication;
 
namespace InfoSupport.SomeApplication.Tests
{
    [TestClass]
    public class DutchReportViewerMessagesTests
    {
        [TestMethod]
        public void TranslatedStringsTests()
        {
            var m = new DutchReportViewerMessages();
            Assert.IsTrue(!String.IsNullOrEmpty(m.BackButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.CalendarLoading));
            Assert.IsTrue(!String.IsNullOrEmpty(m.CancelLinkText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ChangeCredentialsText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ChangeCredentialsToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ClientNoScript));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ClientPrintControlLoadFailed));
            Assert.IsTrue(!String.IsNullOrEmpty(m.CredentialMissingUserNameError(null)));
            Assert.IsTrue(!String.IsNullOrEmpty(m.CurrentPageTextBoxToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.DocumentMap));
            Assert.IsTrue(!String.IsNullOrEmpty(m.DocumentMapButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ExportButtonText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ExportButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ExportFormatsToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.FalseValueText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.FindButtonText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.FindButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.FindNextButtonText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.FindNextButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.FirstPageButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.InvalidPageNumber));
            Assert.IsTrue(!String.IsNullOrEmpty(m.LastPageButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.NextPageButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.NoMoreMatches));
            Assert.IsTrue(!String.IsNullOrEmpty(m.NullCheckBoxText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.NullValueText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.PageOf));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterAreaButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterDropDownToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterMissingSelectionError(String.Empty)));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterMissingValueError(String.Empty)));
            Assert.IsTrue(!String.IsNullOrEmpty(m.PasswordPrompt));
            Assert.IsTrue(!String.IsNullOrEmpty(m.PreviousPageButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.PrintButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ProgressText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.RefreshButtonToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.SearchTextBoxToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.SelectAll));
            Assert.IsTrue(!String.IsNullOrEmpty(m.SelectAValue));
            Assert.IsTrue(!String.IsNullOrEmpty(m.SelectFormat));
            Assert.IsTrue(!String.IsNullOrEmpty(m.TextNotFound));
            Assert.IsTrue(!String.IsNullOrEmpty(m.TodayIs));
            Assert.IsTrue(!String.IsNullOrEmpty(m.TrueValueText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.UserNamePrompt));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ViewReportButtonText));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ZoomControlToolTip));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ZoomToPageWidth));
            Assert.IsTrue(!String.IsNullOrEmpty(m.ZoomToWholePage));
        }
 
        [TestMethod]
        public void FormattableStringsTest()
        {
            var m = new DutchReportViewerMessages();
            var parameter = "abc123";
            Assert.IsTrue(m.ParameterMissingSelectionError(parameter).Contains(parameter));
            Assert.IsTrue(m.ParameterMissingValueError(parameter).Contains(parameter));
            Assert.IsTrue(String.Format(m.TodayIs, parameter).Contains(parameter));
        }
 
        [TestMethod]
        public void GetLocalizedNameForRenderingExtensionTest()
        {
            var m = new DutchReportViewerMessages();
            string[] knownExtensions = { "XML", "CSV", "PDF", "MHTML", "EXCEL", "IMAGE", "WORD"};
            foreach (var ext in knownExtensions)
                Assert.IsTrue(!String.IsNullOrEmpty(m.GetLocalizedNameForRenderingExtension(ext)));
        }
 
        [TestMethod]
        public void GetLocalizedNameForRenderingExtensionTest_UnknownExtensionReturnsNull()
        {
            var m = new DutchReportViewerMessages();
            string[] unknownExtensions = { "DOCX", "PNG", "JPG", "JPEG" };
            foreach (var ext in unknownExtensions)
                Assert.IsNull(m.GetLocalizedNameForRenderingExtension(ext));
        }
 
        [TestMethod]
        public void TotalPagesTest()
        {
            var m = new DutchReportViewerMessages();
            Assert.AreEqual("10",  m.TotalPages(10, Microsoft.Reporting.WebForms.PageCountMode.Actual));
            Assert.AreEqual("10~", m.TotalPages(10, Microsoft.Reporting.WebForms.PageCountMode.Estimate));
        }
    }
}

此外,下面是所有属性的表格以及它们各自的英语和荷兰语翻译。请注意,该表不包括属于接口的方法。

IREPORTVIEWER消息

物业名称原始英语价值荷兰语翻译
BackButtonToolTip返回上级报告Terug naar het vorige融洽关系
ChangeCredentialsText变更凭证维希格·雷希滕
ChangeCredentialsToolTip变更凭证维希格·雷希滕
CurrentPageTextBoxToolTip当前页面希迪格·帕吉纳
DocumentMap文件图文件图
DocumentMapButtonToolTip显示/隐藏文档图Toon / Verberg文档图
ExportButtonText出口出口商
ExportButtonToolTip出口出口商
ExportFormatsToolTip导出格式出口商格式化
FalseValueTextOnwaar
FindButtonText佐克
FindButtonToolTip佐克
FindNextButtonText下一个伏根德
FindNextButtonToolTip找下一个Volgend结果
FirstPageButtonToolTip第一页埃斯特·帕吉纳(Eerste Pagina)
InvalidPageNumber输入有效的页码Voer een geldig paginanummer在
LastPageButtonToolTip最后一页Laatste Pagina
NextPageButtonToolTip下一页Volgende Pagina
NoMore比赛整个报告已被搜索。混血儿和睦相处是doorzocht。
NullCheckBoxText空值吉恩·沃德
空值文本空值吉恩·沃德
PageOf货车
ParameterAreaButtonToolTip显示/隐藏参数Toon / Verberg参数
密码提示密码:Wachtwoord:
PreviousPageButtonToolTip上一页沃里格·帕吉纳(Vorige Pagina)
打印按钮工具提示打印阿夫德鲁肯
ProgressText载入中...Verwerken…
刷新按钮工具提示刷新韦尔纽纽
SearchTextBoxToolTip在报告中查找文本Zoek Naar Tekst Binnen Het融洽
选择值<选择值><选帝侯瓦德>
全选(全选)(选拔队)
选择格式选择格式选择者形成
TextNotFound找不到搜索文字。De zoektekst是niet gevonden。
今天是今天是{0}Vandaag是{0}
TrueValueText真正Waar
用户名提示登录名:Gebruikersnaam:
查看报告ViewReportButtonText卡通香椿
ZoomControlToolTip放大放大
ZoomToPageWidth页面宽度Paginabreedte
缩放到整个页面整页Volledige Pagina

IREPORTVIEWERMESSAGES2

物业名称原始英语价值荷兰语翻译
ClientNoScript您的浏览器不支持脚本或已被配置为不允许脚本。Uw浏览器ondesteunting的deze ondersteuninging JavaScript是uitgeschakeld。
ClientPrintControlLoadFailed无法加载客户端打印控件。杂货客户的打印控件是niet gelukt。
ParameterDropDownToolTip选择一个值甄选人

IREPORTVIEWERMESSAGES3

物业名称原始英语价值荷兰语翻译
日历加载载入中...Verwerken…
取消链接文字取消安乐儿

附加条款

  • 返回null将使ReportViewer默认返回原始值。将此属性用于不希望转换的字符串属性或方法。
  • 要使ReportViewer接管您的自定义实施,需要更改应用程序的web.config或app.config。添加<add key="ReportViewerMessages" value="MyClass, MyAssembly" />到您的appSettings中,并用实现类及其所在的程序集的名称替换MyClass和MyAssembly。

摘要

可以通过实现三个IReportViewerMessages接口来本地化Microsoft ReportViewer Control。但是,这些接口的文档缺少原始的字符串值,从而使提供正确的转换变得很困难。在此博客中,提供了这些值的完整列表以及IReportViewerMessages的荷兰语实现。

https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/aa992078%28v%3dvs.100%29

https://blogs.infosupport.com/localizing-microsoft-reportviewer/

  • 本地化Microsoft ReportViewer

     

    可以通过实现三个IReportViewerMessages接口来本地化Microsoft ReportViewer Control 。但是,这些接口的文档缺少原始的字符串值,这反过来又使得难以提供适当的转换。在此博客中,提供了这些值的完整列表以及IReportViewerMessages的荷兰语实现。

     

    Microsoft ReportViewer

    Microsoft ReportViewer是一个.NET控件,可以在Windows和Web应用程序中使用它来呈现Microsoft Reports。顾名思义,ReportViewer的功能远不只是查看报告。该控件能够加载(远程)RDL文件,执行其内容并以各种格式(包括HTML,Excel,Word,PDF)呈现最终结果。呈现后,用户可以与控件进行交互,以传递报告参数,浏览多页报告等等。

    ReportViewer本地化为荷兰的文化和语言。

    在我当前的项目中,我们将ReportViewer嵌入到ASP MVC Web应用程序中。由于应用程序的受众是荷兰人,因此所有内容(包括ReportViewer)都必须本地化为荷兰文化。不幸的是,可用于ReportViewer的语言包不包括荷兰语,因此我不得不提出一种替代解决方案。

    善良

    幸运的是,Microsoft在ReportViewer控件中包含了一种机制,该机制允许开发人员覆盖默认消息。这是通过在利用ReportViewer的父应用程序中实现各种接口,然后将这些自定义实现传递给ReportViewer控件来实现的。

    更具体地讲,这些接口IReportViewerMessagesIReportViewerMessages2 并且IReportViewerMessages3,它驻留在Microsoft.Reporting.WebForms命名空间(或的WinForms,如果你正在使用的)。这些接口实质上只是具有静态硬编码值的只读字符串属性的集合。

    坏人

    尽管Microsoft足够优雅地记录了 这些 接口,但它们的文档缺少这些字符串属性的原始值。结果,任何想要为这些属性创建有意义的翻译的人都必须从属性的名称和描述而不是原始值中推断出含义。这可能是当面对神秘的名字,如相当具有挑战性ParameterAreaButtonToolTipNullValueText ClientPrintControlLoadFailed

    丑陋的

    尽管缺乏原始价值是一件令人讨厌的事,但这绝不是一件容易的事。翻译不善可能导致用户面对看似不合适的消息,但应用程序本身仍将保持功能。或者我以为:

    首次尝试本地化ReportViewer会导致FormatException

    大多数.NET开发人员都将熟悉此异常,因为它是String.Format用格式字符串调用的结果,该字符串与要格式化的预期对象不匹配。换句话说,我要翻译的一个或多个字符串使用了复合格式设置功能。如果没有这些字符串的原始英文值,则可以猜测这些字符串中的哪些必须包含格式占位符。

    解决方案

    为了解决此问题,我对ReportViewer程序集进行了反编译,并提取了这些属性的原始字符串值。下面是我的荷兰语IReportViewerMessages接口实现的版本。每个属性均包含英文原始文本,因此您可以将其用作自己的翻译的模板。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    using System;
    using System.Globalization;
    using Microsoft.Reporting.WebForms;
     
    namespace InfoSupport.SomeApplication
    {
         public class DutchReportViewerMessages : IReportViewerMessages, IReportViewerMessages2, IReportViewerMessages3
         {
             #region IReportViewerMessages Members
     
             // English value: Back to Parent Report
             public string BackButtonToolTip
             {
                 get { return &quot;Terug naar het vorige rapport&quot;; }
             }
     
             // English value: Change Credentials
             public string ChangeCredentialsText
             {
                 get { return &quot;Wijzig Rechten&quot;; }
             }
     
             // English value: Change Credentials
             public string ChangeCredentialsToolTip
             {
                 get { return &quot;Wijzig Rechten&quot;; }
             }
     
             // English value: Current Page
             public string CurrentPageTextBoxToolTip
             {
                 get { return &quot;Huidige Pagina&quot;; }
             }
     
             // English value: Document Map
             public string DocumentMap
             {
                 get { return &quot;Document Map&quot;; }
             }
     
             // English value: Show / Hide Document Map
             public string DocumentMapButtonToolTip
             {
                 get { return &quot;Toon / Verberg Document Map&quot;; }
             }
     
             // English value: Export
             public string ExportButtonText
             {
                 get { return &quot;Exporteer&quot;; }
             }
     
             // English value: Export
             public string ExportButtonToolTip
             {
                 get { return &quot;Exporteer&quot;; }
             }
     
             // English value: Export Formats
             public string ExportFormatsToolTip
             {
                 get { return &quot;Exporteer Formaten&quot;; }
             }
     
             // English value: False
             public string FalseValueText
             {
                 get { return &quot;Onwaar&quot;; }
             }
     
             // English value: Find
             public string FindButtonText
             {
                 get { return &quot;Zoek&quot;; }
             }
     
             // English value: Find
             public string FindButtonToolTip
             {
                 get { return &quot;Zoek&quot;; }
             }
     
             // English value: Next
             public string FindNextButtonText
             {
                 get { return &quot;Volgende&quot;; }
             }
     
             // English value: Find Next
             public string FindNextButtonToolTip
             {
                 get { return &quot;Volgend Resultaat&quot;; }
             }
     
             // English value: First Page
             public string FirstPageButtonToolTip
             {
                 get { return &quot;Eerste Pagina&quot;; }
             }
     
             // English value: Enter a valid page number
             public string InvalidPageNumber
             {
                 get { return &quot;Voer een geldig paginanummer in &quot;; }
             }
     
             // English value: Last Page
             public string LastPageButtonToolTip
             {
                 get { return &quot;Laatste Pagina&quot;; }
             }
     
             // English value: Next Page
             public string NextPageButtonToolTip
             {
                 get { return &quot;Volgende Pagina&quot;; }
             }
     
             // English value: The entire report has been searched.
             public string NoMoreMatches
             {
                 get { return &quot;Het volledige rapport is doorzocht.&quot;; }
             }
     
             // English value: NULL
             public string NullCheckBoxText
             {
                 get { return &quot;Geen waarde&quot;; }
             }
     
             // English value: Null
             public string NullValueText
             {
                 get { return &quot;Geen waarde&quot;; }
             }
     
             // English value: of
             public string PageOf
             {
                 get { return &quot;van&quot;; }
             }
     
             // English value: Show / Hide Parameters
             public string ParameterAreaButtonToolTip
             {
                 get { return &quot;Toon / Verberg Parameters&quot;; }
             }
     
             // English value: Password:
             public string PasswordPrompt
             {
                 get { return &quot;Wachtwoord:&quot;; }
             }
     
             // English value: Previous Page
             public string PreviousPageButtonToolTip
             {
                 get { return &quot;Vorige Pagina&quot;; }
             }
     
             // English value: Print
             public string PrintButtonToolTip
             {
                 get { return &quot;Afdrukken&quot;; }
             }
     
             // English value: Loading...
             public string ProgressText
             {
                 get { return &quot;Verwerken...&quot;; }
             }
     
             // English value: Refresh
             public string RefreshButtonToolTip
             {
                 get { return &quot;Vernieuwen&quot;; }
             }
     
             // English value: Find Text in Report
             public string SearchTextBoxToolTip
             {
                 get { return &quot;Zoek naar tekst binnen het rapport&quot;; }
             }
     
             // English value: <Select a Value>
             public string SelectAValue
             {
                 get { return &quot;<Selecteer een waarde>&quot;; }
             }
     
             // English value: (Select All)
             public string SelectAll
             {
                 get { return &quot;(Selecteer alles)&quot;; }
             }
     
             // English value: Select a format
             public string SelectFormat
             {
                 get { return &quot;Selecteer een formaat&quot;; }
             }
     
             // English value: The search text was not found.
             public string TextNotFound
             {
                 get { return &quot;De zoektekst is niet gevonden.&quot;; }
             }
     
             // English value: Today is {0}
             public string TodayIs
             {
                 get { return &quot;Vandaag is {0}&quot;; }
             }
     
             // English value: True
             public string TrueValueText
             {
                 get { return &quot;Waar&quot;; }
             }
     
             // English value: Log In Name:
             public string UserNamePrompt
             {
                 get { return &quot;Gebruikersnaam:&quot;; }
             }
     
             // English value: View Report
             public string ViewReportButtonText
             {
                 get { return &quot;Toon Rapport&quot;; }
             }
     
             // English value: Zoom
             public string ZoomControlToolTip
             {
                 get { return &quot;Zoom&quot;; }
             }
     
             // English value: Page Width
             public string ZoomToPageWidth
             {
                 get { return &quot;Paginabreedte&quot;; }
             }
     
             // English value: Whole Page
             public string ZoomToWholePage
             {
                 get { return &quot;Volledige pagina&quot;; }
             }
     
             #endregion
     
             #region IReportViewerMessages2 Members
     
             // English value: Your browser does not support scripts or has been configured not to allow scripts.
             public string ClientNoScript
             {
                 get { return &quot;Uw browser ondersteunt geen JavaScript of deze ondersteuning is uitgeschakeld.&quot;; }
             }
     
             // English value: Unable to load client print control.
             public string ClientPrintControlLoadFailed
             {
                 get { return &quot;Het laden van het client print control is niet gelukt.&quot;; }
             }
     
             // English value: One or more data sources is missing a user name.
             public string CredentialMissingUserNameError( string dataSourcePrompt)
             {
                 return &quot;Een of meerdere databronnen missen een gebruikersnaam.&quot;;
             }
     
             // English value is different for each Rendering Extension. See comment behind each type.
             public string GetLocalizedNameForRenderingExtension( string format)
             {
                 switch (format)
                 {
                     case &quot;XML&quot;   : return &quot;XML databestand (.xml)&quot;;  // XML file with report data
                     case &quot;CSV&quot;   : return &quot;CSV databestand (.csv)&quot;;  // CSV (comma delimited)
                     case &quot;PDF&quot;   : return &quot;PDF document (.pdf)&quot;;     // PDF
                     case &quot;MHTML&quot; : return &quot;Webarchief (.mhtml)&quot;;     // MHTML (web archive)
                     case &quot;EXCEL&quot; : return &quot;Excel rekenblad (.xls)&quot;;  // Excel
                     case &quot;IMAGE&quot; : return &quot;Afbeelding (.tif)&quot;;       // TIFF file
                     case &quot;WORD&quot;  : return &quot;Word document (.doc)&quot;;    // Word
                     default      : return null ;
                 }
             }
     
             // English value: Select a value
             public string ParameterDropDownToolTip
             {
                 get { return &quot;Selecteer een waarde&quot;; }
             }
     
             // English value: Please select a value for the parameter '{0}'.
             public string ParameterMissingSelectionError( string parameterPrompt)
             {
                 return String.Format(CultureInfo.CurrentCulture, &quot;Selecteer een waarde voor de parameter '{0}' &quot;, parameterPrompt);
             }
     
             // English value: Please enter a value for the parameter '{0}'. The parameter cannot be blank.
             public string ParameterMissingValueError( string parameterPrompt)
             {
                 return String.Format(CultureInfo.CurrentCulture, &quot;Selecteer een waarde voor de parameter '{0}' . De parameter mag niet leeg zijn.&quot;, parameterPrompt);
             }
     
             #endregion
     
             #region IReportViewerMessages3 Members
     
             // English value: Loading...
             public string CalendarLoading
             {
                 get { return &quot;Verwerken...&quot;; }
             }
     
             // English value: Cancel
             public string CancelLinkText
             {
                 get { return &quot;Annuleer&quot;; }
             }
     
             // English value: pageCount if PageCountMode.Actual, else pageCount suffixed with a ?
             public string TotalPages( int pageCount, PageCountMode pageCountMode)
             {
                 return string .Format(CultureInfo.CurrentCulture, &quot;{0}{1}&quot;, pageCount, pageCountMode == PageCountMode.Estimate ? &quot;~&quot; : String.Empty);
             }
     
             #endregion
         }
    }

    自然地,如果我没有一些匹配的单元测试就粘贴代码是不负责任的:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using InfoSupport.SomeApplication;
     
    namespace InfoSupport.SomeApplication.Tests
    {
         [TestClass]
         public class DutchReportViewerMessagesTests
         {
             [TestMethod]
             public void TranslatedStringsTests()
             {
                 var m = new DutchReportViewerMessages();
                 Assert.IsTrue(!String.IsNullOrEmpty(m.BackButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.CalendarLoading));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.CancelLinkText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ChangeCredentialsText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ChangeCredentialsToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ClientNoScript));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ClientPrintControlLoadFailed));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.CredentialMissingUserNameError( null )));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.CurrentPageTextBoxToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.DocumentMap));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.DocumentMapButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ExportButtonText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ExportButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ExportFormatsToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.FalseValueText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.FindButtonText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.FindButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.FindNextButtonText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.FindNextButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.FirstPageButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.InvalidPageNumber));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.LastPageButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.NextPageButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.NoMoreMatches));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.NullCheckBoxText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.NullValueText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.PageOf));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterAreaButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterDropDownToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterMissingSelectionError(String.Empty)));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ParameterMissingValueError(String.Empty)));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.PasswordPrompt));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.PreviousPageButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.PrintButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ProgressText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.RefreshButtonToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.SearchTextBoxToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.SelectAll));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.SelectAValue));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.SelectFormat));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.TextNotFound));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.TodayIs));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.TrueValueText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.UserNamePrompt));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ViewReportButtonText));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ZoomControlToolTip));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ZoomToPageWidth));
                 Assert.IsTrue(!String.IsNullOrEmpty(m.ZoomToWholePage));
             }
     
             [TestMethod]
             public void FormattableStringsTest()
             {
                 var m = new DutchReportViewerMessages();
                 var parameter = &quot;abc123&quot;;
                 Assert.IsTrue(m.ParameterMissingSelectionError(parameter).Contains(parameter));
                 Assert.IsTrue(m.ParameterMissingValueError(parameter).Contains(parameter));
                 Assert.IsTrue(String.Format(m.TodayIs, parameter).Contains(parameter));
             }
     
             [TestMethod]
             public void GetLocalizedNameForRenderingExtensionTest()
             {
                 var m = new DutchReportViewerMessages();
                 string [] knownExtensions = { &quot;XML&quot;, &quot;CSV&quot;, &quot;PDF&quot;, &quot;MHTML&quot;, &quot;EXCEL&quot;, &quot;IMAGE&quot;, &quot;WORD&quot;};
                 foreach ( var ext in knownExtensions)
                     Assert.IsTrue(!String.IsNullOrEmpty(m.GetLocalizedNameForRenderingExtension(ext)));
             }
     
             [TestMethod]
             public void GetLocalizedNameForRenderingExtensionTest_UnknownExtensionReturnsNull()
             {
                 var m = new DutchReportViewerMessages();
                 string [] unknownExtensions = { &quot;DOCX&quot;, &quot;PNG&quot;, &quot;JPG&quot;, &quot;JPEG&quot; };
                 foreach ( var ext in unknownExtensions)
                     Assert.IsNull(m.GetLocalizedNameForRenderingExtension(ext));
             }
     
             [TestMethod]
             public void TotalPagesTest()
             {
                 var m = new DutchReportViewerMessages();
                 Assert.AreEqual(&quot;10&quot;,  m.TotalPages(10, Microsoft.Reporting.WebForms.PageCountMode.Actual));
                 Assert.AreEqual(&quot;10~&quot;, m.TotalPages(10, Microsoft.Reporting.WebForms.PageCountMode.Estimate));
             }
         }
    }

    此外,下面是所有属性的表格以及它们各自的英语和荷兰语翻译。请注意,该表不包括属于接口的方法。

    IReportViewerMessages

    物业名称原始英文价值荷兰语翻译
    BackButtonToolTipBack to Parent ReportTerug naar het vorige rapport
    ChangeCredentialsTextChange CredentialsWijzig Rechten
    ChangeCredentialsToolTipChange CredentialsWijzig Rechten
    CurrentPageTextBoxToolTipCurrent PageHuidige Pagina
    DocumentMapDocument MapDocument Map
    DocumentMapButtonToolTipShow / Hide Document MapToon / Verberg Document Map
    ExportButtonTextExportExporteer
    ExportButtonToolTipExportExporteer
    ExportFormatsToolTipExport FormatsExporteer Formaten
    FalseValueTextFalseOnwaar
    FindButtonTextFindZoek
    FindButtonToolTipFindZoek
    FindNextButtonTextNextVolgende
    FindNextButtonToolTipFind NextVolgend Resultaat
    FirstPageButtonToolTipFirst PageEerste Pagina
    InvalidPageNumberEnter a valid page numberVoer een geldig paginanummer in
    LastPageButtonToolTipLast PageLaatste Pagina
    NextPageButtonToolTipNext PageVolgende Pagina
    NoMoreMatchesThe entire report has been searched.Het volledige rapport is doorzocht.
    NullCheckBoxTextNULLGeen waarde
    NullValueTextNullGeen waarde
    PageOfofvan
    ParameterAreaButtonToolTipShow / Hide ParametersToon / Verberg Parameters
    PasswordPromptPassword:Wachtwoord:
    PreviousPageButtonToolTipPrevious PageVorige Pagina
    PrintButtonToolTipPrintAfdrukken
    ProgressTextLoading...Verwerken...
    RefreshButtonToolTipRefreshVernieuwen
    SearchTextBoxToolTipFind Text in ReportZoek naar tekst binnen het rapport
    SelectAValue<Select a Value><Selecteer een waarde>
    SelectAll(Select All)(Selecteer alles)
    SelectFormatSelect a formatSelecteer een formaat
    TextNotFoundThe search text was not found.De zoektekst is niet gevonden.
    TodayIsToday is {0}Vandaag is {0}
    TrueValueTextTrueWaar
    UserNamePromptLog In Name:Gebruikersnaam:
    View ReportViewReportButtonTextToon Rapport
    ZoomControlToolTipZoomZoom
    ZoomToPageWidthPage WidthPaginabreedte
    ZoomToWholePageWhole PageVolledige pagina

    IReportViewerMessages2

    物业名称原始英文价值荷兰语翻译
    ClientNoScriptYour browser does not support scripts or has been configured not to allow scripts.Uw browser ondersteunt geen JavaScript of deze ondersteuning is uitgeschakeld.
    ClientPrintControlLoadFailedUnable to load client print control.Het laden van het client print control is niet gelukt.
    ParameterDropDownToolTipSelect a valueSelecteer een waarde

    IReportViewerMessages3

    物业名称原始英文价值荷兰语翻译
    CalendarLoadingLoading...Verwerken...
    CancelLinkTextCancelAnnuleer

    附加条款

    • 返回null将使ReportViewer默认返回原始值。将此属性用于不希望转换的字符串属性或方法。
    • 要使ReportViewer接管您的自定义实施,需要更改应用程序的web.config或app.config。将以下行添加到您的appSettings中,并用实现类及其所在的程序集的名称替换MyClass和MyAssembly。

马丁·戴维勒斯

 

查看资料

10条评论

  1. 这是您需要在web.config中实现的键,以使ReportViewer加载已实现的类。

    comaunite/ 6年前

  2. comaunite/ 6年前

  3. http://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportviewermessages2.aspx

    在那里,您可以在web.config中找到所需的密钥,以便ReportViewer加载您的类。(对垃圾评论很抱歉,网站似乎删除了这些标签(或尝试使用该标签))

    comaunite/ 6年前

    • 谢谢,看来您并不是唯一一个在使用标签的人:片段实际上是在博客的末尾,在“将以下行添加到您的appSettings中,并用实现类的名称和MyClass和MyAssembly代替”,但当我发布博客时似乎已被省略。我将查看是否可以还原该代码段。再次感谢您的关注

      马丁·戴维勒斯/ 6年前

  4. 这是VS2005的吗,因为我使用2008,所以我得到了更多的字符串。

    斯塔凡·维尔坎斯/ 6年前

    • 您还会看到哪些额外的字符串?您是否实现了IReportViewerMessages,IReportViewerMessages2和IReportViewerMessages3?

      马丁·戴维勒斯/ 6年前

  5. 嗨,马丁,
    我对Reportviewer有一个不同的问题。我想在reportviewer中显示HTM1。我注意到内容并未呈现所有HTM1标签。有没有解决的办法,或者没有可能性,
    我有一个保存HTML内容(即HTML标签)的字段,所以我需要将其显示在reportviewer中。让我知道是否有任何可能性

    Jiju/ 6年前

  6. 非常感谢,辛苦了。我整日忙于搜索如何更改默认验证消息,发现只有答案“无法完成”。在这里!(实际上,我错过了这2个其他接口)

    谢谢
    Slawek

    斯拉维克/ 5年前

  7. 这可以正常工作,但是当报表中有下拉菜单时,当我从下拉菜单中选择一个新值并单击“查看报表”按钮时,控件默认为英语。请帮助我解决这个问题。

    马达里/ 4年前

  8. 非常感谢。有没有一种方法可以本地化警报
    “为报告参数…提供的值对其类型无效。(rsReportParameterTypeMismatch)”?

 

https://tutorialmore.com/questions-364157.htm

我在ASP.NET MVC应用程序中使用报表查看器来查看报表。我的系统和浏览器文化是法语。当您在Visual Studio中打开报表或直接从服务器(在浏览器中)打开时,界面为法语。但是,使用reportviewer时,界面为英语。我如何用法语获得它?

尝试将页面文化设置为法语,如下所示:



 
  1. (`UICulture="fr-FR"`)
  2.  

或将组装文化从中性更改为自动:



 
  1. <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=auto`...
  2.  

但是,没有结果。



 
  1. System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");
  2. String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportsFolder"].ToString();
  3. rvSiteMapping.Height = Unit.Pixel(Convert.ToInt32(Request["Height"]) - 58);
  4. rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
  5. rvSiteMapping.ServerReport.ReportServerUrl = new Uri("http://server/PREPROD/");
  6. rvSiteMapping.ServerReport.ReportPath = String.Format("/{0}/{1}", reportFolder, Request["ReportName"].ToString());
  7. rvSiteMapping.ServerReport.Refresh();
  8.  
  • 解决的方法1

    我正在尝试通过以下信息解决此问题:https://devillers.nl/blog/localizing-microsoft-reportviewer/

    这个想法是实现以下接口:

    
    
     
    1. public class FrenchReportViewerMessages : IReportViewerMessages, IReportViewerMessages2, IReportViewerMessages3
    2. {
    3. #region IReportViewerMessages Members
    4. // English value: Back to Parent Report
    5. public string BackButtonToolTip
    6. {
    7. get { return "Terug naar het vorige rapport"; }
    8. }
    9. ...
    10.  

    并将以下内容添加到web.config中:

    
    
     
    1. <add key="ReportViewerMessages" value="FrenchReportViewerMessages, MyAssembly" />
    2.  

    似乎是一种解决方案,但现在我得到一个错误:找不到类型'FrenchReportViewerMessages,MyAssembly'

 

第一次使用接口 --ReportViewer改变显示语言

学会使用msdn

ReportViewer是一个winform控件,想让控件里文本全部显示为英文。

因为是微软封装的,所以无法直接改动,这是就应该考虑微软会提供接口。

搜索发现ReportViewer有实现本地化的IReportViewerMessages3接口,它继承IReportViewerMessages,IReportViewerMessages2.

三个接口很类似应该都看一下,在注释和示例里会描述怎么使用接口,IReportViewerMessages3只有注释,没有示例,看了还不清楚该怎么用,幸好在IReportViewerMessages里看到了示例,根据注释的描述和示例的代码基本可以看懂怎么使用IReportViewerMessages3接口了。

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值