Localization/Cultures question concerning custom widget and

Posted by Community Admin on 04-Aug-2018 15:37

Localization/Cultures question concerning custom widget and module builder

All Replies

Posted by Community Admin on 28-Sep-2012 00:00

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.


Posted by Community Admin on 10-Oct-2012 00:00

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

Posted by Community Admin on 11-Oct-2012 00:00

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

This thread is closed