Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm developing my first Umbraco site. This site is going to be in spanish only. The problem I'm facing at this moment is related to language. In a document type I have a date property. When I preview or publish the site the date is printed in english format (Fecha: 2011-02-22T00:00:00). I want it to be displayed in spanish culture (sort off: 22/02/2011).
I have added the spanish language in Settings/Languages. I want to set this as the default language, but I don't know how to do this. Also, I want to delete the default English language, because the web is going to be just in Spanish, but I get an error 'You cannot delete the default language: en-US'.
So finally, my question is: where can I set the default language for the site to Spanish?
Thanks in advance!
Well, as it says you can't delete the en-US language. But I guess the backoffice UI is translated to spanish when the spanish language has been selected on the users in the users section?
In order to get the date formatted in spanish you'll need to do that by using a XSLT macro for instance, using the umbraco.library:FormatDateTime extension, which allows you to manipulate the date string so it's formatted into the date suiting your culture.
Here you can read more about the use of the extension: http://our.umbraco.org/wiki/reference/umbracolibrary/formatdatetime
Hope this helps
Another thing you might want to try out, though not 100% sure it will immediately work out: right-click on the top-most node of your web site content, right-click and select 'Manage hostnames'. In the popup window add a new entry, enter a url (e.g. localhost or local.mysite.com and add an entry to the hosts file) and set the langage to Spanish. Re-publish the entire site (by choosing 'Publish' on the node you've just set the node on and select to include children) and go the url you've just added. The .Net UI culture should now be set to es-[XX] and .Net should output the date as defined for that language.
Should that for some reason not work then Jan's solution would be my next go as well.
Thanks for your answers!
I've tried the Sascha advice first. Edited my hosts file, added a 'test.com 127.0.0.1' line, then added the hostname in Umbraco, and finally replublished the entire site. But this doesn't seem to work. When I type the url (adding the port, since I'm using WebMatrix + IIS 7.5), for example 'http://test.com:50983' I get this error message:
HTTP Error 400. The request hostname is invalid.
I don't know if this is a dead-end, but meanwhile I'm going to try the Jan's solution.
@Jan, yes, if I change the language for Umbraco UI in the users section I see the UI in spanish, but the website looks the same. I'm trying the FormatDateTime and see what happens!
Ok, I developed a XLST macro to perform the formatting of the string. Here it is (omiting headers), for it might help anyone:
<xsl:param name="currentPage"/> <xsl:param name="dateTime"/> <xsl:variable name="dateTimeValue" select="/macro/dateTime" /> <xsl:template match="/"> <xsl:value-of select="umbraco.library:FormatDateTime($dateTimeValue, 'd')"/> </xsl:template></xsl:stylesheet>
And then I use the macro in a template like this:
<umbraco:Macro dateTime="[#fecha]" Alias="DateFormat" runat="server"></umbraco:Macro>
And now, I see the date in spanish format: 22/02/2011!!
So, using the macro the problem is solved. But, then I have tried to get the date in english (en-US) format (02/22/11), just to learn how this works, so I have changed the language of the browser to en-US, and the date still appears in spanish locale! I have checked that no hostname is configured in the site and republished the site. Any idea about this?
Thanks again for helping
Do you have both spanish and english sites running in the same Umbraco installation, or am I missing something?
If you have an english version you would need to make another macro formatting the date in the english format, since I'm pretty sure that no matter the culture etc. the date will adhere to the formatting made by the macro.
Well, my late problem has been solved when I've changed the globalization section in web.config, adding culture="auto" and uiCulture="auto". Now, depending of the language of the browser, the date is formatted in proper way.
In other hand, I have just found that there's no need to use a macro for formatting dates! When inserting an item in a template, you can select the option Format as date: Yes, date only in that dialog!! Shame on me for not seeing it before!!
Anyway, thanks for everything!! (I've marked your comment as an answer, because sure it will be helpful for me in the future)
And shame on me for not knowing that! :-)
I also learned something from this, so that's really cool!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted