mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-10-27 07:03:41 +03:00
Added i18n service to Ghost core
refs https://github.com/TryGhost/Ghost/issues/15502 - this adds the scaffolding for enabling i18n translations within Ghost core - also adds `yarn translate:ghost` as an option to the `i18n` package - the locale is currently hardcoded to `en` so we don't utilize the translations until we're ready
This commit is contained in:
parent
0273ba2066
commit
21ea426794
@ -102,6 +102,11 @@ async function initCore({ghostServer, config, bootLogger, frontend}) {
|
||||
await settings.syncEmailSettings(config.get('hostSettings:emailVerification:verified'));
|
||||
debug('End: settings');
|
||||
|
||||
debug('Begin: i18n');
|
||||
const i18n = require('./server/services/i18n');
|
||||
await i18n.init();
|
||||
debug('End: i18n');
|
||||
|
||||
// The URLService is a core part of Ghost, which depends on models.
|
||||
debug('Begin: Url Service');
|
||||
const urlService = require('./server/services/url');
|
||||
|
14
ghost/core/core/server/services/i18n.js
Normal file
14
ghost/core/core/server/services/i18n.js
Normal file
@ -0,0 +1,14 @@
|
||||
//const debug = require('@tryghost/debug')('i18n');
|
||||
const i18n = require('@tryghost/i18n');
|
||||
|
||||
module.exports.init = function () {
|
||||
//const events = require('../lib/common/events');
|
||||
//const settingsCache = require('../../shared/settings-cache');
|
||||
|
||||
module.exports = i18n(/* settingsCache.get('locale') */ 'en', 'ghost');
|
||||
|
||||
/*events.on('settings.locale.edited', (model) => {
|
||||
debug('locale changed, updating i18n to', model.get('value'));
|
||||
i18nInstance.changeLanguage(model.get('value'));
|
||||
});*/
|
||||
};
|
@ -88,6 +88,7 @@
|
||||
"@tryghost/helpers": "1.1.76",
|
||||
"@tryghost/html-to-plaintext": "0.0.0",
|
||||
"@tryghost/http-cache-utils": "0.1.7",
|
||||
"@tryghost/i18n": "0.0.0",
|
||||
"@tryghost/image-transform": "1.2.4",
|
||||
"@tryghost/importer-handler-content-files": "0.0.0",
|
||||
"@tryghost/importer-revue": "0.0.0",
|
||||
|
@ -4,7 +4,7 @@ const SUPPORTED_LOCALES = ['en', 'nl'];
|
||||
|
||||
/**
|
||||
* @param {string} [lng]
|
||||
* @param {'portal'|'test'} ns
|
||||
* @param {'ghost'|'portal'|'test'} ns
|
||||
*/
|
||||
module.exports = (lng = 'en', ns = 'portal') => {
|
||||
const i18nextInstance = i18next.createInstance();
|
||||
|
1
ghost/i18n/locales/en/ghost.json
Normal file
1
ghost/i18n/locales/en/ghost.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
1
ghost/i18n/locales/nl/ghost.json
Normal file
1
ghost/i18n/locales/nl/ghost.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
@ -12,7 +12,8 @@
|
||||
"lint:code": "eslint *.js lib/ --ext .js --cache",
|
||||
"lint": "yarn lint:code && yarn lint:test",
|
||||
"lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache",
|
||||
"translate": "yarn translate:portal && yarn translate:test",
|
||||
"translate": "yarn translate:ghost && yarn translate:portal && yarn translate:test",
|
||||
"translate:ghost": "NAMESPACE=ghost i18next '../core/core/{frontend,server,shared}/**/*.{js,jsx}'",
|
||||
"translate:portal": "NAMESPACE=portal i18next '../portal/src/**/*.{js,jsx}'",
|
||||
"translate:test": "NAMESPACE=test i18next './test/**/*.js'"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user