Sitecore set/change default language from 'en' - sitecore

Can anyone recommend the best way to change the default language in Sitecore 6.1. On a fresh install, the typical language for all items is 'en' English, witha nice little USA flag and all.
However, we are setting up a system which is targeting en-AU and en-NZ. When I rename the main 'en' language item in any database, every other item is left without a version in the "correct" language. I recall in the past that renaming this item causes an update across the whole system, but that didn't seem to be the case when I tried it today.
Is there an easy "Sitecore" way to convert all default items to the primary language en-AU? I've considered running a sql update script over the database, but am hoping there is a neater way of doing it.

I don't think that changing anything about the en-language is a good idea. A lot of internal Sitecore objects are based on that language and you could risk loosing labels and help texts in the Sitecore UI.
We usually create all templates, renderings and layouts in the en-language and then create the content items for each language.
Instead you should set the language property in web.config for your site.
Here is an example that we are using from one of our multi-language solutions:
<site name="website_no" hostName="www.site.no|site.no" language="no" />
<site name="website_en" hostName="www.site.com|site.com" language="en" />
<site name="website" language="sv" />
The last line catches all requests not caught by the two first ones.

Couldn't get a site to use Danish as default language for backend UI based on value language="da" in <site...> tag. Changed it to da-DK, which made it work. Don't know if this is expected behaviour, but one might use the fully qualified ISO code to make sure, things are good.

Related

Sitecore multilingual site, default to non-english language even when English version exists

I am working on a sitecore 7.1 site which in Web.config is set to a Swedish language.
<site name="SiteName" language="sv-SE" ... />
It works as expected if I go to a page which only has a Swedish version, but if an English and Swedish version of an Item exists, it prefers the English version. How can I change it so it prefers the Swedish version by default even if an English version exists.
I've read John West's post on how Sitecore language can be set here and of the five ways he mentions language can be set, I think the following 2 may be y pertinent to me, but I'm not sure:
Language cookie associated with context site: in my request, I see there is a cookie se#lang=sv-SE. First is this the site context language cookie? If yes, then language is getting set elsewhere down the pipeline.
The default language associated with the context logical site. I'm not sure how to get at this.
The site language setting should be enough, but just in case, there are some other settings you could check:
ClientLanguage: By default, this is set to 'en'.
DefaultLanguage: By default, this is set to 'en'.
The ClientLanguage should not be used for users visiting your site. From my understanding, that is used for the editing interfaces.
Also, according to my decompiler, the Sitecore 7.2 pipelines should only use the DefaultLanguage if the site language cannot be found.
I did notice that a user's cookie for language is read before it will default to the site language. Are you sure you have a fresh session when you are visiting the page with two languages and the user's default session language has not already been set?
Otherwise, as mentioned in one of the comments, do you have a fallback module installed that may have their own configurations?
I think this is more of a feature than a bug. I narrowed down the causes on my end and it appears to be caused by the following.
My browser sends a request header that it expects english content.
if a version of the content exists in the requested language, sitecore prioritizes english, per the user's preferred language, even if the site is configured to default to a different language.

How to disable Sitecore's embedded language parser

I have a site that has many URL rewrites and a good portion of them contain old links that are prefixed with a country code (e.g. /fr, /de, etc). Rewrites without the prefixes work just fine but those with trigger Sitecore's embedded language URL parser which bypasses the rewrite module entirely.
Example
/fr/old-link tries to parse 'fr' as a language and fails as 'fr-FR' is the name of the French language.
Solution I need to disable Sitecore's ability to detect a language prefix in the URL so the URL rewrite module can proceed unhindered.
I can't find where it is in the pipeline that this occurs. I've gone through numerous with Reflector and come up short. I need help please.
Another pipeline to look at is the preprocessRequest pipeline. It has a StripLanguage processor that detects if the first part of the URL is a language and acts on it.
More info on how to get Sitecore to ignore the language part of the url can be found in this post http://sitecoreblog.patelyogesh.in/2013/11/sitecore-item-with-language-name.html
You will need to create a new LanguageResolver to replace the standard Sitecore one (Sitecore.Pipelines.HttpRequest.LanguageResolver). This is referenced in the <httpRequestBegin> pipeline section in web.config. Here you can handle requests beginning with fr as opposed to fr-FR etc. In the past I have done a similar thing for when we wanted to use non-ISO language codes.
EDIT
The LanguageResolver resolves language based on query string first, but will also resolve based on file path (i.e. having fr-FR in the start of your path). I think you would need to inherit from the Sitecore LanguageResolver and override the GetLanguageFromRequest method changing the else statement to use something different to Context.Data.FilePathLanguage - possibly just using regex/string manipulation to get the first folder from the URL then use that to set the context language. This should prevent the failure to resolve language which I understand is killing your URL rewrite module.

Multi language website, how to approach this?

I have a website (Coldfusion) on which I want to offer multi language, but no idea what is the best way to do this.
There 2 plans I have:
1:
Of course all content (text) is in a database.
If a user would want a different language, the user would click on a link/flag, this would put the requested language in a session variable, for example: session.language = "es"
In the database I would have 2 columns (every language has 1 column) and then select the text which belongs to 'es'
Every page would then do a request to the database to get the text beloging to the session.language.
PROS: Relatively simple to implement
CONS: SEO wise I don't think this could be very good. http:// www.domain.com/page.cfm would give an english text or spanish text (or other language). Google will not add duplicate URL's
2:
Do something with http:// www.domain.com/en/page.cfm for english and http:// www.domain.com/es/page.cfm for english.
With a URL rewrite rule the language value in the URL http:// www.domain.com/en/page.cfm would actually be a page http:// www.domain.com/page.cfm?language=en
The url.language variable will then select the correct language from the database.
PROS: Unique URL for each language. Good for SEO and Google indexing.
CONS: A bit more difficult to implement. (I think)
Or does anyone have other / better ideas?
Thanks!!
You should always first check the browser header "Accept-Language" for the default language(s) (the correct standard way to do it), and offer links (the intuitively seemingly right way) only as an alternative.
Doing it in a database doesn't seem very standard. Let's assume you would like to use MVC architecture (model-view-controller). Most software uses keys in the presentation layer (view) (eg. html) and along with the presentation layer, you have language files (in Java, this is typically properties files) which are mapped simply by their filenames, and can be modified by regular users, without any special skills, such as professional translators with no computer skills. Certainly you could put it in a database, but then it is just more work, and moves the information out of the presentation layer.
There are various libraries for doing this. You should find the normal one for your application. Please edit your question to include what you are using to develop the application. (eg. JSP, Tapestry, Wicket, ASP, PHP, etc.) So for example, if you wanted to use JSPs, I would then suggest you use the JSTL tag library's language support. Or if you were using Tapestry, I would point you to http://tapestry.apache.org/localization.html or http://tapestry.apache.org/tapestry4.1/UsersGuide/localization.html
To look it up, you can look for the terms "internationalization" aka "i18n", or "localization". (The terms don't mean the same thing, but few use them correctly, so either works. http://www.w3.org/International/questions/qa-i18n)
I would go for option 2. Every translation should have its own url. Links to your website will already be in the intended translation.
To store translations in a database, I wouldn't put every translation in a seperate column, but rather put them in a seperate table:
Table Posts:
- id
- title_id
- ...
Table Translations:
- label_id
- value
- country_code
- language_code
Where title_id matches label_id
This way you won't have to alter your table structure when a new translation is added. This allows you to have infinite translations for any label or text.
To effectively do a multi-lingual site then you need set a rule for yourself that NO TEXT is ever put in the source as hard coded. It either needs to come from the database and / or a Resource Bundle.
Text from the database
You need to make sure that the column you are storing your data in is unicode otherwise you'll have issues with accented character. Also don't have a column per language as this is not scalable, do what #jan suggests and have a translations table where the items are keyed on a reference as well as a language.
Resource bundles
You are not going to want to get every last little bit of text from the database so for those you can utilise a resource bundle. This is an, admittedly old, link http://www.sustainablegis.com/blog/cfg11n/index.cfm?mode=entry&entry=FD48909C-50FC-543B-1FE177C1B97E8CC1 from Paul Hastings's blog about some solutions to resource bundles. To be honest his blog is an excellent resource on this very subject.
With regards to how you handle the URLs do not do option 1 as you quite rightly identified you will cause issues the SEO rankings of the page and it will mean that users cannot correctly share or return to the page.
Two approaches are having the language code in the URL as you identified in option 1.
Pros
Simpler to configure
Cons
You have one application which means that as you add more languages you add more complexity and weight on the memory of that app
Or you can have a different sub domain or domain per application e.g. es.yourdomain.com or yourdomain.es they can all be the same codebase
Pros
Each language is a standalone application meaning it has it's own memory
Cons
more effort to configure
http://i18n.riaforge.org/ has a download for i18n. It can be used to make sure that all string labels match. That way if some one wants to change "Save" to "Update", it can all be done in one spot.
It is also important to consider the technical background of those that will being doing the translation. It is often easier to get the translation team to edit files in notepad as opposed to updating a db. Text files work well with version control.
The best way i found is to use an XML to hold just that pages language stuff, one xml to cover each page, and you then vary it for language. when the page loads, just load a different XML from the database or files... many ways to do this. all other methods i have tried have their issues, and at least this one allows you to take a language XML, hand it to someone who will copy it, and then change the boxes... you put it in the DB to serve it.
one can also do this for text, and have the DB make the XML for just the text for that page by using a list of items to include in the XML for the page.
once you get the idea, the rest becomes very easy...
and given CF ways of accessing such data with dot notation, easy peasy to us
say you have "Load Images"
in english xml it may be <LoadIMGS>Load Images</LoadIMGS>
in chinese it may be <LoadIMGS>加载图像</LoadIMGS>
or <LoadIMGS>Jiā zǎi túxiàng</LoadIMGS>
regardless, in your CFM code you would just put #variablename.LoadIMGS# in the place... i would also suggest putting in the loadimages tag the size the font should be adjusted to if not normal size. that way, when translations are too large, you can shrink that font there for that... etc.
enjoy!!!

Why might a sitecore presentation component produce different output dependent on domain?

As I can't post code I'm asking this as a theoretical question, but giving a scenario.
I have a "newsroom" sublayout, which staticaly binds a couple of XSLTs to list latest news and latest events. The sublayout is used on a newsroom item, the events and news items are descendants of it (though not direct child items, there are a couple of layers of folders to categorise and date items).
The subayout is in use in around 10 sites in our solution with no problem. Each site is a clone of our main site with an extra language version added. We hae succesfully used this with (amongst others) Japanese, Chinese, Russian, Polish and Czech language sites.
Our most recent clone (Turkish), however, shows no items in the event or news lists. The items exist and are published, and display as expected when browsed individually.
The presentation details for the newsroom item are identical to all other newsroom items.
Even more perplexing, the newsoom item itself, when displayed in the context of a different domain, displays correctly.
i.e.
www.mysite.com/sitecore/content/my_turkish_site/path/newsroom?sc_lang=tr-TR
shows the lists without a problem, including dates formatted according to culture, but
www.mysite.com.tr/sitecore/content/my_turkish_site/path/newsroom?sc_lang=tr-TR
shows empty lists.
The exact same problem occurs if language is switched to English (the language of the source of the clone)
Almost all of the Turkish site is working properly.
None of the presentation components are marked as cachable.
None of the presentation components have a specified data source (i.e. they all use the current item/descendants axis)
What are the possible causes of this problem, and how can I test them?
EDIT:
For Mark Ursino
This is the site definition (slightly fictionalised). I can't post that much more of the web.config...
<site name="www.mysite.com.tr" patch:after="site[#name='www.mysite.com.au']" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/CloneData/TurkishClone" hostName="www.mysite.com.tr" startItem="/Turkey_Home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" language="tr-TR" />
Some debugging shows that the XSLTs aren't matching the template when the item is viewed in the Turkish context.
This is the debug match used (the select is what we use in our for-each):
<xsl:value-of select="count(./descendant::item[#template='newsitem' and #id!=$topNewsId and sc:fld('__created',.)])"/>
It matches on the same item viewed from other domains.
Debug output shows the Turkish site thinks the template is newsıtem instead of newsitem (the i is wrong!).
I've also tested viewing the newsroom of other sites through the Turkish domain - the problem is the same.
We have the same problem with items based on the eventitem template, and apparently with an Image Spot template.
Have you tried printing out the language, culture and context item id, lang, version within your events lister and xslts?
If that shows anything unexpected you could step-in to some of the Sitecore pipeline resolvers with Reflector Pro's external assembly debugging.
Answering my own question.
Sitecore template names are converted to lower case for use in XSLT comparison, by the Sitecore XSLT extensions.
This lower case conversion hasn't been set as culturally invariant. In Turkish, forcing lower casing of a upper case I gives the lower case ı
Sitecore has replaced calls with ToLower() in the Sitecore API with ToLowerInvariant() as of 6.5 rev.110419
http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/ReleaseNotes/ChangeLog.aspx
As we're not upgrading to 6.5 quite yet we'll be using template IDs rather than names in XSLT for now.
.Net info on strings and culture, including specifically the "Turkish I problem"
http://msdn.microsoft.com/en-us/library/ms973919.aspx

List of tags not available ColdFusion 9 script syntax?

I'm looking for a complete list of tags that are not available in ColdFusion 9 script syntax.
Example:
CFSetting: is one example that is available in Railo but not in CF9 for use in cfscript
CFDocument: I can't find this one so far.
Not an official list by any measure, but this is a list I presented to a private forum a while back, and it didn't receive too much correction (and those corrections have been integrated). It was in the context of what CF does and doesn't need to be implemented, to claim 100% coverage in CFScript.
Summary of omissions:
These ones are significant omissions:
<cfcollection>
<cfexchangecalendar>
<cfexchangeconnection>
<cfexchangecontact>
<cfexchangefilter>
<cfexchangemail>
<cfexchangetask>
<cfexecute>
<cfindex>
<cfinvoke> (support for dynamic method names)
<cflogin>
<cfloginuser>
<cflogout>
<cfmodule>
<cfoutput> (implementation of query looping with grouping)
<cfparam> (fix the bug in that enforced requiredness doesn’t work (ie: param name="foo";))
<cfsearch>
<cfsetting>
<cfwddx>
<cfzip>
<cfzipparam>
There’s a reasonable case for these ones to be implemented:
<cfassociate>
<cfcache>
<cfcontent>
<cfflush>
<cfhtmlhead>
<cfheader>
<cfntauthenticate>
<cfprint>
<cfschedule>
<cfsharepoint>
These ones... I’m ambivalent:
<cfgridupdate>
<cfinsert>
<cfobjectcache>
<cfregistry>
<cfreport>
<cfreportparam>
<cftimer>
<cfupdate>
We don’t need these ones at all, I think:
<cfajaximport>
<cfajaxproxy>
<cfapplet>
<cfcalendar>
<cfchart>
<cfchartdata>
<cfchartseries>
<cfcol>
<cfdiv>
<cfdocument>
<cfdocumentitem>
<cfdocumentsection>
<cffileupload>
<cfform>
<cfformgroup>
<cfformitem>
<cfgraph>
<cfgraphdata>
<cfgrid>
<cfgridcolumn>
<cfgridrow>
<cfinput>
<cflayout>
<cflayoutarea>
<cfmap>
<cfmapitem>
<cfmediaplayer>
<cfmenu>
<cfmenuitem>
<cfpod>
<cfpresentation>
<cfpresentationslide>
<cfpresenter>
<cfselect>
<cfsilent>
<cfslider>
<cfsprydataset>
<cftable>
<cftextarea>
<cftextinput>
<cftooltip>
<cftree>
<cftreeitem>
<cfwindow>
If there's anything here that you think ought to be included in CFScript, please raise an issue here - http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html - and cross reference the issue number here.
HTH.
I would argue that there are no commands that are not available as script as you can extend and write the missing bits using cfc's.
Thus wrap your favourite missing <cftag in a cfc and call it using new
However, here is a list of what is supported
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSe9cbe5cf462523a02805926a1237efcbfd5-7ffe.html