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

1

7

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.

Breve answered 24/1, 2011 at 19:5 Comment(0)
V
17

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);
Vlada answered 25/1, 2011 at 5:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.