get TermSet Name (Label) by language (LCID)

today is a small story of how i won MS :)

well i decided i want to make a custom navigation based on MMD, and with the site being with variations i need to be able to decide witch language i need.

with Terms its pretty easy, you defauld method "GetDefaultLabel" accepts LCID, but with TermSet it just brings you the default language on the server, if the TermSet has one.

finally i got help from my best friend, System.Reflection, and this is the code:

Dictionary<int, string> names =
    ts.GetType().GetProperty("Names",
    System.Reflection.BindingFlags.NonPublic | 
    System.Reflection.BindingFlags.Instance).
    GetValue(ts) as Dictionary<int, string>;
string label = names.Where(n => n.Key == lcid).First().Value;

Comments

Popular posts from this blog

c# Service Play Sound with NAudio example by Moshe

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem

JS/JQ simulate Enter event