{"id":43,"date":"2011-06-09T00:07:22","date_gmt":"2011-06-09T04:07:22","guid":{"rendered":"http:\/\/blogs.visigo.com\/chriscoulson\/?p=43"},"modified":"2011-06-20T21:55:02","modified_gmt":"2011-06-21T01:55:02","slug":"getting-the-localized-taxonomyfieldvalue","status":"publish","type":"post","link":"https:\/\/blogs.visigo.com\/chriscoulson\/getting-the-localized-taxonomyfieldvalue\/","title":{"rendered":"Getting the Localized TaxonomyFieldValue"},"content":{"rendered":"<p>Let&#8217;s say you have a Managed Metadata column in a SharePoint list, and you want to get the value for that column from an item in the list. Easy right?<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n(item&#x5B;&quot;MyMetadataColumnName&quot;] as TaxonomyFieldValue).Label\r\n<\/pre>\n<p>One problem though. It doesn&#8217;t matter what the current Culture is, you&#8217;ll always get back the default label. If you want to get the localized label, you need to do a whole lot more:<\/p>\n<ul>\n<li>Create a TaxonomySession<\/li>\n<li>Get the Term Store for the site collection<\/li>\n<li>Get the term from the guid of the TaxonomyFieldValue<\/li>\n<li>And finally&#8230; Get the label from the term for the specified culture<\/li>\n<\/ul>\n<p>Here&#8217;s the code:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\r\nTaxonomyFieldValue value =item&#x5B;&quot;MyMetadataColumnName&quot;] as TaxonomyFieldValue;\r\n\r\nTaxonomySession session = new TaxonomySession(SPContext.Current.Site);\r\n\r\nString localizedValue = session.DefaultSiteCollectionTermStore.GetTerm(new Guid(value.TermGuid)).GetDefaultLabel(CultureInfo.CurrentUICulture.LCID);\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s say you have a Managed Metadata column in a SharePoint list, and you want to get the value for that column from an item in the list. Easy right? (item&#x5B;&quot;MyMetadataColumnName&quot;] as TaxonomyFieldValue).Label One problem though. It doesn&#8217;t matter what the current Culture is, you&#8217;ll always get back the default label. If you want to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52,5],"tags":[55,56,63,65,53,61,318,64,47,317,54,22,24,49,50,51,48,57,58,59,62,60],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry","category-localization","category-sharepoint","tag-culture","tag-cultureinfo","tag-defaultsitecollectiontermstore","tag-getdefaultlabel","tag-globalization","tag-label","tag-localization","tag-localized","tag-managed-metadata","tag-metadata","tag-resource","tag-sharepoint-2","tag-sharepoint-2010","tag-taxonomy","tag-taxonomy-field","tag-taxonomy-field-value","tag-taxonomyfieldvalue","tag-taxonomysession","tag-term","tag-term-store","tag-termguid","tag-termstore"],"_links":{"self":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":0,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}