More in this section

Forums / Developing with Sitefinity / API and multilingual content

API and multilingual content

5 posts, 1 answered
  1. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    06 Apr 2010
    Link to this post
    I can't find an example on the website (nor in the Developper Manual): how do you manage pages through the API on a multilingual environnent ?

    My use-case is that I need to import an historical website to sitefinity, I'll need to create the new pages programatically and import its content to sitefinity. That implies creating and retrieving pages and controls.

    Thanks a lot !
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    06 Apr 2010
    Link to this post
    Hi Lucas,

    You could get the localized pages by using LangID property of the CmsPageInfo object.

    IList listofPages = manager.GetPages(0, int.MaxValue, string.Empty, ListSortDirection.Ascending, out totalRows);
    foreach (CmsPageInfo page in listofPages)
    {
        CultureInfo culture;
        if (page.LangID == CultureInfo.InvariantCulture.LCID)
            culture = LocalizationManager.DefaultCulture;
        else
            culture = CultureInfo.GetCultureInfo(page.LangID);

    You could use HasCurrentLanguageVersion property of the ICmsPage to check whether a given page exists in the current language.

    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.
  3. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    06 Apr 2010
    Link to this post
    Great!

    So, in order to create an alternate version of a given page, I simply use something along the lines of:

    Telerik.Cms.ICmsPage homepage_fr = cmsManager.DuplicatePage(Homepage, "Accueil");
    homepage_fr.LangID = frFRLangId;
    cmsManager.SavePage(homepage_fr)

    am I correct?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    06 Apr 2010
    Link to this post
    Hello Lucas,

    You have to use CopyFromLanguage method.

    Greetings,
    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
  5. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    07 Apr 2010
    Link to this post
    Thanks a lot.

    For future reference (in case someone else needs this), there's a nice example of CopyFromLanguage in the KB:  Automatically create other language versions of the page using Sitefinity API
Register for webinar
5 posts, 1 answered