mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Started to add translated text.
This commit is contained in:
@@ -700,7 +700,7 @@ var messageDialogProto = Object.create(HTMLDialogElement.prototype, {
|
||||
this.getElementsByClassName('cancel')[0].addEventListener('click', this.onButtonClick, false);
|
||||
|
||||
if (type == 'error' || type == 'info') {
|
||||
this.getElementsByClassName('accept')[0].textContent = 'OK';
|
||||
this.getElementsByClassName('accept')[0].textContent = l10n.translate("OK").fetch();
|
||||
this.getElementsByClassName('cancel')[0].classList.toggle('hidden', true);
|
||||
}
|
||||
|
||||
@@ -728,12 +728,12 @@ var messageDialogProto = Object.create(HTMLDialogElement.prototype, {
|
||||
|
||||
var accept = document.createElement('button');
|
||||
accept.className = 'accept';
|
||||
accept.textContent = 'Yes';
|
||||
accept.textContent = l10n.translate("Yes").fetch();
|
||||
buttons.appendChild(accept);
|
||||
|
||||
var cancel = document.createElement('button');
|
||||
cancel.className = 'cancel';
|
||||
cancel.textContent = 'Cancel';
|
||||
cancel.textContent = l10n.translate("Cancel").fetch();
|
||||
buttons.appendChild(cancel);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -38,9 +38,16 @@
|
||||
});
|
||||
},
|
||||
|
||||
applyLocale: function(locale) {
|
||||
this.loadLocaleData(locale).then(function(result){
|
||||
console.log(result);
|
||||
translateStaticText: function(l10n) {
|
||||
document.getElementById('hideVersionNumbers').nextElementSibling.textContent = l10n.translate("Hide version numbers").fetch();
|
||||
},
|
||||
|
||||
getJedInstance: function(locale) {
|
||||
return this.loadLocaleData(locale).then(function(result){
|
||||
return new jed({
|
||||
'locale_data': result,
|
||||
'domain': 'messages'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -241,12 +241,12 @@ var loot = {
|
||||
if (change.object[change.name] && change.object[change.name].revision) {
|
||||
document.getElementById('masterlistRevision').textContent = change.object[change.name].revision;
|
||||
} else {
|
||||
document.getElementById('masterlistRevision').textContent = 'N/A';
|
||||
document.getElementById('masterlistRevision').textContent = l10n.translate("N/A").fetch();
|
||||
}
|
||||
if (change.object[change.name] && change.object[change.name].date) {
|
||||
document.getElementById('masterlistDate').textContent = change.object[change.name].date;
|
||||
} else {
|
||||
document.getElementById('masterlistDate').textContent = 'N/A';
|
||||
document.getElementById('masterlistDate').textContent = l10n.translate("N/A").fetch();
|
||||
}
|
||||
} else if (change.name == 'globalMessages') {
|
||||
/* For the messages, they don't have a JS 'class' so need to everything
|
||||
@@ -517,7 +517,7 @@ function applyFilters(evt) {
|
||||
if (messages[j].className.indexOf('say') != -1) {
|
||||
hasNotes = true;
|
||||
}
|
||||
if (messages[j].textContent.indexOf('Do not clean.') != -1) {
|
||||
if (messages[j].textContent.indexOf(l10n.translate("Do not clean.").fetch()) != -1) {
|
||||
hasDoNotCleanMessages = true;
|
||||
}
|
||||
if ((document.getElementById('hideAllPluginMessages').checked && hasPluginMessages)
|
||||
@@ -1296,10 +1296,6 @@ function initVars() {
|
||||
loot.query('getSettings'),
|
||||
];
|
||||
|
||||
if (!result) {
|
||||
parallelPromises.push(loot.query('getGameData'));
|
||||
}
|
||||
|
||||
updateProgressDialog('Initialising user interface...');
|
||||
openProgressDialog();
|
||||
Promise.all(parallelPromises).then(function(results) {
|
||||
@@ -1326,33 +1322,37 @@ function initVars() {
|
||||
console.log('getInstalledGames response: ' + results[1]);
|
||||
}
|
||||
|
||||
if (results.length > 3) {
|
||||
try {
|
||||
var game = JSON.parse(results[3], jsonToPlugin);
|
||||
loot.game.folder = game.folder;
|
||||
loot.game.masterlist = game.masterlist;
|
||||
loot.game.globalMessages = game.globalMessages;
|
||||
loot.game.plugins = game.plugins;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log('getGameData response: ' + results[3]);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
loot.settings = JSON.parse(results[2]);
|
||||
applySavedFilters();
|
||||
l10n.applyLocale(loot.settings.language);
|
||||
l10n.getJedInstance(loot.settings.language).then(function(jed){
|
||||
l10n.translateStaticText(jed);
|
||||
l10n = jed;
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log('getSettings response: ' + results[2]);
|
||||
}
|
||||
|
||||
if (results.length == 3) {
|
||||
document.getElementById('settingsButton').click();
|
||||
}
|
||||
if (!result) {
|
||||
loot.query('getGameData').then(function(result){
|
||||
try {
|
||||
var game = JSON.parse(result, jsonToPlugin);
|
||||
loot.game.folder = game.folder;
|
||||
loot.game.masterlist = game.masterlist;
|
||||
loot.game.globalMessages = game.globalMessages;
|
||||
loot.game.plugins = game.plugins;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log('getGameData response: ' + results[3]);
|
||||
}
|
||||
|
||||
closeProgressDialog();
|
||||
applySavedFilters();
|
||||
closeProgressDialog();
|
||||
}).catch(processCefError);
|
||||
} else {
|
||||
document.getElementById('settingsButton').click();
|
||||
closeProgressDialog();
|
||||
}
|
||||
|
||||
/* So much easier than trying to set up my own C++ message loop to listen
|
||||
to window messages looking for a focus change. */
|
||||
|
||||
Reference in New Issue
Block a user