Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
EZP-26660: Make strings used in JavaScript files translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
dpobel committed Nov 24, 2016
1 parent 8bee8d0 commit a7fd685
Show file tree
Hide file tree
Showing 136 changed files with 1,242 additions and 330 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/EzPlatformUIExtension.php
Expand Up @@ -83,7 +83,7 @@ public function getTranslationDomains()
return [
'bar', 'confirm', 'contentedit', 'contenttypeselector', 'dashboardblocks',
'fieldedit', 'fieldview', 'languageselection', 'locationview', 'login', 'navigationhub',
'search', 'subitem', 'trash', 'tree', 'universaldiscovery', 'onlineeditor',
'search', 'subitem', 'trash', 'tree', 'universaldiscovery', 'onlineeditor', 'section', 'role',
];
}
}
80 changes: 45 additions & 35 deletions Resources/config/yui.yml

Large diffs are not rendered by default.

Expand Up @@ -136,7 +136,7 @@ YUI.add('ez-translateactionview', function (Y) {
e.preventDefault();
this.fire('languageSelect', {
config: {
title: "Select a language for your new translation:",
title: Y.eZ.trans('select.a.language.for.new.translation', {}, 'bar'),
languageSelectedHandler: Y.bind(this._newTranslation, this),
cancelLanguageSelectionHandler: null,
canBaseTranslation: true,
Expand Down
4 changes: 2 additions & 2 deletions Resources/public/js/views/ez-contenteditview.js
Expand Up @@ -81,8 +81,8 @@ YUI.add('ez-contenteditview', function (Y) {
content: e.content,
callback: e.callback,
notificationText: {
started: 'Saving the draft to generate the preview',
error: 'An error occurred while saving the draft, the preview cannot be generated.',
started: Y.eZ.trans('saving.draft.to.generate.the.preview', {}, 'contentedit'),
error: Y.eZ.trans('failed.saving.draft.to.generate.the.preview', {}, 'contentedit'),
},
});
},
Expand Down
8 changes: 4 additions & 4 deletions Resources/public/js/views/ez-editactionbarview.js
Expand Up @@ -72,13 +72,13 @@ YUI.add('ez-editactionbarview', function (Y) {
new Y.eZ.ButtonActionView({
actionId: "publish",
disabled: false,
label: "Publish",
label: Y.eZ.trans('publish', {}, 'contentedit'),
priority: 200
}),
new Y.eZ.ButtonActionView({
actionId: "discard",
disabled: false,
label: "Discard changes",
label: Y.eZ.trans('discard.changes', {}, 'contentedit'),
priority: 180
}),
];
Expand All @@ -91,14 +91,14 @@ YUI.add('ez-editactionbarview', function (Y) {
new Y.eZ.ButtonActionView({
actionId: "save",
disabled: false,
label: "Save",
label: Y.eZ.trans('save', {}, 'contentedit'),
priority: 190
})
);
list.push(
new Y.eZ.PreviewActionView({
actionId: "preview",
label: "Preview",
label: Y.eZ.trans('preview', {}, 'contentedit'),
priority: 170,
buttons: [
{option: "desktop"},
Expand Down
12 changes: 7 additions & 5 deletions Resources/public/js/views/ez-searchlistview.js
Expand Up @@ -130,11 +130,13 @@ YUI.add('ez-searchlistview', function (Y) {
* @type {Object}
*/
propertyNames: {
value: {
'name': 'Name',
'lastModificationDate': 'Modified',
'contentType': 'Content type',
'translations': 'Translations',
valueFn: function () {
return {
'name': Y.eZ.trans('name', {}, 'search'),
'lastModificationDate': Y.eZ.trans('modified', {}, 'search'),
'contentType': Y.eZ.trans('content.type', {}, 'search'),
'translations': Y.eZ.trans('translations', {}, 'search'),
};
}
},

Expand Down
6 changes: 3 additions & 3 deletions Resources/public/js/views/ez-trashbarview.js
Expand Up @@ -35,19 +35,19 @@ YUI.add('ez-trashbarview', function (Y) {
new Y.eZ.ButtonActionView({
actionId: "minimizeTrashBar",
disabled: false,
label: "Minimize",
label: Y.eZ.trans('minimize', {}, 'trash'),
priority: 1000
}),
new Y.eZ.ButtonActionView({
actionId: "restoreTrashItems",
disabled: true,
label: "Restore Selected",
label: Y.eZ.trans('restore.selected', {}, 'trash'),
priority: 800
}),
new Y.eZ.ButtonActionView({
actionId: "emptyTrash",
disabled: false,
label: "Empty the Trash",
label: Y.eZ.trans('empty.trash', {}, 'trash'),
priority: 10
}),
];
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/js/views/ez-treeview.js
Expand Up @@ -221,7 +221,7 @@ YUI.add('ez-treeview', function (Y) {

if ( node.isRoot() ) {
if (node.children.length === 0) {
this._getTreeContentNode().append('<p class="ez-tree-empty-info ez-font-icon">The Content Tree is empty</p>');
this._getTreeContentNode().append('<p class="ez-tree-empty-info ez-font-icon">' + Y.eZ.trans('tree.empty', {}, 'tree') + '</p>');
} else {
this._getTreeContentNode().append(template(nodeJson));
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/js/views/ez-usermenuview.js
Expand Up @@ -149,7 +149,7 @@ YUI.add('ez-usermenuview', function (Y) {
return [
new Y.eZ.UserMenuItemFireEventView({
bubbleTargets: this,
title: "Logout",
title: Y.eZ.trans('logout', {}, 'navigationhub'),
eventName: 'logOut',
}),
];
Expand Down
10 changes: 5 additions & 5 deletions Resources/public/js/views/fields/ez-author-editview.js
Expand Up @@ -183,19 +183,19 @@ YUI.add('ez-author-editview', function (Y) {
errorStatus = {};

if ( hasEmail && !emailValid ) {
errorStatus.email = 'The email address should be valid';
errorStatus.email = Y.eZ.trans('email.not.valid', {}, 'fieldedit');
}
if ( hasName && !hasEmail ) {
errorStatus.email = 'The email address is required if the name is filled.';
errorStatus.email = Y.eZ.trans('email.required.if.name.filled', {}, 'fieldedit');
}
if ( hasEmail && !hasName ) {
errorStatus.name = 'The name is required if the email is filled';
errorStatus.name = Y.eZ.trans('name.required.if.email.filled', {}, 'fieldedit');
}

if ( required && !hasName && !hasEmail ) {
errorStatus = {
name: 'The name is required',
email: 'The email address is required'
name: Y.eZ.trans('name.required', {}, 'fieldedit'),
email: Y.eZ.trans('email.required', {}, 'fieldedit'),
};
} else if ( hasName && hasEmail && emailValid ) {
errorStatus = {email: false, name: false};
Expand Down
9 changes: 4 additions & 5 deletions Resources/public/js/views/fields/ez-binarybase-editview.js
Expand Up @@ -17,7 +17,6 @@ YUI.add('ez-binarybase-editview', function (Y) {
IS_EMPTY = 'is-field-empty',
DRAGGING = 'is-dragging-file',
L = Y.Lang,
OVER_SIZE_TPL = "The file '{name}' was refused because its size is greater than the maximum allowed size ({max})",
win = Y.config.win,
events = {
'.ez-binarybase-warning-hide': {
Expand Down Expand Up @@ -96,7 +95,7 @@ YUI.add('ez-binarybase-editview', function (Y) {
var def = this.get('fieldDefinition');

if ( def.isRequired && this._isEmpty() ) {
this.set('errorStatus', 'This field is required');
this.set('errorStatus', Y.eZ.trans('this.field.is.required', {}, 'fieldedit'));
} else {
this.set('errorStatus', false);
}
Expand Down Expand Up @@ -197,7 +196,7 @@ YUI.add('ez-binarybase-editview', function (Y) {
* @return {String}
*/
_getOverSizeMessage: function (name) {
return L.sub(OVER_SIZE_TPL, {name: name, max: this._getHumanMaxSize()});
return Y.eZ.trans('over.maximum.allowed.size', {name: name, max: this._getHumanMaxSize()}, 'fieldedit');
},

/**
Expand Down Expand Up @@ -399,14 +398,14 @@ YUI.add('ez-binarybase-editview', function (Y) {
if ( files.length > 1 ) {
this._set(
'warning',
'You dropped several files while only one can be stored in this field. Please choose one file.'
Y.eZ.trans('dropped.several.files', {}, 'fieldedit')
);
return;
}
if ( !files[0] ) {
this._set(
'warning',
'You dropped a text selection while this field can only store a file. Please drop a file instead.'
Y.eZ.trans('dropped.text.selection', {}, 'fieldedit')
);
return;
}
Expand Down
8 changes: 4 additions & 4 deletions Resources/public/js/views/fields/ez-date-editview.js
Expand Up @@ -187,9 +187,9 @@ YUI.add('ez-date-editview', function (Y) {
var validity = this._getInputValidity();

if ( validity.valueMissing ) {
this.set('errorStatus', 'This field is required');
this.set('errorStatus', Y.eZ.trans('this.field.is.required', {}, 'fieldedit'));
} else if ( validity.badInput ) {
this.set('errorStatus', 'This is not a valid input');
this.set('errorStatus', Y.eZ.trans('input.not.valid', {}, 'fieldedit'));
} else {
this.set('errorStatus', false);
}
Expand All @@ -205,9 +205,9 @@ YUI.add('ez-date-editview', function (Y) {
var validity = this._getInputValidity();

if ( validity.valueMissing ) {
this.set('errorStatus', 'This field is required');
this.set('errorStatus', Y.eZ.trans('this.field.is.required', {}, 'fieldedit'));
} else if ( !validity.valueMissing && !this._isDateEmpty() && this._isDateValid() ) {
this.set('errorStatus', 'This is not a correct date');
this.set('errorStatus', Y.eZ.trans('date.not.valid', {}, 'fieldedit'));
} else {
this.set('errorStatus', false);
}
Expand Down
24 changes: 12 additions & 12 deletions Resources/public/js/views/fields/ez-dateandtime-editview.js
Expand Up @@ -25,18 +25,6 @@ YUI.add('ez-dateandtime-editview', function (Y) {
TIME_INVALID_DATE_MISSING = 10,
ERROR_MSG_DICTIONARY = {};

ERROR_MSG_DICTIONARY[NO_ERROR] = false;
ERROR_MSG_DICTIONARY[DATE_TIME_INVALID] = 'Date and time do not have valid inputs';
ERROR_MSG_DICTIONARY[DATE_INVALID_TIME_REQUIRED] = 'Date do not have a valid input and time is required';
ERROR_MSG_DICTIONARY[DATE_INVALID] = 'Date do not have a valid input';
ERROR_MSG_DICTIONARY[TIME_INVALID_DATE_REQUIRED] = 'Time do not have a valid input and date is required';
ERROR_MSG_DICTIONARY[TIME_INVALID] = 'Time do not have a valid input';
ERROR_MSG_DICTIONARY[DATE_TIME_REQUIRED] = 'Date and time are required';
ERROR_MSG_DICTIONARY[TIME_REQUIRED] = 'Time is required';
ERROR_MSG_DICTIONARY[DATE_REQUIRED] = 'Date is required';
ERROR_MSG_DICTIONARY[DATE_INVALID_TIME_MISSING] = 'Date do not have a valid input and time is missing';
ERROR_MSG_DICTIONARY[TIME_INVALID_DATE_MISSING] = 'Time do not have a valid input and date is missing';

/**
* Date and time edit view
*
Expand All @@ -59,6 +47,18 @@ YUI.add('ez-dateandtime-editview', function (Y) {

initializer: function () {
this._useStandardFieldDefinitionDescription = false;

ERROR_MSG_DICTIONARY[NO_ERROR] = false;
ERROR_MSG_DICTIONARY[DATE_TIME_INVALID] = Y.eZ.trans('date.and.time.not.valid', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[DATE_INVALID_TIME_REQUIRED] = Y.eZ.trans('date.not.valid.time.required', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[DATE_INVALID] = Y.eZ.trans('date.not.valid', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[TIME_INVALID_DATE_REQUIRED] = Y.eZ.trans('time.not.valid.date.required', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[TIME_INVALID] = Y.eZ.trans('time.not.valid', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[DATE_TIME_REQUIRED] = Y.eZ.trans('date.time.required', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[TIME_REQUIRED] = Y.eZ.trans('time.required', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[DATE_REQUIRED] = Y.eZ.trans('date.required', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[DATE_INVALID_TIME_MISSING] = Y.eZ.trans('date.not.valid.time.missing', {}, 'fieldedit');
ERROR_MSG_DICTIONARY[TIME_INVALID_DATE_MISSING] = Y.eZ.trans('time.not.valid.date.missing', {}, 'fieldedit');
},

/**
Expand Down
4 changes: 2 additions & 2 deletions Resources/public/js/views/fields/ez-emailaddress-editview.js
Expand Up @@ -42,9 +42,9 @@ YUI.add('ez-emailaddress-editview', function (Y) {
var validity = this._getInputValidity();

if ( validity.typeMismatch || !this._isValidEmail() ) {
this.set('errorStatus', 'The value should be a valid email address');
this.set('errorStatus', Y.eZ.trans('email.not.valid', {}, 'fieldedit'));
} else if ( validity.valueMissing ) {
this.set('errorStatus', 'This field is required');
this.set('errorStatus', Y.eZ.trans('this.field.is.required', {}, 'fieldedit'));
} else {
this.set('errorStatus', false);
}
Expand Down
11 changes: 5 additions & 6 deletions Resources/public/js/views/fields/ez-float-editview.js
Expand Up @@ -11,8 +11,7 @@ YUI.add('ez-float-editview', function (Y) {
*/
Y.namespace('eZ');

var L = Y.Lang,
FIELDTYPE_IDENTIFIER = 'ezfloat',
var FIELDTYPE_IDENTIFIER = 'ezfloat',
FLOAT_PATTERN = "-?\\d*\\.?\\d+"; // WARNING: each backslash is doubled, because it is escaped on output otherwise

/**
Expand Down Expand Up @@ -48,23 +47,23 @@ YUI.add('ez-float-editview', function (Y) {
validity = this._getInputValidity();

if ( validity.valueMissing ) {
this.set('errorStatus', 'This field is required');
this.set('errorStatus', Y.eZ.trans('this.field.is.required', {}, 'fieldedit'));
// Float pattern validation
} else if ( validity.patternMismatch ) {
this.set(
'errorStatus',
'The value should be a valid float number'
Y.eZ.trans('invalid.float.value', {}, 'fieldedit')
);
// Range validation
} else if ( config.maxFloatValue && inputValue > config.maxFloatValue ) {
this.set(
'errorStatus',
L.sub('The value should be less than or equal to {maxFloatValue}', config)
Y.eZ.trans('float.value.should.be.less.than', config, 'fieldedit')
);
} else if ( config.minFloatValue && inputValue < config.minFloatValue ) {
this.set(
'errorStatus',
L.sub('The value should be more than or equal to {minFloatValue}', config)
Y.eZ.trans('float.value.should.be.more.than', config, 'fieldedit')
);

} else {
Expand Down
6 changes: 2 additions & 4 deletions Resources/public/js/views/fields/ez-image-editview.js
Expand Up @@ -15,8 +15,6 @@ YUI.add('ez-image-editview', function (Y) {
IS_LOADING = 'is-image-loading',
IS_BEING_UPDATED = 'is-image-being-updated',
HAS_LOADING_ERROR = 'has-loading-error',
NOT_IMAGE_TPL = "The file '{name}' was refused because it seems to not be an image. Please choose an image file.",
SVG_IMAGE_TPL = "SVG images are not supported. Please choose another image file.",
L = Y.Lang,
win = Y.config.win,
events = {
Expand Down Expand Up @@ -96,7 +94,7 @@ YUI.add('ez-image-editview', function (Y) {
* @param {File} file the File object from the input file element
*/
_setWarningNotAnImage: function (file) {
this._set('warning', L.sub(NOT_IMAGE_TPL, {name: file.name}));
this._set('warning', Y.eZ.trans('refused.not.an.image', {name: file.name}, 'fieldedit'));
},

/**
Expand Down Expand Up @@ -214,7 +212,7 @@ YUI.add('ez-image-editview', function (Y) {
this._setWarningNotAnImage(file);
}
if ( isSVG ) {
this._set('warning', SVG_IMAGE_TPL);
this._set('warning', Y.eZ.trans('svg.not.supported', {}, 'fieldedit'));
}
return (isImage && !isSVG);
},
Expand Down
11 changes: 5 additions & 6 deletions Resources/public/js/views/fields/ez-integer-editview.js
Expand Up @@ -11,8 +11,7 @@ YUI.add('ez-integer-editview', function (Y) {
*/
Y.namespace('eZ');

var L = Y.Lang,
FIELDTYPE_IDENTIFIER = 'ezinteger',
var FIELDTYPE_IDENTIFIER = 'ezinteger',
INTEGER_PATTERN = "-?\\d*"; // WARNING: each backslash is doubled, because it is escaped on output otherwise;

/**
Expand Down Expand Up @@ -42,23 +41,23 @@ YUI.add('ez-integer-editview', function (Y) {
inputValue = this.get('container').one('.ez-integer-input-ui input').get('value');

if ( validity.valueMissing ) {
this.set('errorStatus', 'This field is required');
this.set('errorStatus', Y.eZ.trans('this.field.is.required', {}, 'fieldedit'));
// Integer pattern validation
} else if ( validity.patternMismatch ) {
this.set(
'errorStatus',
'The value should be a valid integer number'
Y.eZ.trans('value.should.be.valid.integer', {}, 'fieldedit')
);
// Range validation
} else if ( config.maxIntegerValue && inputValue > config.maxIntegerValue ) {
this.set(
'errorStatus',
L.sub('The value should be less than or equal to {maxIntegerValue}', config)
Y.eZ.trans('value.should.be.less.than', config, 'fieldedit')
);
} else if ( config.minIntegerValue && inputValue < config.minIntegerValue ) {
this.set(
'errorStatus',
L.sub('The value should be more than or equal to {minIntegerValue}', config)
Y.eZ.trans('value.should.be.more.than', config, 'fieldedit')
);

} else {
Expand Down

0 comments on commit a7fd685

Please sign in to comment.