Get the current project
Created by Richard Saunders, last modified by noellambertwork on 21 Dec 2017
Requesting the current project can be achieved by using the get method on the client's project property.
get(): Promise<Project>
Returns
A Promise that will resolve with the Project
<select id="language_selector"></select>
(function(Zengenti) {
// Create a client
var client = Zengenti.Contensis.Client.create();
$(function() {
// Get the current project
client.project.get().then(function(currentProject) {
for (var i = 0, ilen = currentProject.supportedLanguages.length; i < ilen; i++) {
// loop through the project's supported languages and add them to the language selector
var lang = currentProject.supportedLanguages[i];
// check if the supported language is the primary language, if it is select the option
var selected = (lang === currentProject.primaryLanguage) ? 'selected' : '';
var option = $('<option />')
.val(lang)
.text(lang)
.attr('selected', selected);
$('#language_selector').append(option);
}
}, function(error) {
console.error(error);
});
});
})(Zengenti);