简体   繁体   English

多语言网站中的警报消息

[英]alert message in Multilingual website

i am using resource files for showing html content(like label names ) in my multilingual website.The resource files are different for different countries.The website is built on Asp.Net MVC3. 我正在使用资源文件在我的多语言网站中显示html内容(如标签名称)。该资源文件因国家/地区而异。该网站基于Asp.Net MVC3构建。

I am showing a javascript alert whose message is picked from a resource file as shown below: alert('@Resources.Areas.Admin.Views.Program.Local.Create.msgDate3'); 我正在显示一个JavaScript警报,其消息是从资源文件中选取的,如下所示:alert('@ Resources.Areas.Admin.Views.Program.Local.Create.msgDate3'); Now in the resource file for msgDate3 i have text in french as "La fecha de inicio deberá ser menor que la fecha de término" This alert on the website gets displayed as "La fecha de inicio deberá ser menor que la fecha de término" where the "á" and "é" are not getting displayed properly. 现在,在msgDate3的资源文件中,我在法语中显示的文本为“ La fecha de iniciodeberáser menor que la fecha detérmino”,该警报在网站上显示为“ La fecha de iniciodeberáser Menor que la fecha detérmino”,其中“á”和“é”显示不正确。 How to display these special charcters? 如何显示这些特殊字符?

I also have data in other languages where similar issue comes up with these characters.How to display them? 我也有其他语言的数据,这些字符也出现类似的问题。如何显示它们?

EDIT:- 编辑:-

(In my app english resource files are named as "cshtmlfilename.resx" eg create.resx and other culture resource files are named as "cshtmlfilename.culturename.resx" eg create.es-MX.resx) (在我的应用中,英语资源文件名为“ cshtmlfilename.resx”,例如create.resx,其他文化资源文件名为“ cshtmlfilename.culturename.resx”,例如create.es-MX.resx)

I found out that the javascript code of my page breaks on the alerts that i have placed in the page in the format alert('@Html.Raw(Resources.Areas.Admin.Views.Program.Local.Create.msgDate2)'); 我发现页面的javascript代码在我以alert('@Html.Raw(Resources.Areas.Admin.Views.Program.Local.Create.msgDate2)'); where 'Create.msgDate2' refers to the resource file Create.resx's key msgDate2. 其中“ Create.msgDate2”是指资源文件Create.resx的密钥msgDate2。 The break msg in firebug comes up as ` 萤火虫中的中断msg显示为`

unterminated string literal [Break On This Error] alert('ควรจะลงวันที่ที่เริ่มก่อนวันสุดท้ายของการสิ้นสุด (this is the msg i get for thailand (th-th) when i am modifying the translation for msgDate2 then the script is working fine.I am sure some issue is happenning with the characters of this language which are making the javascript to stop. Any solutions for this?? 未终止的字符串文字[Break On This Error] alert('ควรจะลงวันที่ที่เริ่มก่อนวันสุดท้ายของการสิ้นสุด(这是我在修改msgDate2的翻译时获取的泰国(thth)的味精,然后是脚本工作正常。我确定此语言的字符正在发生问题,导致javascript停止运行。对此的任何解决方案?

Use Html.Raw to avoid string encoding: 使用Html.Raw避免字符串编码:

alert('@Html.Raw(Resources.Areas.Admin.Views.Program.Local.Create.msgDate3)');

Htmlhelpers like Html.LabelFor(..) return an IHtmlString which aren't encoded like regular strings in the view, so that's why you don't have issues with labels. 像Html.LabelFor(..)这样的Htmlhelpers返回一个IHtmlString,该IHtmlString的编码方式与视图中的常规字符串不同,因此这就是标签没有问题的原因。

What browser(s) is this happening in? 这是什么浏览器发生的? Can you please post the Head element of your HTML file. 能否请您发布HTML文件的Head元素。 I think you could be missing a meta tag for encoding. 我认为您可能会缺少用于编码的元标记。 Try adding the following to the head: 尝试将以下内容添加到头部:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM