Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to retrieve a Sitecore item using a different language than the current context?

I have a Sitecore layout that generates a vCard from a Sitecore item, including a person's name, business address, etc, and saves it as a file on the web server for later (fast) retrieval. Part of the vCard is the organization (business) name. We're an international firm, which means that across the different locales our firm name is slightly different.

For example, in English our name is [Firm Name] LLP, while in Swedish it is [Firm Name] Advokat AB.

The language context used when generating vCards is English, but the org name is localized within Sitecore. Is it possible to switch from English to another language context to grab the localized org name, and then switch back?

Alternative Approach

The alternative I'm pondering would be to just hard-code the org name in the code, and based on the person's office address output the correct org name. The downside of this would be that I wouldn't be taking advantage of Sitecore's localization capabilities. In addition, there may be other components of the vCard that will eventually be localized - I don't want to hard-code everything.

like image 400
Bob Black Avatar asked Jan 24 '11 19:01

Bob Black


1 Answers

Is this to any help?

Language theLanguage = Sitecore.Globalization.Language.Parse("sv-SE");
Item theOriginalItem = Sitecore.Context.Database.GetItem("/sitecore/content/home/theitem");
Item theLanguageSpecificItem = Sitecore.Context.Database.GetItem(theOriginalItem.ID, theLanguage);
like image 98
Zooking Avatar answered Oct 26 '22 23:10

Zooking