+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Cultures problem

Cultures problem

13 posts, 1 answered
  1. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    25 Jun 2010
    Link to this post
    I am seeing some strange behaviour when finding content using the API. When I have the following in my web.config then the code returns the content belonging to the requested category:

    <localization defaultProvider="Sitefinity" persistenceMode="QueryString" defaultCulture="en" cultures="en, es, fr, de">


    However if I allowSpecificCultures the code returns no content:

    <localization defaultProvider="Sitefinity" persistenceMode="QueryString" defaultCulture="en-GB" cultures="en-GB, es-ES, fr-FR, de-DE" allowSpecificCultures="true">


    My code is:

    private static IEnumerable<IContent> LoadResourcesForCategory(string category)
            {
                var resourcesManager = new ResourcesManager(string.Empty);
                var filters = new List<IMetaSearchInfo>
                                  {
                                      new MetaSearchInfo(MetaValueTypes.ShortText, "Category", category, SearchCondition.Equal)
                                  };
     
                return resourcesManager.Content.GetContent(filters.ToArray()).Cast<IContent>();
            }

    ResourcesManager is a re-named copy of the ProductsManager from the sample products module. Is this expected behaviour?
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 Jun 2010
    Link to this post
    Hi Chris,

    Thank you for using our services.

    The content items store each culture's culture ID to find the respective content for a given language. Non-specific and specific cultures have different IDs (you can check them out here), so the behavior you are experiencing is expected. What you can do in the case is to go to the database and change the culture ids from the non-specific to the specific ones. This forum post will help you. Instead of changing the default culture ids you will look for the items's culture ids and change them. For example if the culture was fr (CID: 12) you have to change the id for fr-FR to 1036.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    25 Jun 2010
    Link to this post
    Hi Radoslav,

    Thanks for the reply. I think I understand what you are saying but would you not expect new content created following the allowSpecificCultures="true" change to be returned? I have created new en-GB content (language ID in the database is 127) and it is not being returned. The module in the admin section of the site finity web site is also showing all the "en" content I created previously.

    Chris.
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 Jun 2010
    Link to this post
    Hello Chris,

    Thank you for getting back to me.

    The problem is that with change of the default language from en to en-GB the default culture changed so this means that first you should perform the described in the forum thread to adjust the default language and then fix CIDs for other cultures.

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    25 Jun 2010
    Link to this post
    Reading through the instructions it does not look as though doing this will result in any changes in the data by the time I have executed all the steps.

    I am only trying to change my default culture from "en" to "en-GB". My understanding is...

    - My current default culture is "en"
    - I have a single item of content (let's call it content A)
    - Content A only exists for "en" (the default culture) and only has one version. 
    - Content A has a single row in sf_CmsContentVersion with LangID 127 (invariant)
    - If I change SiteFinity to allowSpecificCultures, and change "en" to "en-GB" as in my first post, then en-GB becomes the invariant culture
    - The row in content A should remain with LangID 127 because "en-GB" is the new invariant culture.

    Is this not correct? Sorry if I'm not being clear or misunderstanding.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 Jun 2010
    Link to this post
    Hi Chris,

    Thank you for clarifying this.

    I am sorry I have started on the wrong foot. Here is what I did in my sample project to change from non-specific to specific languages:

    1) Create the project and enable localization with the bellow settings:
    <localization defaultProvider="Sitefinity" persistenceMode="QueryString" defaultCulture="en" cultures="en, fr">

    2) turn on localization for Generic content module and create content localized in both languages.

    3) Add allowSpecificCultures="true" and change default culture to en-GB. Here you are correct in your previous post. Now my web.config looks like this:
    <localization defaultProvider="Sitefinity" persistenceMode="QueryString" defaultCulture="en-GB" allowSpecificCultures="true" cultures="en-GB, fr, fr-FR">

    4) The default culture change did not effect the content created in en, it is also available in en-GB.

    5) Use the bellow query to change the content from fr to fr-FR:
    declare @nonSpecificLangID int
    declare @specificLangId int
        
    set @nonSpecificLangID = 12
    set @specificLangId = 1036
     
    Update sf_GCMetaData set LangID = @specificLangId where LangID = @nonSpecificLangID and Application in ('/')
           
    Update sf_CmsContentVersion set LangID = @specificLangId where LangID = @nonSpecificLangID and Application in ('/')
           
    Update sf_CmsTextContent set Culture = @specificLangId where Culture = @nonSpecificLangID and Application in ('/')
          
    Update sf_VersionItem set CultureID = @specificLangId where CultureID = @nonSpecificLangID and Application in ('/')
     
          
    Update sf_VrsTxtData set CultureID = @specificLangId where CultureID = @nonSpecificLangID and Application in ('/')
     
         
    Update sf_VrsBinData set CultureID = @specificLangId where CultureID = @nonSpecificLangID and Application in ('/')

    Now change web.config to:
    <localization defaultProvider="Sitefinity" persistenceMode="QueryString" defaultCulture="en-GB" allowSpecificCultures="true" cultures="en-GB, fr-FR">

    All is dandy after changes.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    28 Jun 2010
    Link to this post
    Hmm ok, not sure why my code isn't working then. I do see all the right content, it's just that I get no content back from the API even when I'm not filtering by language. I'll give it another go.
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    29 Jun 2010
    Link to this post
    Hi Chris,

    Could you please share the code you are using to get the items?

    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    29 Jun 2010
    Link to this post
    Hi Radoslav,

    The code is in my first post, it is:

    ar resourcesManager = new ResourcesManager(string.Empty);
                var filters = new List<IMetaSearchInfo>
                                  {
                                      new MetaSearchInfo(MetaValueTypes.ShortText, "Category", category, SearchCondition.Equal)
                                  };
      
                return resourcesManager.Content.GetContent(filters.ToArray()).Cast<IContent>();

    ResourcesManager is part of a custom generic content based module. It is based upon the products module sample code, so I presume the same code for generic content would cause problems. Perhaps I should try this with generic content:

    var contentManager = new ContentManager();
                var filters = new List<IMetaSearchInfo>
                                  {
                                      new MetaSearchInfo(MetaValueTypes.ShortText, "Category", category, SearchCondition.Equal)
                                  };
      
                return contentManager.GetContent(filters.ToArray()).Cast<IContent>();

  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jun 2010
    Link to this post
    Hello Chris,

    I am having some hard time reproducing this.

    The GetContent() method is returning results for the current culture. Make sure that you have items with this category in the currently selected culture.

    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    11 Aug 2010
    Link to this post
    Hi Radoslav,

    I have not been able to get this to work. I think it is because I am running this code inside a web service so maybe I cannot rely on the culture being right. Either way in my method I want to return content from all cultures/languages (from a single category) not just the current culture, is there a way I can do this?

    A new problem I am also having now is that when I change my cultures to en-GB, fr-FR, es-ES, de-DE the language drop down does not work properly (it switches back to english when I select another language). If I inspect the HTML I see the following:

    <select name="ctl00$LangBar$ctl00$languageList" id="ctl00_LangBar_ctl00_languageList"class="cmsLangDropDown">
        <option selected="selected" value="en-GB">English (United Kingdom)</option>
        <option value="es">español</option>
        <option value="fr">français</option>
        <option value="de">Deutsch</option>
    </select>

    If I change the option values in the inline HTML (using Firebug) to es-ES, fr-FR and de-DE then the drop down will work, but Site Finity doesn't ever seem to be render it correctly anymore.

    Thanks for your help.
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Aug 2010
    Link to this post
    Hello Chris,

    1. You have to set the CurrentUICulture and then call GetContent method. This will give you a proper results. You have to do this for each culture you have(LocalizationManager.Cultures.Values).

    2. We are not able to reproduce the second issue you have reported. Are you able to reproduce it on our demo website ? If so what are the steps?

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  13. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    17 Aug 2010
    Link to this post
    I have set the CurrentUICulture and am now getting back content from the API. I think I can leave it at this and use the Languages property to get what I want as I don't expect there to be content in one language that doesn't exist in the default language e.g.

    foreach (var language in  content.Languages
    {
    // get language version
    }

    I realised that I had not set allowSpecificCultures in web.config which is why the language selection was not working.

    Thanks for your help.
Register for webinar
13 posts, 1 answered