Skip to content

Commit

Permalink
reconfigure i18n to ensure the default locale and locales lists match…
Browse files Browse the repository at this point in the history
… what workflow module expects so it does not suddenly start defaulting to the wrong locale now that apostrophe-i18n and apostrophe-workflow are friends
  • Loading branch information
Thomas Boutell committed Dec 13, 2018
1 parent c94def1 commit 757494d
Show file tree
Hide file tree
Showing 26 changed files with 39 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/implementation.js
Expand Up @@ -383,9 +383,23 @@ module.exports = function(self, options) {
};

self.modulesReady = function(callback) {
self.reconfigureI18n();
return self.ensureIndexes(callback);
};

// Reconfigure the i18n module with knowledge of the locales in
// use for workflow. Necessary otherwise conflicting configurations
// in older workflow sites will suddenly fail now that i18n is
// aware of workflow locales
self.reconfigureI18n = function() {
var options = self.apos.modules['apostrophe-i18n'].options;
options.locales = _.filter(_.keys(self.locales), function(locale) {
return !locale.match(/-draft$/);
});
options.defaultLocale = self.defaultLocale;
self.apos.i18n.configure(options);
};

self.ensureIndexes = function(callback) {

return Promise.try(function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware.js
Expand Up @@ -185,4 +185,4 @@ module.exports = function(self, options) {
}
};

};
};
1 change: 1 addition & 0 deletions test/locales/de-de-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/de-de.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/de-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/de.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/default-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/default.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/es-CO-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/es-CO.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/es-MX-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/es-MX.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/es-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/es.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/fr-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/fr.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-de-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-de.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-en-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-en.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-es-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-es.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-fr-draft.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us-fr.json
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/locales/us.json
@@ -0,0 +1 @@
{}

0 comments on commit 757494d

Please sign in to comment.