Martin Hickey 2016-08-18 15:09:22 +01:00
parent 2dd3065856
commit db11a2db24
9 changed files with 15 additions and 30 deletions

View file

@ -186,7 +186,6 @@
"event-stream": "3.3.2",
"expect.js": "0.3.1",
"faker": "1.1.0",
"fs-extra": "0.30.0",
"grunt": "1.0.1",
"grunt-aws-s3": "0.14.5",
"grunt-babel": "5.0.1",

View file

@ -1,4 +1,4 @@
{
"name": "i18n",
"version": "1.0.0"
"version": "kibana"
}

View file

@ -7,11 +7,11 @@ API:
Register translations:
registerTranslations(<absolute_path_to_translation_file>)
The translation file will be bundled into one translation file per locale and stored in the Kibana data directory. Returns a Promise object.
The translation file is registered with i18n plugin. The plugin contains a list of registered translation file paths per language.
Fetch the list of currently supported locales:
Promise getRegisteredTranslationLocales()
Returns a Promise object which will contain on resolve a list of all locales as locale codes for which translations are registered
List getRegisteredTranslationLocales()
Returns a list of all locales as locale codes for which translations are registered
Fetch a specific locale translated content bundle:
Promise getRegisteredLocaleTranslations(<locale_code>)

View file

@ -1,11 +1,9 @@
import Promise from 'bluebird';
import { mkdirp as mkdirpNode } from 'mkdirp';
import manageUuid from './server/lib/manage_uuid';
import fs from 'fs';
import i18nPlugin from '../i18n/server/i18n/index';
import ingest from './server/routes/api/ingest';
import kibanaPackage from '../../utils/package_json';
import Promise from 'bluebird';
import fromRoot from '../../utils/from_root';
import search from './server/routes/api/search';
import settings from './server/routes/api/settings';
import scripts from './server/routes/api/scripts';
@ -127,17 +125,7 @@ module.exports = function (kibana) {
function registerCoreTranslations()
{
const rootDir = kibanaPackage.__dirname;
//Add translation dirs for the core plugins here
const corePluginTranslationDirs = [rootDir + '/src/ui/i18n'];
return Promise.map(corePluginTranslationDirs, (dir) => {
readdir(dir).then((dirListing) => {
Promise.map(dirListing, (listing) => {
const fullFilePath = dir + '/' + listing;
i18nPlugin.registerTranslations(fullFilePath);
});
});
});
const corePluginTranslationFile = fromRoot('/src/core_plugins/kibana/i18n/en.json');
console.log('!! Regsiter file: ', corePluginTranslationFile);
i18nPlugin.registerTranslations(corePluginTranslationFile);
}

View file

@ -19,13 +19,11 @@ module.exports = async (kbnServer, server, config) => {
server.exposeStaticDir('/bundles/{path*}', bundles.env.workingDir);
await bundles.writeEntryFiles();
// in prod, only bundle what looks invalid or missing
if (config.get('optimize.useBundleCache')) {
bundles = await bundles.getInvalidBundles();
}
// in prod, only bundle when someing is missing or invalid
let invalidBundles = config.get('optimize.useBundleCache') ? await bundles.getInvalidBundles() : bundles;
// we might not have any work to do
if (!bundles.getIds().length) {
if (!invalidBundles.getIds().length) {
server.log(
['debug', 'optimize'],
`All bundles are cached and ready to go!`

View file

@ -142,7 +142,7 @@ function translate(key) {
return kibanaTranslations[key];
}
async function getTranslationLocale(acceptLanguages) {
function getTranslationLocale(acceptLanguages) {
let localeStr = '';
let foundLang = false;
@ -151,7 +151,7 @@ async function getTranslationLocale(acceptLanguages) {
}
const acceptLangsLen = acceptLanguages.length;
const registeredLocales = await i18nPlugin.getRegisteredTranslationLocales();
const registeredLocales = i18nPlugin.getRegisteredTranslationLocales();
for (let indx = 0; indx < acceptLangsLen; indx++) {
const language = acceptLanguages[indx];

View file

@ -10,7 +10,8 @@ module.exports = function (grunt) {
'copy:devSource',
'babel:build',
'_build:babelOptions',
'_build:installedPlugins',
'_build:plugins',
'_build:data',
'_build:packageJson',
'_build:readme',
'_build:babelCache',

View file

@ -3,7 +3,6 @@ define({
'test/unit/api/ingest/index',
'test/unit/api/search/index',
'test/unit/api/scripts/index'
'test/unit/api/i18n/index'
],
excludeInstrumentation: /(fixtures|node_modules)\//,
loaderOptions: {