AJAX:CalendarExtender does not localize Today
I'm using the CalendarExtender from the AJAX library with the possibility of localization. Currently everything works fine except when I try to localize it for the Danich (da-DK) language. The calendar looks localized, except the part that says "Today" that remains in English. How do you loc开发者_C百科alize that part too?
PS. And if localization is not possible, can I hide "Today" part of the calendar?
Re:
PS. And if localization is not possible, can I hide "Today" part of the calendar?
As we deemed it more work that it was worth to add our own resources, we decided to hide the "Today" bit. This was however easily done by adding the following to our css file:
.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.
We just had the same problem in a legacy project using an old version of AjaxControlToolkit (4.1), after localization to a specific language has been added. And I definitely did not want to compile my own version of AjaxControlToolkit.
Thus, after digging through CalendarExtender's JavaScript source, I noticed that the text is loaded from a resource, and that this resource can be modified. To make a long story short, if you update Sys.Extended.UI.Resources.Calendar_Today
(default: Today: {0}
) in JavaScript
- after the Toolkit's scripts have been loaded but
- before the user opens the Calendar for the first time,
then the resource value is replaced by your value:
<!-- Add this to the bottom of your page -->
<script type="text/javascript">
Sys.Extended.UI.Resources.Calendar_Today = "Σήμερα: {0}";
</script>
Obviously, if your application is multi-lingual, you will have your own translation resource files:
<script type="text/javascript">
Sys.Extended.UI.Resources.Calendar_Today =
'<%= HttpUtility.JavaScriptStringEncode(Resources.MyTexts.Today) %>';
</script>
精彩评论