Implement locale trenslation of resource names

Translate the names of the resources using the exported Factorio locale.
This commit is contained in:
Hornwitser committed 2020-05-26 01:12:05 +02:00
1 parent 260f976fa3
commit 453226f246
1 file changed
+18 -3
+18 -3
View File
@@ -35,10 +35,25 @@ function drawcontents(data) {
if (itemIcon.getAttribute("class") !== iconClass) {
itemIcon.setAttribute("class", iconClass);
}
let localeName = item.name;
let meta = factorioItemMetadata.get(item.name);
if (meta && meta.localised_name) {
// TODO implement the locale to name conversion.
localeName = factorioLocale.get(meta.localised_name[0]);
} else {
for (let section of ["item-name", "entity-name", "fluid-name", "equipment-name"]) {
let name = factorioLocale.get(`${section}.${item.name}`);
if (name) {
localeName = name;
break;
}
}
}
const name = row.querySelector('.name');
if(name.textContent !== item.name) {
name.textContent = item.name;
if(name.textContent !== localeName) {
name.textContent = localeName;
}
const count = row.querySelector('.count');