1
votes

I am implementing Locale/Culture Specific Media Library Items i.e different set of images and styles for different Locale/Culture.

I followed the approach as in the below blog http://sitecorejohn.wordpress.com/2010/04/30/dynamic-source-property-for-sitecore-image-fields/

But in addition to above I have to maintain a locale folder and store image items beneath them. For example, If my site root is SiteA and has en-US and es-US locale/Culture then Media Library looks as below: /sitecore/media library/SiteA/en-US and /sitecore/media library/SiteA/es-US .So when a content editor is in es-US and wants to select a Image then /sitecore/media library/SiteA/es-US should open up.

I tried to access the locale information but I always get "en", as the Context site will be "shell" when using content editor. Can anybody throw some light to implement the above?

Thanks, Suhas

3

3 Answers

0
votes

If you go to your <sites> section in the web.config, you'll see that the site with the name Shell is defined there.

Content Editor (and Desktop for that matter) runs under Shell:
http://yoursite/sitecore/shell/Applications/Content%20editor.aspx for Content Editor
http://yoursite/sitecore/shell/default.aspx for Desktop.

In that definition:

<site name="shell" virtualFolder="/sitecore/shell" physicalFolder="/sitecore/shell" rootPath="/sitecore/content" startItem="/home" language="en" database="core" domain="sitecore" loginPage="/sitecore/login" content="master" contentStartItem="/Home" ..." />

As you can see, the languange is set to en by default.

0
votes

If I understand you correctly, you need the current contentlanguage the content editor is in. In your code use this to get the current content language:

System.Globalization.CultureInfo culture = Sitecore.Context.ContentLanguage.CultureInfo;

If you have the culture that is defined for the current content language, you can set the correct path to the media library.

0
votes

You can do what you want using security, but it will be complex to do.

First, you will need an editor account per language and you will need to create roles to DENY read & write access for each language.

Example:

Languages: en-US, fr-CA Roles: Deny_enUS, Deny_frCA

Create a user for editing en-US and add the Deny_frCA role to it. Add another user for editing fr-CA and add the Deny_enUS role to it.

Now go to the language settings in /sitecore/system/lanaguages and for en-US add the role Deny_enUS and click the X for Item and Descendants on Language Read and Language Write. Do the same for fr-CA with the Deny_frCA role.

Now setup your source for your image pickers to be the root of all the local specific image folders, so if you have /sitecore/media library/SiteA/enUS and /sitecore/media library/SiteA/frCA set the source too /sitecore/media library/SiteA.

Finally make sure that the /sitecore/media library/SiteA/enUS has a version in en-US and no other languages and that /sitecore/media library/SiteA/frCA as a version in fr-CA and no other languages.

Now when each user logs in, they should only be able to see the folder in the language they are editing. Make sure that the default content language for each user is set correctly.

Its not a pretty way of doing it, but it worked for a big site I worked on. It can be a pain to maintain if you have a lot of languages tho.