Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is you have created <code>fr-CA</code> versions of your items which cannot be fixed by renaming the language .. you can now make a <code>fr</code> version but, like you are seeing, this means there are now 3 possible versions.</p> <p>One suggestion is to leave the languages in Sitecore alone and alter how links are served and processed instead.</p> <p>You would probably need to look at adding your own method into the <code>httpRequestBegin</code> pipeline in Sitecore. This would follow the <code>LanguageResolver</code> entry. You can then parse the <code>RawUrl</code> and set <code>Sitecore.Context.Langauge' to French if the first element in it matched</code>/fr/`.</p> <p><strong>Extremely quick &amp; dirty example:</strong></p> <pre><code>public class MyLanguageResolver : HttpRequestProcessor { public override void Process(HttpRequestArgs args) { string languageText = WebUtil.ExtractLanguageName(args.Context.Request.RawUrl); if(languageText == "fr") { Sitecore.Context.Language = LanguageManager.GetLanguage("fr-CA"); } } } </code></pre> <p>You would probably also have to override the <code>LinkProvider</code> in the <code>&lt;linkManager&gt;</code> section of the web.config to format your URLs when they are resolved by Sitecore.</p> <p><strong>Another extremely quick &amp; dirty example:</strong></p> <pre><code>public class MyLinkProvider : LinkProvider { public override string GetItemUrl(Sitecore.Data.Items.Item item, UrlOptions options) { var url = base.GetItemUrl(item, options); url = url.Replace("/fr-CA/", "/fr/"); return url; } } </code></pre> <p>Another way (slightly more long-winded as it will need to be executed via a script) is to copy the data from the <code>fr-CA</code> version to the <code>fr</code> version and then delete the fr-CA version of each item.</p> <p><strong>Rough helper method that encompasses what you're trying to do</strong></p> <pre><code> private void CopyLanguage(ID id, Language sourceLanguage, Language destinationLanguage) { var master = Database.GetDatabase("master"); var sourceLanguageItem = master.GetItem(id, sourceLanguage); var destinationLanguageItem = master.GetItem(id, destinationLanguage); using (new SecurityDisabler()) { destinationLanguageItem.Editing.BeginEdit(); //for each field in source, create in destination if it does not exist foreach (Field sf in sourceLanguageItem.Fields) { if (sf.Name.Contains("_")) continue; destinationLanguageItem.Fields[sf.Name].Value = sf.Value; } destinationLanguageItem.Editing.AcceptChanges(); ////Remove the source language version ItemManager.RemoveVersions(sourceLanguageItem,sourceLanguage, SecurityCheck.Disable); } } </code></pre> <p>Another way to update the languages on your content items is: </p> <ol> <li>Export the fr-CA language to a <code>.xml</code> file (Using the Control Panel)</li> <li>In the .xml file replace all and tags with the and </li> <li>Rename fr-CA language in the master database to the fr</li> <li>Import language from the .xml file</li> <li>Run Clean Up Databases task (from the Control Panel) </li> </ol> <p>Also you can create a sql script that will change fr-CA language with the fr for all records in the UnversionedFields and VersionedFields tables. </p> <p>If you need any more information or examples please let me know. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload