Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix errors
  • Loading branch information
Diogo Fernandes committed Dec 2, 2017
commit 6c3341052f7a75b115382765c81f91ec12ffabd9
124 changes: 12 additions & 112 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 25 additions & 24 deletions assets/js/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ var localizedLanguageCodes = {}, localizedLanguageNames = {};
/* global config, getPairs, getGenerators, getAnalyzers, persistChoices, getURLParam, cache, ajaxSend, ajaxComplete, sendEvent,
srcLangs, dstLangs, generators, analyzers, readCache, modeEnabled, populateTranslationList, populateGeneratorList,
populateAnalyzerList, analyzerData, generatorData, curSrcLang, curDstLang, restoreChoices, refreshLangList, onlyUnique */

var newSrc;
var dynamicLocalizations = {
'fallback': {
'Not_Available': 'Translation not yet available!',
'detected': 'detected',
'File_Too_Large': 'File is too large!',
'Format_Not_Supported': 'Format not supported!',
'Download_File': 'Download {{fileName}}'
},
'Suggest_Sentence': 'How would you suggest we translate {{targetWordCode}}?',
'Suggest_Title': 'Improve Apertium\'s translation',
'Suggest_Placeholder': 'New word'
'Download_File': 'Download {{fileName}}',
'Suggest_Sentence': 'How would you suggest we translate {{targetWordCode}}?',
'Suggest_Title': 'Improve Apertium\'s translation',
'Suggest_Placeholder': 'New word'
}
};

function getDynamicLocalization(stringKey) {
Expand All @@ -47,6 +47,24 @@ if(!config.LANGNAMES) {
config.LANGNAMES = {};
}

function getRecaptchaSrc(locale2) {
newSrc = recaptchaScriptSrc + 'en';
var backoff = true;

for(var i = 0; i < localizeRecaptchaLanguages.length; i++) {
if(locale2 === localizeRecaptchaLanguages[i]) {
newSrc = recaptchaScriptSrc + locale2;
backoff = false;
break;
}
}

if(backoff) {
newSrc = recaptchaScriptSrc + localizeReacaptchaAlternativeLanguages[locale2];
}
return newSrc;
}

$(document).ready(function () {
$.each(languages, function (code, language) {
languagesInverse[language] = code;
Expand Down Expand Up @@ -98,7 +116,7 @@ $(document).ready(function () {
$('#suggestRecaptcha').empty();
$.getScript(newSrc);

var placeholder = dynamicLocalizations['Suggest_Placeholder'];
var placeholder = dynamicLocalizations.fallback['Suggest_Placeholder'];
$('#suggestedWordInput').removeAttr('placeholder');
$('#suggestedWordInput').attr('placeholder', placeholder);
});
Expand Down Expand Up @@ -427,23 +445,6 @@ function getLangByCode(dirtyCode) {
}
}

function getRecaptchaSrc(locale2) {
var newSrc = recaptchaScriptSrc + 'en';
var backoff = true;

for(var i = 0; i < localizeRecaptchaLanguages.length; i++) {
if(locale2 === localizeRecaptchaLanguages[i]) {
newSrc = recaptchaScriptSrc + locale2;
backoff = false;
break;
}
}

if(backoff) {
newSrc = recaptchaScriptSrc + localizeReacaptchaAlternativeLanguages[locale2];
}
return newSrc;
}
/*:: export {iso639CodesInverse, iso639Codes, localizeInterface} */

/*:: import {persistChoices} from "./persistence.js" */
Expand Down
Loading