Skip to content

Commit

Permalink
[JENKINS-35845] Assumes jenkinsci/jenkins#2586 to be applied. We know…
Browse files Browse the repository at this point in the history
… get the translations from the standard jenkins way, but needs changes in the core for now
  • Loading branch information
scherler committed Oct 13, 2016
1 parent 7bb3f7f commit 92a421e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion blueocean-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"history": "2.0.2",
"i18next": "^3.4.3",
"i18next-browser-languagedetector": "^1.0.0",
"i18next-xhr-backend-thor": "^1.2.0-thor2",
"i18next-xhr-backend-thor": "^1.2.0-thor3",
"immutable": "3.8.1",
"keymirror": "0.1.1",
"mobx": "2.6.0",
Expand Down
35 changes: 10 additions & 25 deletions blueocean-web/src/main/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,36 @@ const lngDetector = new LngDetector(null, {
// order and from where user language should be detected
order: ['querystring', 'navigator'],
// keys or params to lookup language from
lookupQuerystring: 'lng',
lookupQuerystring: 'language',
});

const xhr = new XHR(null, {
loadPath: '/jenkins/i18n/resourceBundle?language={{lng}}&baseName={{ns}}',
loadPath: '/jenkins/i18n/resourceBundle?language=##lng##&baseName=##ns##',
allowMultiLoading: false,
parse: function (data) {
console.log('mujer', data);
return data;
const response = JSON.parse(data);
return response.data;
},
});
console.log('rtrt', xhr)

i18n
.use(xhr)
.use(lngDetector)
.init({
fallbackLng: 'en',
// have a common namespace used around the full app
ns: ['common', 'hudson.logging.Messages'],
defaultNS: 'common',
ns: ['org.jenkinsci.plugins.blueocean.web.Messages', 'hudson.logging.Messages'],
defaultNS: 'org.jenkinsci.plugins.blueocean.web.Messages',
preload: ['en', 'de'],
keySeparator: '#',
debug: true,
load: 'all',
interpolation: {
prefix: '##',
suffix: '##',
escapeValue: false // not needed for react!!
},

resources: {
de: {
common: {
login: 'Einloggen',
logout: 'Ausloggen',
pipelines: "Röhren",
administration: "Verwaltung",
}
},
en: {
common: {
login: 'Login',
logout: 'Logout',
pipelines: "Pipelines",
administration: "Administration",
}
}
}
});

export default i18n;
4 changes: 4 additions & 0 deletions blueocean-web/src/main/js/loadLngBundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const PropertiesReader = require('properties-reader');

const properties = PropertiesReader('../resources/common.properties');
console.log('mmmmmmmm', properties.getAllProperties());
8 changes: 4 additions & 4 deletions blueocean-web/src/main/js/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class App extends Component {
<div className="global-header">
<Extensions.Renderer extensionPoint="jenkins.logo.top"/>
<nav>
<Link to="/pipelines">{t('pipelines')}</Link>
<Link to="/pipelines">{t('pipelines', {name: 'thor'})}</Link>
<a href="#">{t('administration')}</a>
</nav>
<div className="button-bar">
Expand All @@ -68,7 +68,8 @@ class App extends Component {
}

App.propTypes = {
children: PropTypes.node
children: PropTypes.node,
t: PropTypes.func
};

App.childContextTypes = {
Expand All @@ -92,8 +93,7 @@ function makeRoutes(routes) {
];


const namespaces = ['common', 'hudson.logging.Messages'];
console.log(namespaces, '222')
const namespaces = ['org.jenkinsci.plugins.blueocean.web.Messages'];
const routeProps = {
path: "/",
component: translate(namespaces, { wait: true })(App)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
login=Login
logout=Logout
pipelines=Pipelines ##name## hmm
administration=Administration
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
login=Einloggen
logout=Ausloggen
pipelines=Röhren ##name## hmm
administration=Verwaltung
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<properties>
<java.level>7</java.level>
<jackson.version>2.2.3</jackson.version>
<jenkins.version>2.7.1</jenkins.version> <!-- Should be kept in sync with Dockerfile FROM statement-->
<jenkins.version>2.26-SNAPSHOT</jenkins.version> <!-- Should be kept in sync with Dockerfile FROM statement-->
<javadoc.exec.goal>javadoc-no-fork</javadoc.exec.goal> <!-- stop initialize phase plugins executing twice -->
<node.version>5.8.0</node.version>
<npm.version>3.7.3</npm.version>
Expand Down

0 comments on commit 92a421e

Please sign in to comment.