diff --git a/src/meta/languages.js b/src/meta/languages.js index 36611f1b9a..4d845cc2e1 100644 --- a/src/meta/languages.js +++ b/src/meta/languages.js @@ -99,7 +99,12 @@ async function buildNamespaceLanguage(lang, namespace, plugins) { } async function addPlugin(translations, pluginData, lang, namespace) { - const pluginLanguages = path.join(paths.nodeModules, pluginData.id, pluginData.languages); + // if plugin doesn't have this namespace no need to continue + if (pluginData.languageData && !pluginData.languageData.namespaces.includes(namespace)) { + return; + } + + const pathToPluginLanguageFolder = path.join(paths.nodeModules, pluginData.id, pluginData.languages); const defaultLang = pluginData.defaultLang || 'en-GB'; // for each plugin, fallback in this order: @@ -116,7 +121,7 @@ async function addPlugin(translations, pluginData, lang, namespace) { for (const language of langs) { /* eslint-disable no-await-in-loop */ - await assignFileToTranslations(translations, path.join(pluginLanguages, language, `${namespace}.json`)); + await assignFileToTranslations(translations, path.join(pathToPluginLanguageFolder, language, `${namespace}.json`)); } } diff --git a/src/plugins/data.js b/src/plugins/data.js index e66bd74e9a..8eb1c79452 100644 --- a/src/plugins/data.js +++ b/src/plugins/data.js @@ -3,6 +3,7 @@ const fs = require('fs'); const path = require('path'); const winston = require('winston'); +const _ = require('lodash'); const db = require('../database'); const file = require('../file'); @@ -245,9 +246,8 @@ Data.getLanguageData = async function getLanguageData(pluginData) { languages.push(language); namespaces.push(namespace); }); - return { - languages, - namespaces, + languages: _.uniq(languages), + namespaces: _.uniq(namespaces), }; }; diff --git a/src/plugins/load.js b/src/plugins/load.js index 1ee74b5b24..99ee26df3d 100644 --- a/src/plugins/load.js +++ b/src/plugins/load.js @@ -63,6 +63,7 @@ module.exports = function (Plugins) { if (results.languageData) { Plugins.languageData.languages = _.union(Plugins.languageData.languages, results.languageData.languages); Plugins.languageData.namespaces = _.union(Plugins.languageData.namespaces, results.languageData.namespaces); + pluginData.languageData = results.languageData; } Plugins.pluginsData[pluginData.id] = pluginData; }