I'm trying to pull back the labels from a term store for a different locale in SharePoint Online. So I have installed the different language packs in the term store:
And then I have added a TermSet named "Test" with the label "Test 1" in English and "Hungarian 1" in Hungarian. Good Hungarian translation, dont you think?
So now from JSOM I would like to pull back Hungarian 1. This seems simple enough on paper. But in practice doesnt work. So my JSOM code is:
var context = SP.ClientContext.get_current();
var taxonomySession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
var termStore = taxonomySession.getDefaultSiteCollectionTermStore();
var termSets = termStore.getTermSetsByName("Test", "1038"); //tried this with an int instead of a string as well
context.load(taxonomySession);
context.load(termStore);
context.load(termSets);
context.executeQueryAsync(Function.createDelegate(this, function (sender, args) {
var termSetsEnumerator = termSets.getEnumerator();
while(termSetsEnumerator.moveNext())
{
getTermSets(termSetsEnumerator, context, success, error);
}
}), Function.createDelegate(this, function (sender, args) {
errorCallback('Error: ' + args.get_message());
}));
Unless I provide the LCID for English 1033 I dont get any termsets back. Am I doing something wrong? I can see one other individual has had this problem and the suggested solution works but it means doing an executeQueryAsync for EVERY term by using this code:
var context = SP.ClientContext.get_current();
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
var termDefaultValue = taxSession.getTerm(termId).getDefaultLabel(lcid);
context.executeQueryAsync(function() {
success(termDefaultValue);
},
failure);
This surely cannot be right? There must be a way of getting all the terms in 1 language in a bulk collect? The above solution is not viable when you're trying to build a term tree in a different language.
Edit
To show was I mean about what value I expect to get back in English I may have set this value for the label:
But then in (for example) Danish I have Danish on the end, when I pull back the term set name for the Danish LCID and drill into the terms I'd expect to get this label (Test 2 Term Danish), instead I still get the English version of the term (Test 2 Term):