mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Fix translations requirement and plugin build
This commit is contained in:
parent
650e7dd6cb
commit
64029c66d9
@ -29,12 +29,6 @@ import { translationMessages, languages } from './i18n';
|
||||
const remoteURL = process.env.REMOTE_URL || 'http://localhost:1337/admin';
|
||||
const backendURL = process.env.BACKEND_URL || 'http://localhost:1337';
|
||||
|
||||
window.strapi = {
|
||||
remoteURL,
|
||||
backendURL,
|
||||
languages,
|
||||
};
|
||||
|
||||
// Create redux store with history
|
||||
const initialState = {};
|
||||
const history = createHistory({
|
||||
@ -146,7 +140,9 @@ const displayNotification = (message, status) => {
|
||||
store.dispatch(showNotification(message, status));
|
||||
};
|
||||
|
||||
window.strapi = Object.assign(window.strapi, {
|
||||
window.strapi = {
|
||||
remoteURL,
|
||||
backendURL,
|
||||
registerPlugin,
|
||||
notification: {
|
||||
success: (message) => {
|
||||
@ -171,7 +167,8 @@ window.strapi = Object.assign(window.strapi, {
|
||||
},
|
||||
}),
|
||||
router: history,
|
||||
});
|
||||
languages,
|
||||
};
|
||||
|
||||
const dispatch = store.dispatch;
|
||||
export {
|
||||
|
||||
@ -12,19 +12,21 @@ const pluginId = pkg.name.replace(/^strapi-/i, '');
|
||||
|
||||
// Define remote and backend URLs.
|
||||
const URLs = {
|
||||
remote: '',
|
||||
backend: ''
|
||||
remote: null,
|
||||
backend: null
|
||||
};
|
||||
|
||||
const serverConfig = path.resolve(process.env.PWD, '..', 'config', 'environments', _.lowerCase(process.env.NODE_ENV), 'server.json');
|
||||
if (process.env.PWD.indexOf('/admin') !== -1) {
|
||||
const serverConfig = path.resolve(process.env.PWD, '..', 'config', 'environments', _.lowerCase(process.env.NODE_ENV), 'server.json');
|
||||
|
||||
try {
|
||||
const server = require(serverConfig);
|
||||
try {
|
||||
const server = require(serverConfig);
|
||||
|
||||
URLs.remote = _.get(server, 'admin.remoteURL', null) ? _.get(server, 'admin.remoteURL', null) : `http://${_.get(server, 'host', 'localhost')}:${_.get(server, 'port', 1337)}/admin`;
|
||||
URLs.backend = _.get(server, 'admin.backendURL', null) ? _.get(server, 'admin.backendURL', null) : `http://${_.get(server, 'host', 'localhost')}:${_.get(server, 'port', 1337)}`;
|
||||
} catch (e) {
|
||||
throw new Error('Impossible to open ' + serverConfig);
|
||||
URLs.remote = _.get(server, 'admin.remoteURL', null) ? _.get(server, 'admin.remoteURL', null) : `http://${_.get(server, 'host', 'localhost')}:${_.get(server, 'port', 1337)}/admin`;
|
||||
URLs.backend = _.get(server, 'admin.backendURL', null) ? _.get(server, 'admin.backendURL', null) : `http://${_.get(server, 'host', 'localhost')}:${_.get(server, 'port', 1337)}`;
|
||||
} catch (e) {
|
||||
throw new Error('Impossible to open ' + serverConfig);
|
||||
}
|
||||
}
|
||||
|
||||
// Load plugins into the same build in development mode.
|
||||
|
||||
@ -34,7 +34,7 @@ const formatMessages = messages => reduce(messages, (result, value, key) => {
|
||||
*/
|
||||
const requireTranslations = language => {
|
||||
try {
|
||||
return require(`/translations/${language}.json`); // eslint-disable-line global-require
|
||||
return require(`translations/${language}.json`); // eslint-disable-line global-require
|
||||
} catch (error) {
|
||||
console.error(`Unable to load "${language}" translation for the plugin ${pluginId}. Please make sure "${language}.json" file exists in "pluginPath/admin/src/translations" folder.`);
|
||||
return false;
|
||||
@ -45,9 +45,7 @@ const requireTranslations = language => {
|
||||
* Dynamically generate `translationsMessages object`.
|
||||
*/
|
||||
|
||||
console.log(window.strapi);
|
||||
|
||||
const translationMessages = reduce(window.strapi.languages, (result, language) => {
|
||||
const translationMessages = reduce(strapi.languages, (result, language) => {
|
||||
const obj = result;
|
||||
const messages = requireTranslations(language);
|
||||
obj[language] = formatMessages(messages);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user