[Minor] fixing i18n

This commit is contained in:
Robert von Burg 2017-09-12 15:12:40 +02:00
parent f396b45776
commit e4ebb17e43
3 changed files with 31 additions and 28 deletions

View File

@ -17,8 +17,8 @@
"homepage": "https://github.com/4treesCH/strolch-wc-auth", "homepage": "https://github.com/4treesCH/strolch-wc-auth",
"ignore": [], "ignore": [],
"dependencies": { "dependencies": {
"strolchjs": "4treesCH/strolchjs#^0.1.4", "strolchjs": "4treesCH/strolchjs#^0.2.0",
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.0.2", "strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.1.0",
"paper-material": "PolymerElements/paper-material#^1.0.6", "paper-material": "PolymerElements/paper-material#^1.0.6",
"paper-card": "PolymerElements/paper-card#^1.1.2", "paper-card": "PolymerElements/paper-card#^1.1.2",
"paper-dialog": "PolymerElements/paper-dialog#^1.1.0", "paper-dialog": "PolymerElements/paper-dialog#^1.1.0",

View File

@ -13,7 +13,12 @@
"passwordResetDone": "Your password has been reset. Please login by navigating to the login dialog.", "passwordResetDone": "Your password has been reset. Please login by navigating to the login dialog.",
"code": "Code", "code": "Code",
"repeat": "Repeat", "repeat": "Repeat",
"send": "Send" "send": "Send",
"close" : "Close",
"logoutFailed" : "Logout failed",
"authenticationFailed" : "Authentication failed",
"resetFailed" : "Reset failed",
"passwordsDontMatch" : "Passwords don't match"
}, },
"de": { "de": {
"pleaseLogin": "Melden Sie sich bei {appTitle} an", "pleaseLogin": "Melden Sie sich bei {appTitle} an",
@ -29,6 +34,11 @@
"passwordResetDone": "Ihr Passwort wurde zurückgesetzt. Bitte loggen Sie sich im Login-Dialog ein.", "passwordResetDone": "Ihr Passwort wurde zurückgesetzt. Bitte loggen Sie sich im Login-Dialog ein.",
"code": "Code", "code": "Code",
"repeat": "Wiederholen", "repeat": "Wiederholen",
"send": "Absenden" "send": "Absenden",
"close" : "Schliessen",
"logoutFailed" : "Ausloggen fehlgeschlagen",
"authenticationFailed" : "Authentifizierung fehlgeschlagen",
"resetFailed" : "Zurücksetzung fehlgeschlagen",
"passwordsDontMatch" : "Passwörter sind nicht gleich"
} }
} }

View File

@ -160,7 +160,7 @@
<h2>[[dlgTitle]]</h2> <h2>[[dlgTitle]]</h2>
<p>[[dlgText]]</p> <p>[[dlgText]]</p>
<div class="buttons"> <div class="buttons">
<paper-button dialog-confirm autofocus>Close</paper-button> <paper-button dialog-confirm autofocus>[[localize('close')]]</paper-button>
</div> </div>
</paper-dialog> </paper-dialog>
@ -195,6 +195,11 @@
return './'; return './';
} }
}, },
localesPath: {
type: String,
value: './locales.json'
},
appTitle: { appTitle: {
type: String type: String
}, },
@ -230,14 +235,6 @@
this.$.username.inputElement.select(); this.$.username.inputElement.select();
}, },
attached: function () {
// this component has its own locales resources to load
this.loadResources(this.resolveUrl("./locales.json"));
// default the language to english, if there is none given by the app
if (!this.language) this.language = "en";
},
reload: function () { reload: function () {
this.username = ''; this.username = '';
@ -291,7 +288,7 @@
console.log('Logged out.'); console.log('Logged out.');
Strolch.clearStorageData(); Strolch.clearStorageData();
}; };
this.dlgTitle = "Logout failed"; this.dlgTitle = this.localize('logoutFailed');
this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication/' + Strolch.getAuthToken(); this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication/' + Strolch.getAuthToken();
this.$.ajaxAuth.method = 'DELETE'; this.$.ajaxAuth.method = 'DELETE';
this.$.ajaxAuth.generateRequest(); this.$.ajaxAuth.generateRequest();
@ -299,8 +296,7 @@
_submitForm: function () { _submitForm: function () {
if (!this.$.username.validate() || !this.$.password.validate()) if (!this.$.username.validate() || !this.$.password.validate()) return;
return;
console.log('Authenticating...'); console.log('Authenticating...');
this._ajaxResponse = function (data) { this._ajaxResponse = function (data) {
@ -309,7 +305,7 @@
Strolch.setUserConfig(data.detail.response); Strolch.setUserConfig(data.detail.response);
location.reload(); location.reload();
}; };
this.dlgTitle = "Authentication failed"; this.dlgTitle = this.localize('authenticationFailed');
this.$.ajaxAuth.body = { this.$.ajaxAuth.body = {
'username': this.username, 'username': this.username,
'password': btoa(this.password) 'password': btoa(this.password)
@ -339,8 +335,7 @@
_initiateReset: function () { _initiateReset: function () {
if (!this.$.usernameReset.validate()) if (!this.$.usernameReset.validate()) return;
return;
console.log('Initiating reset...'); console.log('Initiating reset...');
@ -350,7 +345,7 @@
that.$.resetInitiated.hidden = false; that.$.resetInitiated.hidden = false;
that.$.code.focus(); that.$.code.focus();
}; };
this.dlgTitle = "Reset failed"; this.dlgTitle = this.localize('resetFailed');
this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication/challenge'; this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication/challenge';
this.$.ajaxAuth.method = 'POST'; this.$.ajaxAuth.method = 'POST';
@ -363,8 +358,7 @@
_validateChallenge: function () { _validateChallenge: function () {
if (!this.$.code.validate()) if (!this.$.code.validate()) return;
return;
console.log('Validating challenge...'); console.log('Validating challenge...');
@ -375,7 +369,7 @@
that.$.resetForm.hidden = false; that.$.resetForm.hidden = false;
that.$.password1.focus(); that.$.password1.focus();
}; };
this.dlgTitle = "Reset failed"; this.dlgTitle = this.localize('resetFailed');
this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication/challenge'; this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication/challenge';
this.$.ajaxAuth.method = 'PUT'; this.$.ajaxAuth.method = 'PUT';
@ -388,14 +382,13 @@
_doReset: function () { _doReset: function () {
if (!this.$.password1.validate() || !this.$.password2.validate()) if (!this.$.password1.validate() || !this.$.password2.validate()) return;
return;
if (this.password1 !== this.password2) { if (this.password1 !== this.password2) {
this.$.password1.invalid = true; this.$.password1.invalid = true;
this.$.password2.invalid = true; this.$.password2.invalid = true;
var dlgTitle = "Reset failed"; var dlgTitle = this.localize('resetFailed');
var dlgText = 'Passwords do not match.'; var dlgText = this.localize('passwordsDontMatch');
this.showError(dlgTitle, dlgText); this.showError(dlgTitle, dlgText);
} }
@ -406,7 +399,7 @@
that._hideAll(); that._hideAll();
that.$.passwordResetDone.hidden = false; that.$.passwordResetDone.hidden = false;
}; };
this.dlgTitle = "Reset failed"; this.dlgTitle = this.localize('resetFailed');
this.$.ajaxAuth.url = this.basePath + 'rest/strolch/privilege/users/' + this.username + '/password'; this.$.ajaxAuth.url = this.basePath + 'rest/strolch/privilege/users/' + this.username + '/password';
this.$.ajaxAuth.method = 'PUT'; this.$.ajaxAuth.method = 'PUT';