Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public addLanguage() {
this.languages[this.chosenLanguage] = {
name: "",
text: "",
url: "", // TODO: Calculate
isExternal: false,
externalUrl: "",
langName: ISO6391.getName(this.chosenLanguage),
};
this.chosenLanguage = this.availableLanguages[0].code;
}
languages.sort().forEach(id => {
// @ts-ignore
const label: string = languagesDb.getName(id);
if (label) {
result.push(new FilterDto({ id, label }));
}
});
function getLanguageName(langCode) {
if (ISO6391.validate(langCode)) {
return ISO6391.getName(langCode);
} else {
var langInfo = BCP47.parse(langCode);
if (ISO6391.validate(langInfo.language)) {
var name = ISO6391.getName(langInfo.language);
if (name == 'Chinese') {
if (langInfo.region == 'CN') {
name += ' (Simplified)';
} else if (langInfo.region == 'TW') {
name += ' (Traditional)';
}
}
return name;
} else {
return langCode;
}
}
}
renderAvailable(translation) {
if (translation.language !== this.props.TranslationStore.currentLang.language){
let languageName = ISO6391.getName(translation.language.toLowerCase().substr(0,2));
if (languageName){
return (
{value:translation.deck_id , text: languageName}
);
}else{
return;
}
}else{
return;
}
}
render() {
const languageList = languages.map(code => ({ code, name: ISO6391.getName(code) }))
export function generate({ tag, country, name, language }) {
let title = prefix;
if (name || country || tag || language) {
title += ' | ';
if (name) {
title += name;
} else {
if (language) {
title += ` ${ISO6391.getName(language)} speaking `;
}
if (tag) {
title += `${tag} `;
}
title += 'mentors';
if (country) {
title += ` from ${countries[country]}`;
}
}
}
return title;
}
openChooseLanguageModal() {
let that = this;
let tmp = {};
ISO6391.getAllCodes().forEach((code) => {
if(this.languages.includes(''+code))
tmp[''+code] = '' + ISO6391.getName(code) + (((''+code) === that.deckLanguage) ? ' (default)' : '');
});
let dialog = {
titleText: 'Choose your preferred language',
html: '<p>Translations of this deck are available. You may choose one of these to view the slides in this langauge instead of the langauge the presenter chose to present (<strong>'+ISO6391.getName(this.deckLanguage)+'</strong>). You can change your decision at any time. Please keep in mind that not all slides might be translated to your chosen language.</p>',
type: 'info',
input: 'select',
inputValue: this.chosenLanguage,
inputOptions: tmp,
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Okay',
cancelButtonText: 'Cancel',
allowOutsideClick: false,
allowEscapeKey: false,
preConfirm: function (lang) {
return new Promise((resolve, reject) => {
that.changeLanguage(lang);
resolve();
});
available_array = translations.map((translation) => {
let languageName = ISO6391.getName(translation.language.toLowerCase().substr(0,2));
let link = '/deck/';
if (languageName){
if (translation.language !== currentLanguage){
switch (mode){
case 'deck':
link+= translation.deck_id;
return (
<a href="{link}">{languageName}, </a>
);
break;
case 'slide':
return (
<a>{languageName}, </a>
);
break;
case 'subdeck':
function getLanguageName(langCode) {
if (ISO6391.validate(langCode)) {
return ISO6391.getName(langCode);
} else {
var langInfo = BCP47.parse(langCode);
if (ISO6391.validate(langInfo.language)) {
var name = ISO6391.getName(langInfo.language);
if (name == 'Chinese') {
if (langInfo.region == 'CN') {
name += ' (Simplified)';
} else if (langInfo.region == 'TW') {
name += ' (Traditional)';
}
}
return name;
} else {
return langCode;
}
}