More in this section

Forums / Developing with Sitefinity / Localization/Cultures question concerning custom widget and module builder

Localization/Cultures question concerning custom widget and module builder

3 posts, 0 answered
  1. Chris
    Chris avatar
    12 posts
    Registered:
    10 Aug 2010
    28 Sep 2012
    Link to this post
    Hi. We are working on a site (version 5.0.2860.0) and we have been tasked with adding a new language (culture: en-GB) I have added this in the back end and can add and edit the "translated" pages without issue. 

    We have created some custom widgets that take advantage of the module builder feature to store and manage the data on the back end. For instance we have a carousel slide module that accepts an image and a title and link. I created a custom widget that queries all of the published slides and renders them appropriately this all works great in the default language of English (en).

    Here is the code used to query the slides
    public IQueryable<DynamicContent> RetrieveCollectionOfHomepageCarouselSlides()
      {
             DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
             Type homepageCarouselSlideType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.HomepageCarousel.HomepageCarouselSlide");
     
             // Get the collection of Homepage Carousel Slide items where the slides have been published and order them by priority
             var SlideCollection = dynamicModuleManager.GetDataItems(homepageCarouselSlideType).Where(i => i.Status == ContentLifecycleStatus.Live && i.Visible == true).OrderBy("Priority");
     
             return SlideCollection;
    }

    This is all pretty straightforward however I need to be able to save slides for different languages. I'm certain that I will need to modify the above code for retrieving my slides for the current culture only...or I am completely off base.

    1. Do I need to create some sort of language selector in my module in the backend such as a dropdown allowing the user to select which culture to apply the slide to or does Sitefinity have some way of determining this automatically? Admittedly, I'm new to localization in .NET/Sitefinity and I am trying to get my head around the basic concepts here.

    Thank you in advance.


  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    10 Oct 2012
    Link to this post
    Hi Chris,

    Too bad, but the Module Builder doesn't offer the ability to make use of the multilingual features in Sitefinity.

    So, either make use of the 'Lists' module to be the source of your Carousel slide module, or add some fields to the module builder that need translation (e.g. Title-English, Title-French).

    If you make use of multilingual features, you could add the language selector and if you are not using that, you even can get the current culture throughout the browser.

    Then you could use the CurrentUICulture on the CurrentThread to
    determine the language of the visitor currently browsing your site.

    Regards,
    Daniel
  3. Chris
    Chris avatar
    12 posts
    Registered:
    10 Aug 2010
    11 Oct 2012 in reply to Daniel Plomp
    Link to this post
    Hi Daniel. Thanks for helping out! 

    In the end I added a drop down in module builder and just pre-loaded the cultures for the content editors to select the culture they wanted to apply the slide to. I was then able to get the current culture on the front end to filter against when I query the slides. Its only one additional step for the editors and it seems to work pretty well since there aren't a large number of slides.

    Much appreciated.
    -Chris
3 posts, 0 answered