javascript - Add additional file to global path in nodeJS -
i new nodejs/ javascript , want add additional file global variable declaration. idear:
i want add language file global path
var getlanguage = require('./language.js'); module.exports = { retryassertiontimeout: 2000, url:'https://10.99.8.81', language: getlanguage.de_de,
in language file have 2 definitions, 1 german , 1 english.
so if change
language: getlanguage.de_de,
to
language: getlanguage.en_en,
i want change used langugage.
the declaration in language file looks like:
module.exports = { de_de: { verzeichnisse: "verzeichnisse", benachrichtigungen: "benachrichtigungen", berichte: "berichte", ftp_server: "ftp server", } };
in functions call
var data = client.globals; var language = data.language; .goto(language.benutzer) //benutzer declared in full file.
but not work.
any idears?
[laguage.js] var chinese = { game : "游戏" } var english = { game : "game" } function getlanguage(type) { if (type == 1) { return chinese; } else if (type == 2) { return english; } } exports.getlanguage = getlanguage; [main.js] var getlanguage = require('./language.js'); var language = getlanguage.getlanguage(1); console.log(language); [result] { game: '游戏'}
Comments
Post a Comment