mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Implement locale trenslation of resource names
Translate the names of the resources using the exported Factorio locale.
This commit is contained in:
1 parent
260f976fa3
commit
453226f246
1 file changed
+18
-3
@@ -35,10 +35,25 @@ function drawcontents(data) {
|
|||||||
if (itemIcon.getAttribute("class") !== iconClass) {
|
if (itemIcon.getAttribute("class") !== iconClass) {
|
||||||
itemIcon.setAttribute("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');
|
const name = row.querySelector('.name');
|
||||||
if(name.textContent !== item.name) {
|
if(name.textContent !== localeName) {
|
||||||
name.textContent = item.name;
|
name.textContent = localeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const count = row.querySelector('.count');
|
const count = row.querySelector('.count');
|
||||||
|
|||||||
Reference in new issue
Block a user