mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +09:00
Map locale from modules into the save's locale
Map locale files located at locale/{lang}/{file} in a module to
locale/{lang}/{module-name}-{file} in the save. This additionally
support a shorthand notation by mapping locale/{lange}.cfg to
locale/{lang}/{module-name}.cfg.
Resolves #500.
This commit is contained in:
1 parent
a1148c7ec9
commit
cc8ec36e5a
5 files changed
+47
-1
No files matched your search
@@ -0,0 +1 @@
|
||||
module-test=A Test
|
||||
@@ -0,0 +1 @@
|
||||
module-test-locale=Test Locale
|
||||
@@ -9,6 +9,27 @@ const patch = require("@clusterio/host/dist/src/patch");
|
||||
|
||||
|
||||
describe("host/patch", function() {
|
||||
describe("class SaveModule", function() {
|
||||
describe("static moduleFilePath()", function() {
|
||||
it("Should remap locale files", function() {
|
||||
const mappings = [
|
||||
["locale/en/foo.cfg", "locale/en/test-foo.cfg"],
|
||||
["locale/en/foo.txt", "locale/en/test-foo.txt"],
|
||||
["locale/en/foo.txt.tmp", "locale/en/test-foo.txt.tmp"],
|
||||
["locale/en/foo", "locale/en/test-foo"],
|
||||
["locale/en.cfg", "locale/en/test.cfg"],
|
||||
["locale/en.txt", "locale/en/test.txt"],
|
||||
["locale/en.txt.tmp", "locale/en/test.txt.tmp"],
|
||||
["locale/en", "locale/en/test"],
|
||||
["locale/en/bar/foo.cfg", "locale/en/test-bar/foo.cfg"],
|
||||
];
|
||||
for (let [input, expected] of mappings) {
|
||||
assert.equal(patch.SaveModule.moduleFilePath(input, "test"), expected);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("generateLoader()", function() {
|
||||
let reference = [
|
||||
"-- Auto generated scenario module loader created by Clusterio",
|
||||
|
||||
@@ -27,6 +27,14 @@ describe("Integration of lib/factorio/patch", function() {
|
||||
let zip = await JSZip.loadAsync(await fs.readFile(savePath));
|
||||
assert.equal(await zip.file("test/modules/test/test.lua").async("string"), "-- test\n");
|
||||
assert.equal(await zip.file("test/modules/subdir/dir/test.lua").async("string"), "-- test\n");
|
||||
assert.equal(
|
||||
await zip.file("test/locale/en/test.cfg").async("string"),
|
||||
"module-test=A Test\n"
|
||||
);
|
||||
assert.equal(
|
||||
await zip.file("test/locale/en/test-locale.cfg").async("string"),
|
||||
"module-test-locale=Test Locale\n"
|
||||
);
|
||||
});
|
||||
it("should remove old modules in a save", async function() {
|
||||
slowTest(this);
|
||||
|
||||
Reference in new issue
Block a user