Fixes comments from review.

Adds a safe check, i18n is expecting undefined not null. Fix a method name and translation to be at placeholder.
This commit is contained in:
damencho 2016-10-25 15:18:56 -05:00
parent 076f7a82de
commit b2a1c9881e
3 changed files with 9 additions and 5 deletions

View File

@ -146,10 +146,10 @@ export default class Dialog {
this.submitted = false; this.submitted = false;
this.onCloseCallback = function() {}; this.onCloseCallback = function() {};
this.setDefaulOptions(); this.setDefaultOptions();
} }
setDefaulOptions() { setDefaultOptions() {
var self = this; var self = this;
this.options = { this.options = {

View File

@ -156,7 +156,8 @@ export default class InviteDialogView {
</label> </label>
<div class="input-control__container"> <div class="input-control__container">
<input class="input-control__input" id="newPasswordInput" <input class="input-control__input" id="newPasswordInput"
type="text" data-i18n="dialog.createPassword"> type="text"
data-i18n="[placeholder]dialog.createPassword">
<button id="addPasswordBtn" id="inviteDialogAddPassword" <button id="addPasswordBtn" id="inviteDialogAddPassword"
disabled data-i18n="dialog.add" disabled data-i18n="dialog.add"
class="button-control button-control_light"> class="button-control button-control_light">

View File

@ -98,7 +98,9 @@ module.exports = {
return i18n.lng(); return i18n.lng();
}, },
translateElement: function (selector, options) { translateElement: function (selector, options) {
selector.i18n(options); // i18next expects undefined if options are missing, check if its null
selector.i18n(
options === null ? undefined : options);
}, },
generateTranslationHTML: function (key, options) { generateTranslationHTML: function (key, options) {
var str = "<span data-i18n=\"" + key + "\""; var str = "<span data-i18n=\"" + key + "\"";
@ -106,7 +108,8 @@ module.exports = {
str += " data-i18n-options='" + JSON.stringify(options) + "'"; str += " data-i18n-options='" + JSON.stringify(options) + "'";
} }
str += ">"; str += ">";
str += i18n.t(key, options); // i18next expects undefined if options ARE missing, check if its null
str += i18n.t(key, options === null ? undefined : options);
str += "</span>"; str += "</span>";
return str; return str;