Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX JENKINS-39225] Internationalisation for Blue Ocean and JDL #556

Merged
merged 50 commits into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
785aaaa
[JENKINS-35845] WIP first steps with i18n
scherler Oct 5, 2016
426aae9
eslint - formating changes and fix offences
scherler Oct 5, 2016
e2c57da
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Oct 6, 2016
ea448c7
[JENKINS-35845] first basic working version with 2 languages
scherler Oct 6, 2016
024d12b
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Oct 10, 2016
42a0a1e
[JENKINS-35845] WIP adding patched backend to investigate
scherler Oct 11, 2016
7bb3f7f
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Oct 11, 2016
92a421e
[JENKINS-35845] Assumes https://github.com/jenkinsci/jenkins/pull/258…
scherler Oct 13, 2016
982bc05
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Oct 13, 2016
bb303bc
[JENKINS-35845] remove testing class
scherler Oct 13, 2016
0a3fa25
[JENKINS-35845] WIP fixing integration of jenkins i18n keys with dot …
scherler Oct 13, 2016
b071f62
[JENKINS-35845] move i18n to core-js and using it from within web
scherler Oct 13, 2016
62f43d8
[JENKINS-35845] follow jenkins convention/pattern for storing locale
scherler Oct 14, 2016
068729e
[JENKINS-35845] WIP implement translation in core-js runbutton and to…
scherler Oct 14, 2016
f58eae8
[JENKINS-35845] WIP starting to translate dashboard
scherler Oct 17, 2016
771063b
[JENKINS-35845] WIP added german translation and finished dashboard. …
scherler Oct 20, 2016
1f401a2
[JENKINS-35845] Use latest jdl
scherler Oct 24, 2016
c9a74fd
[JENKINS-35845] fix locale retrieval
scherler Oct 24, 2016
2c73edb
[JENKINS-35845] update stories to use the new i18n functions. Create …
scherler Oct 24, 2016
f6a699c
[JENKINS-35845] Add spanish translations
scherler Oct 24, 2016
dba9405
[JENKINS-35845] better translation for spanish (thank you @Dario) as …
scherler Oct 25, 2016
43b58b6
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Oct 25, 2016
c32b9b0
[JENKINS-35845] Fix german translations with feedback from @daniel
scherler Oct 25, 2016
8428341
[JENKINS-35845] Fix test view and finish translation
scherler Oct 25, 2016
6ffcc40
[JENKINS-35845] Fix german translation. fix result views. fix some li…
scherler Oct 25, 2016
0304581
[JENKINS-35845] create a compose function to wire different functions…
scherler Oct 25, 2016
40a3b08
[JENKINS-35845] better documentation and remove debug string
scherler Oct 25, 2016
bf8431e
[JENKINS-35845] add documentation about i18n and linking contributing…
scherler Oct 26, 2016
e4612e5
[JENKINS-35845] updte docu
scherler Oct 26, 2016
60b81fc
[JENKINS-35845] Pass locale and translation function down the compone…
scherler Oct 26, 2016
05a6e12
[JENKINS-35845] Fix links to not drop query
scherler Oct 26, 2016
8616002
[JENKINS-35845] use the url config util to get correct path to jenkins
scherler Oct 26, 2016
7d9da8c
[JENKINS-35845] WIP security commit - refactor i18n class to support …
scherler Oct 27, 2016
d62b6c1
[JENKINS-35845] WIP security commit
scherler Oct 27, 2016
32a18f1
[JENKINS-35845] remove debug statement
scherler Nov 7, 2016
6f5d441
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Nov 7, 2016
49a9929
[JENKINS-35845] fix import
scherler Nov 7, 2016
cd726f8
Task/jenkins 35845 i18n key rename (#579)
cliffmeyers Nov 7, 2016
54fd4bf
[JENKINS-35845] order keys
scherler Nov 7, 2016
2a3e8d5
[JENKINS-35845] WIP security commit to be able to merge master
scherler Nov 9, 2016
4901735
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Nov 9, 2016
714043f
eslint - formating changes and fix offences
scherler Nov 9, 2016
8ba0a73
[JENKINS-35845] Remove dep to snapshot-jenkins and implement fallback…
scherler Nov 10, 2016
2b06258
[JENKINS-35845] remove duplicate variable
scherler Nov 10, 2016
9fb6222
[JENKINS-35845] fix test by adding polyfy again
scherler Nov 10, 2016
62f91ba
eslint - formating changes and fix offences
scherler Nov 10, 2016
51b86c6
[JENKINS-35845] Fix last test
scherler Nov 15, 2016
c243acd
[JENKINS-35845] fix tests for dashboard
scherler Nov 17, 2016
d398a38
Merge remote-tracking branch 'origin/master' into JENKINS-35845
scherler Nov 17, 2016
4a1ea80
[JENKINS-35845] sync version numbers
scherler Nov 17, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ https://jenkins.io/blog/2016/05/26/introducing-blue-ocean/



![Pirate logo, because it's ocean and stuff](logo-yarrr.png)
![Pirate logo, because it's ocean and stuff](docu/pix/logo-yarrr.png)
Yarr...

# Modules of note
## blueocean-dashboard

Blue Ocean Dashboard plugin. Currently contains the bulk of the Blue Ocean user interface. This is mostly client side JavaScript built with ES6 and React.

## blueocean
Expand Down Expand Up @@ -79,8 +78,6 @@ List of browsers where we know Blue Ocean is not yet runnable:

* Internet Explorer (all versions) on Windows



# Developing

Follow the steps above for getting it running first.
Expand Down Expand Up @@ -128,6 +125,18 @@ npm i
npm shrinkwrap --dev
```


# Contributing - help wanted

## i18n - Sprechen Sie Deutsch?

We have full i18n support in our plugins. Please read the [i18n documentation](./docu/I18N.md) on how you can provide new translations and how to work with i18n.

## contributing guidelines

Want to get involve with blueocean? See our [contributing guidelines](./CONTRIBUTING.md) for more informations.


# Debug and live reload with IntelliJ
Automatically deploys changes to an instance of blueocean that is run with hpi:run.

Expand Down
2 changes: 1 addition & 1 deletion blueocean-core-js/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ gulp.task("watch", ["clean-build"], () => {
// Default to all

gulp.task("default", () =>
runSequence("clean", "lint", "test", "build", "validate"));
runSequence("clean", "lint", "build", "validate"));

// Clean and build only, for watching

Expand Down
5 changes: 4 additions & 1 deletion blueocean-core-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jenkins-cd/blueocean-core-js",
"version": "0.0.22-unpublished",
"version": "0.0.22-unreleased8",
"description": "Shared JavaScript libraries for use with Jenkins Blue Ocean",
"main": "dist/js/index.js",
"scripts": {
Expand Down Expand Up @@ -29,6 +29,9 @@
"es6-promise": "4.0.5",
"eslint": "2.13.1",
"eslint-plugin-react": "4.3.0",
"i18next": "^3.4.3",
"i18next-browser-languagedetector": "^1.0.0",
"i18next-xhr-backend": "^1.2.0",
"isomorphic-fetch": "2.2.1",
"jsonwebtoken": "7.1.9",
"mobx": "2.6.0",
Expand Down
17 changes: 12 additions & 5 deletions blueocean-core-js/src/js/ToastUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
* Created by cmeyers on 9/21/16.
*/

import { ToastService as toastService } from './index';
import { ToastService as toastService, I18n } from './index';
import { buildRunDetailsUrlFromQueue } from './UrlBuilder';

const CAPABILITY_MULTIBRANCH_PIPELINE = 'io.jenkins.blueocean.rest.model.BlueMultiBranchPipeline';
const CAPABILITY_MULTIBRANCH_BRANCH = 'io.jenkins.blueocean.rest.model.BlueBranch';


export default {

/**
*
* @param runnable
* @param runInfo
* @param toastAction
*/
createRunStartedToast: (runnable, runInfo, toastAction) => {
const translate = I18n.getFixedT(I18n.language, 'jenkins.plugins.blueocean.web.Messages');
const isMultiBranch = runnable._capabilities.some(capability => (
[CAPABILITY_MULTIBRANCH_PIPELINE, CAPABILITY_MULTIBRANCH_BRANCH].indexOf(capability) !== -1
));
Expand All @@ -31,10 +30,18 @@ export default {
);

const name = decodeURIComponent(runnable.name);
const text = translate('toast.run.started', {
0: name,
1: runId,
defaultValue: 'Started "{0}" #{1}',
});

const caption = translate('toast.run.open', {
defaultValue: 'Open',
});
toastService.newToast({
text: `Started "${name}" #${runId}`,
action: 'Open',
text,
action: caption,
onActionClick: () => {
if (toastAction) {
toastAction(runDetailsUrl);
Expand Down
31 changes: 21 additions & 10 deletions blueocean-core-js/src/js/components/RunButton.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/**
* Created by cmeyers on 8/26/16.
*/

import React, { Component, PropTypes } from 'react';
import { Icon } from 'react-material-icons-blue';

import { RunApi as runApi } from '../';
import { ToastService as toastService } from '../';
import { ToastUtils } from '../';
import {
RunApi as runApi,
ToastService as toastService,
ToastUtils,
I18n,
} from '../';
import Security from '../security';
const translate = I18n ? I18n.getFixedT(I18n.language, 'jenkins.plugins.blueocean.web.Messages') : function() {};

const { permit } = Security;

Expand Down Expand Up @@ -68,10 +70,13 @@ export class RunButton extends Component {

const name = decodeURIComponent(this.props.runnable.name);
const runId = this.props.latestRun.id;

toastService.newToast({
text: `Stopping "${name}" #${runId}...`,
const text = translate('toast.run.stopping', {
0: name,
1: runId,
defaultValue: 'Stoppping "{0}" #{1}',
});

toastService.newToast({ text });
}

render() {
Expand All @@ -89,8 +94,14 @@ export class RunButton extends Component {
showRunButton = showRunButton && permit(this.props.runnable).start();
showStopButton = showStopButton && permit(this.props.runnable).stop();

const runLabel = this.props.runText || 'Run';
const stopLabel = this.state.stopping ? 'Stopping...' : 'Stop';
const runLabel = this.props.runText || translate('toast.run', {
defaultValue: 'Run',
});
const stopLabel = this.state.stopping ? translate('toast.stopping', {
defaultValue: 'Stopping ...',
}) : translate('toast.stop', {
defaultValue: 'Stop',
});

if (!showRunButton && !showStopButton) {
return null;
Expand Down
64 changes: 64 additions & 0 deletions blueocean-core-js/src/js/i18n/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import i18next from 'i18next';
import LngDetector from 'i18next-browser-languagedetector';
import XHR from 'i18next-xhr-backend';

import urlConfig from '../urlconfig';

/**
* Init language detector, we are going to use first queryString and then the navigator prefered language
*/
export const defaultLngDetector = new LngDetector(null, {
// order and from where user language should be detected
order: ['querystring', 'navigator'],
// keys or params to lookup language from
lookupQuerystring: 'language',
});
const prefix = urlConfig.getJenkinsRootURL() || '/';

const loadPath = `${prefix}/i18n/resourceBundle?language={lng}&baseName={ns}`;
/**
* configure the backend for our locale
*/
export const defaultXhr = new XHR(null, {
loadPath,
allowMultiLoading: false,
parse: (data) => {
// we need to parse the response and then extract the data since the rest is garbage for us
const response = JSON.parse(data);
return response.data;
},
});

/**
* Our default properties for i18next
* @type {{fallbackLng: string, ns: string[], defaultNS: string, preload: string[], keySeparator: boolean, debug: boolean, load: string, interpolation: {prefix: string, suffix: string, escapeValue: boolean}}}
*/
export const initOptions = {
fallbackLng: 'en',
// have a common namespace used around the full app
ns: ['jenkins.plugins.blueocean.web.Messages', 'jenkins.plugins.blueocean.dashboard.Messages'],
defaultNS: 'jenkins.plugins.blueocean.web.Messages',
preload: ['en'],
keySeparator: false, // we do not have any nested keys in properties files
debug: true, // for dev reasons ATM
load: 'all', // --> ['en-US', 'en', 'dev']
interpolation: {
prefix: '{',
suffix: '}',
escapeValue: false, // not needed for react!!
},
};

/**
* Create a instance of i18next and init it
* @param backend {object} - the backend we want to use
* @param lngDetector {object} - the component that detects which language we want to display
* @param options {object} - general options for i18next
* @see defaultOptions
*/
export const i18n = (backend = defaultXhr, lngDetector = defaultLngDetector, options = initOptions) => i18next
.use(backend)
.use(lngDetector)
.init(options);

export default i18n(defaultXhr, defaultLngDetector, initOptions);
3 changes: 3 additions & 0 deletions blueocean-core-js/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ export { toastService as ToastService };

const runApi = new RunApi();
export { runApi as RunApi };

// export i18n provider
export I18n, { defaultLngDetector, defaultXhr, initOptions, i18n } from './i18n/i18n';
2 changes: 1 addition & 1 deletion blueocean-core-js/test/js/ToastService-spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Created by cmeyers on 8/22/16.
*/
import 'babel-polyfill';
import 'babel-polyfill'
import { assert } from 'chai';

import { ToastService } from '../../src/js/ToastService';
Expand Down
1 change: 0 additions & 1 deletion blueocean-core-js/test/js/components/RunButton-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { RunButton } from '../../../src/js/components/RunButton';

describe('RunButton', () => {
let pipeline;

beforeEach(() => {
pipeline = utils.clone(require('../data/pipeline-1.json'));
});
Expand Down
Loading