我正在使用 AJAX 库中的 CalendarExtender,可以进行本地化。目前一切正常,除非我尝试将其本地化为 Danich (da-DK) 语言。日历看起来是本地化的,除了“今天”部分仍然是英文。你如何本地化那部分呢?
PS。如果无法进行本地化,我可以隐藏日历的“今天”部分吗?
我正在使用 AJAX 库中的 CalendarExtender,可以进行本地化。目前一切正常,除非我尝试将其本地化为 Danich (da-DK) 语言。日历看起来是本地化的,除了“今天”部分仍然是英文。你如何本地化那部分呢?
PS。如果无法进行本地化,我可以隐藏日历的“今天”部分吗?
回覆:
PS。如果无法进行本地化,我可以隐藏日历的“今天”部分吗?
由于我们认为添加我们自己的资源更有价值,因此我们决定隐藏“今天”位。然而,这很容易通过将以下内容添加到我们的 css 文件中来完成:
.ajax__calendar_footer {
display: none;
}
By default Ajax Control Toolkit doesn't localized for the Danish. You need to customize toolkit soulution a bit. Download toolkit sources and add Danish resource file into MicrosoftAjax.Extended project (ExtenderBase folder). You may just create a copy of BaseScriptsResources.resx file and change copy file name to "BaseScriptsResources.ds.resx". I believe you easy find which resource value in that file you must change for your language. After that add that file as a link into ScriptResources folder of the AjaxControlToolkit's project. When you build up solution you will find a new folder with a Danish resource assembly in project's bin folder (da/AjaxControlToolkit.resources.dll). Just copy that folder with a dll to your project's bin folder.
在添加了特定语言的本地化之后,我们在使用旧版本 AjaxControlToolkit (4.1) 的遗留项目中遇到了同样的问题。而且我绝对不想编译我自己的 AjaxControlToolkit 版本。
因此,在挖掘 CalendarExtender 的 JavaScript 源代码后,我注意到文本是从资源加载的,并且可以修改此资源。长话短说,如果您在 JavaScript 中更新Sys.Extended.UI.Resources.Calendar_Today
(默认值:)Today: {0}
然后将资源值替换为您的值:
<!-- Add this to the bottom of your page -->
<script type="text/javascript">
Sys.Extended.UI.Resources.Calendar_Today = "Σήμερα: {0}";
</script>
显然,如果您的应用程序是多语言的,您将拥有自己的翻译资源文件:
<script type="text/javascript">
Sys.Extended.UI.Resources.Calendar_Today =
'<%= HttpUtility.JavaScriptStringEncode(Resources.MyTexts.Today) %>';
</script>