mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
GET /api/getFactorioLocale now returns entire base en locale
This commit is contained in:
1 parent
5d294c3a62
commit
8acbd707f9
5 files changed
+117
-3
No files matched your search
@@ -0,0 +1,29 @@
|
||||
const fs = require("fs");
|
||||
const ini = require("ini");
|
||||
|
||||
function getLocale(factorioDirectory, languageCode, callback){
|
||||
var localeFile = factorioDirectory + '/data/base/locale/' + languageCode + '/base.cfg';
|
||||
fs.readFile(localeFile, "utf8", (err, rawLocale) => {
|
||||
callback(err, rawLocale);
|
||||
});
|
||||
}
|
||||
|
||||
function getLocaleAsObject(factorioDirectory, languageCode, callback){
|
||||
if(typeof factorioDirectory != "string" || typeof languageCode != "string" || typeof callback != "function"){
|
||||
throw "Error: wrong parameters provided";
|
||||
}
|
||||
getLocale(factorioDirectory, languageCode, (err, rawLocale) => {
|
||||
if(err){
|
||||
callback(err);
|
||||
} else {
|
||||
let processedLocale = ini.parse(rawLocale)
|
||||
callback(undefined, processedLocale);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
asObject: getLocaleAsObject,
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user