mirror of https://github.com/rancher/ui.git
parent
f9a0c3cff6
commit
1e2ebcb36e
|
|
@ -47,6 +47,7 @@ export default Ember.Route.extend(Subscribe, {
|
||||||
projects: this.loadProjects(),
|
projects: this.loadProjects(),
|
||||||
preferences: this.loadPreferences(),
|
preferences: this.loadPreferences(),
|
||||||
settings: this.loadPublicSettings(),
|
settings: this.loadPublicSettings(),
|
||||||
|
language: this.get('language').initLanguage(),
|
||||||
}).then((hash) => {
|
}).then((hash) => {
|
||||||
var projectId = null;
|
var projectId = null;
|
||||||
if ( transition.params && transition.params['authenticated.project'] && transition.params['authenticated.project'].project_id )
|
if ( transition.params && transition.params['authenticated.project'] && transition.params['authenticated.project'].project_id )
|
||||||
|
|
@ -54,7 +55,6 @@ export default Ember.Route.extend(Subscribe, {
|
||||||
projectId = transition.params['authenticated.project'].project_id;
|
projectId = transition.params['authenticated.project'].project_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('language').initLanguage();
|
|
||||||
// Make sure a valid project is selected
|
// Make sure a valid project is selected
|
||||||
return this.get('projects').selectDefault(projectId).then((project) => {
|
return this.get('projects').selectDefault(projectId).then((project) => {
|
||||||
// Load stuff that is needed to draw the header
|
// Load stuff that is needed to draw the header
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ import Ember from 'ember';
|
||||||
import C from 'ui/utils/constants';
|
import C from 'ui/utils/constants';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
|
// Set to true on login to savesession value instead of user-pref
|
||||||
|
login : false,
|
||||||
|
|
||||||
tagName : 'div',
|
tagName : 'div',
|
||||||
classNames : ['dropdown', 'language-dropdown', 'inline-block'],
|
classNames : ['dropdown', 'language-dropdown', 'inline-block'],
|
||||||
classNameBindings: ['hideSingle:hide'],
|
classNameBindings: ['hideSingle:hide'],
|
||||||
|
|
@ -18,14 +21,14 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
selectLanguage(language) {
|
selectLanguage(language) {
|
||||||
let route = this.get('app.currentRouteName');
|
if (this.get('login')) {
|
||||||
|
|
||||||
if (route === 'login') {
|
|
||||||
this.get('session').set(C.SESSION.LOGIN_LANGUAGE, language);
|
this.get('session').set(C.SESSION.LOGIN_LANGUAGE, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('language').sideLoadLanguage(language).then(() => {
|
this.get('language').sideLoadLanguage(language).then(() => {
|
||||||
this.get('language').setLanguage(language);
|
if (!this.get('login')) {
|
||||||
|
this.get('language').setLanguage(language, false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -38,4 +41,19 @@ export default Ember.Component.extend({
|
||||||
return null;
|
return null;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
selectedLabel: Ember.computed('selected','locales', function() {
|
||||||
|
let sel = this.get('selected');
|
||||||
|
let out = '';
|
||||||
|
if (sel) {
|
||||||
|
out = this.get('locales')[sel];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!out) {
|
||||||
|
out = 'Language';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip parens for display
|
||||||
|
return out.replace(/\s+\(.+\)$/,'');
|
||||||
|
}),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<a class="dropdown-toggle hand btn btn-sm btn-link lang-select" data-toggle="dropdown" aria-expanded="false">
|
<a class="dropdown-toggle hand btn btn-sm btn-link lang-select" data-toggle="dropdown" aria-expanded="false">
|
||||||
<i class="icon icon-globe"></i> Language <i class="icon icon-chevron-down"></i>
|
<i class="icon icon-globe"></i> {{selectedLabel}} <i class="icon icon-chevron-down"></i>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-menu-right" role="menu">
|
<ul class="dropdown-menu dropdown-menu-right" role="menu">
|
||||||
{{#each-in locales as |label lang|}}
|
{{#each-in locales as |lang label|}}
|
||||||
<li class="{{if (eq selected lang) 'disabled selected'}}">
|
<li class="{{if (eq selected lang) 'disabled selected'}}">
|
||||||
<a {{action 'selectLanguage' lang}}>
|
<a {{action 'selectLanguage' lang}}>
|
||||||
{{label}}
|
{{label}}
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,21 @@ export default Ember.Route.extend({
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
this._super.apply(this,arguments);
|
this._super.apply(this,arguments);
|
||||||
|
|
||||||
|
let lang = C.LANGUAGE.DEFAULT;
|
||||||
const session = this.get('session');
|
const session = this.get('session');
|
||||||
const language = this.get('language');
|
const fromLogin = session.get(C.SESSION.LANGUAGE); // get local language
|
||||||
const uplLocal = this.get('session').get(C.SESSION.LANGUAGE); // get local language
|
|
||||||
let defaultLanguage = C.LANGUAGE.DEFAULT;
|
|
||||||
|
|
||||||
if (uplLocal) {
|
if (fromLogin) {
|
||||||
defaultLanguage = uplLocal;
|
lang = fromLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
language.sideLoadLanguage(defaultLanguage);
|
session.set(C.SESSION.LOGIN_LANGUAGE, lang);
|
||||||
|
|
||||||
session.set(C.SESSION.LOGIN_LANGUAGE, defaultLanguage);
|
return this.get('language').sideLoadLanguage(lang).then(() => {
|
||||||
|
if ( !this.get('access.enabled') )
|
||||||
if ( !this.get('access.enabled') )
|
{
|
||||||
{
|
this.transitionTo('authenticated');
|
||||||
this.transitionTo('authenticated');
|
}
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
<div style="max-width: 360px; margin: 100px auto 0 auto;">
|
<div style="max-width: 360px; margin: 100px auto 0 auto;">
|
||||||
<div class="farm-box login top-colors">
|
<div class="farm-box login top-colors">
|
||||||
{{#if settings.appName}}
|
<h1>
|
||||||
{{format-html-message 'loginPage.greeting'
|
{{format-html-message 'loginPage.greeting' appName=settings.appName}}
|
||||||
appName=settings.appName}}
|
<div class="logo"></div>
|
||||||
{{else}}
|
</h1>
|
||||||
{{format-html-message 'loginPage.greetingWhiteLabel'}}
|
|
||||||
{{/if}}
|
|
||||||
<div class="logo"></div>
|
|
||||||
<section>
|
<section>
|
||||||
{{!-- {{language-dropdown class='r-mt10 r-mb10'}}--}}
|
{{language-dropdown login=true class='r-mt10 r-mb10'}}
|
||||||
<br/>
|
<br/>
|
||||||
{{#if isGithub}}
|
{{#if isGithub}}
|
||||||
<p>{{t 'loginPage.githubMessage' appName=settings.appName}}</p>
|
<p>{{t 'loginPage.githubMessage' appName=settings.appName}}</p>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ export default Ember.Service.extend({
|
||||||
prefs : Ember.inject.service(),
|
prefs : Ember.inject.service(),
|
||||||
session : Ember.inject.service(),
|
session : Ember.inject.service(),
|
||||||
intl : Ember.inject.service(),
|
intl : Ember.inject.service(),
|
||||||
locales : Ember.computed.alias('app.locales'),
|
locales : Ember.computed.alias('app.locales'),
|
||||||
loadedLocales : null,
|
loadedLocales : null,
|
||||||
|
|
||||||
bootstrap: function() {
|
bootstrap: function() {
|
||||||
|
|
@ -48,12 +48,12 @@ export default Ember.Service.extend({
|
||||||
this.get('intl').setLocale(language);
|
this.get('intl').setLocale(language);
|
||||||
return Ember.RSVP.resolve();
|
return Ember.RSVP.resolve();
|
||||||
} else {
|
} else {
|
||||||
return ajaxPromise({url: `/translations/${language}.json`,
|
return ajaxPromise({url: `${this.get('app.baseAssets')}translations/${language}.json`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
loadedLocales.push(language);
|
loadedLocales.push(language);
|
||||||
this.get('intl').addTranslations(language, resp.xhr.responseJSON).then(() => {
|
return this.get('intl').addTranslations(language, resp.xhr.responseJSON).then(() => {
|
||||||
this.get('intl').setLocale(language);
|
this.get('intl').setLocale(language);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,6 @@
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
background-color: $primary;
|
background-color: $primary;
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 105px;
|
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,6 +314,7 @@ TABLE.graphs {
|
||||||
h1 {
|
h1 {
|
||||||
background-color: $brand-primary;
|
background-color: $brand-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2 {
|
h1, h2 {
|
||||||
padding : 40px 20px;
|
padding : 40px 20px;
|
||||||
color : white;
|
color : white;
|
||||||
|
|
@ -323,7 +324,7 @@ TABLE.graphs {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
left : 0;
|
left : 0;
|
||||||
right : 0;
|
right : 0;
|
||||||
bottom : -25px;
|
bottom : -37px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import Ember from 'ember';
|
||||||
const { Logger:logger } = Ember;
|
const { Logger:logger } = Ember;
|
||||||
|
|
||||||
export default function missingMessage(key, locales) {
|
export default function missingMessage(key, locales) {
|
||||||
|
locales = locales||['unknown'];
|
||||||
logger.warn(`translation not found: locale='${locales.join(', ')}', key='${key}'.`);
|
logger.warn(`translation not found: locale='${locales.join(', ')}', key='${key}'.`);
|
||||||
return `*%${key}%*`;
|
return `*%${key}%*`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,17 @@ function readLocales(environment) {
|
||||||
/* Parse the translations from the translations folder*/
|
/* Parse the translations from the translations folder*/
|
||||||
/* ember intl getLocalesByTranslations does not work if intl is not managing them (bundled) */
|
/* ember intl getLocalesByTranslations does not work if intl is not managing them (bundled) */
|
||||||
/* This needs a little work to read the yaml files for the langugae name prop*/
|
/* This needs a little work to read the yaml files for the langugae name prop*/
|
||||||
var translations = fs.readdirSync('./translations');
|
var files = fs.readdirSync('./translations');
|
||||||
var translationsOut = {};
|
var translationsOut = {};
|
||||||
translations.forEach(function(item) {
|
files.forEach(function(filename) {
|
||||||
if ( environment === 'production' && item === 'none.yaml' ) {
|
if ( environment === 'production' && filename === 'none.yaml' ) {
|
||||||
// Don't show the "None" language in prod
|
// Don't show the "None" language in prod
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var ymlFile = YAML.load('./translations/' + item);
|
var ymlFile = YAML.load('./translations/' + filename);
|
||||||
var name = ymlFile.languageName;
|
var label = ymlFile.languageName;
|
||||||
var value = item.split('.')[0];
|
var locale = filename.split('.')[0];
|
||||||
translationsOut[name] = value;
|
translationsOut[locale] = label;
|
||||||
});
|
});
|
||||||
return translationsOut;
|
return translationsOut;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@ languageName: "English (US)"
|
||||||
|
|
||||||
# Routes
|
# Routes
|
||||||
loginPage:
|
loginPage:
|
||||||
greeting: "<h1>Howdy!<br>Welcome to {appName}</h1>"
|
greeting: "Howdy!<br>Welcome to {appName}"
|
||||||
greetingWhiteLabel: "<h1>Howdy!<br>Welcome</h1>"
|
|
||||||
githubMessage: "{appName} uses GitHub to manage accounts and teams. Click the button below to log in and give us read-only access to your basic GitHub account information."
|
githubMessage: "{appName} uses GitHub to manage accounts and teams. Click the button below to log in and give us read-only access to your basic GitHub account information."
|
||||||
|
|
||||||
splashPage:
|
splashPage:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue