mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 16:30:34 +01:00
committed by
Julian Lam
parent
dc6fc65322
commit
ecf212d307
@@ -3,7 +3,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const utils = require('./utils');
|
||||
const paths = require('./constants').paths;
|
||||
const { paths } = require('./constants');
|
||||
const plugins = require('./plugins');
|
||||
|
||||
const Languages = module.exports;
|
||||
const languagesPath = path.join(__dirname, '../build/public/language');
|
||||
@@ -12,8 +13,14 @@ const files = fs.readdirSync(path.join(paths.nodeModules, '/timeago/locales'));
|
||||
Languages.timeagoCodes = files.filter(f => f.startsWith('jquery.timeago')).map(f => f.split('.')[2]);
|
||||
|
||||
Languages.get = async function (language, namespace) {
|
||||
const data = await fs.promises.readFile(path.join(languagesPath, language, namespace + '.json'), 'utf8');
|
||||
return JSON.parse(data) || {};
|
||||
const data = await fs.promises.readFile(path.join(languagesPath, language, `${namespace}.json`), 'utf8');
|
||||
const parsed = JSON.parse(data) || {};
|
||||
const result = await plugins.hooks.fire('filter:languages.get', {
|
||||
language,
|
||||
namespace,
|
||||
data: parsed,
|
||||
});
|
||||
return result.data;
|
||||
};
|
||||
|
||||
let codeCache = null;
|
||||
|
||||
Reference in New Issue
Block a user