How to use the i18n._t function in i18n

To help you get started, we’ve selected a few i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github colymba / GridFieldBulkEditingTools / client / src / js / manager.js View on Github external
const $parent = $(this).parents('.bulkManagerOptions');
      const $btn = $parent.find('a.doBulkActionButton');
      const $msg = $parent.find('.message');

      const config = $btn.data('config');
      let url = this.getActionURL(action, $(this).data('url'));
      const inputData = { records: ids };

      if (ids.length <= 0) {
        alert(i18n._t('GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT'));
        return false;
      }

      // if ( $btn.hasClass('ss-ui-action-destructive') )
      if (config[action].destructive) {
        if (!confirm(i18n._t('GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION'))) {
          return false;
        }
      }

      $btn.addClass('loading');
      $msg.removeClass('static show error warning');

      if (config[action].xhr) {
        $.ajax({
          url,
          data: inputData,
          type: 'POST',
          context: $(this)
        }).always(function (data) {
          let returnData = data;
          $btn.removeClass('loading');
github dnadesign / silverstripe-elemental / client / src / components / ElementEditor / Header.js View on Github external
formDirty,
    } = this.props;

    // No indication required for published elements
    if (!formDirty && isPublished && isLiveVersion) {
      return null;
    }

    let versionStateButtonTitle = '';
    const stateClassNames = ['element-editor-header__version-state'];

    if (formDirty) {
      versionStateButtonTitle = i18n._t('ElementHeader.STATE_UNSAVED', 'Item has unsaved changes');
      stateClassNames.push('element-editor-header__version-state--unsaved');
    } else if (!isPublished) {
      versionStateButtonTitle = i18n._t('ElementHeader.STATE_DRAFT', 'Item has not been published yet');
      stateClassNames.push('element-editor-header__version-state--draft');
    } else if (!isLiveVersion) {
      versionStateButtonTitle = i18n._t('ElementHeader.STATE_MODIFIED', 'Item has unpublished changes');
      stateClassNames.push('element-editor-header__version-state--modified');
    }

    return (
      <span title="{versionStateButtonTitle}">
    );
  }
</span>
github silverstripe / silverstripe-cms / client / src / legacy / CMSMain.EditForm.js View on Github external
_addActions: function() {
			var self = this;
			var	updateURLFromTitle;

			// update button
			updateURLFromTitle = $('<button>', {
				'class': 'update btn btn-outline-secondary form__field-update-url',
				'text': i18n._t('CMS.UpdateURL'),
				'type': 'button',
				'click': function(e) {
					e.preventDefault();
					self.updateURLSegment(self.val());
				}
			});

			// insert elements
			updateURLFromTitle.insertAfter(self);
			updateURLFromTitle.hide();
		}
	});</button>
github silverstripe / silverstripe-asset-admin / client / src / containers / AssetAdmin / AssetAdmin.js View on Github external
)
          );
        }
        if (displayedMessages.length) {
          const alertMessage = [
            i18n.inject(
              i18n._t(
                'AssetAdmin.BULK_OWNED_WARNING_HEADING',
                '{count} file(s) are being used by other published content.'
              ),
              { count: confirmationRequired.length },
            ),

            body.join('\n'),

            i18n._t(
              'AssetAdmin.BULK_OWNED_WARNING_FOOTER',
              'Unpublishing will only remove files from the published version of the content. They will remain on the draft version. Unpublish anyway?'
            )
          ];

          // eslint-disable-next-line no-alert
          if (confirm(alertMessage.join('\n\n'))) {
            const secondPassIDs = confirmationRequired.reduce(
              (acc, curr) => acc.concat(curr.IDs),
              []
            );
            return this.doUnpublish(secondPassIDs, true)
              .then(next => successful.concat(next));
          }
        }
github silverstripe / silverstripe-framework / admin / client / src / containers / CampaignAdmin / CampaignAdmin.js View on Github external
setBreadcrumbs(view, id) {
    // Set root breadcrumb
    const breadcrumbs = [{
      text: i18n._t('Campaigns.CAMPAIGN', 'Campaigns'),
      href: this.props.sectionConfig.url,
    }];
    switch (view) {
      case 'show':
        // NOOP - Lazy loaded in CampaignAdminList.js
        break;
      case 'edit':
        // @todo - Lazy load in FormBuilderLoader / GridField
        breadcrumbs.push({
          text: i18n._t('Campaigns.EDIT_CAMPAIGN', 'Editing Campaign'),
          href: this.getActionRoute(id, view),
        });
        break;
      case 'create':
        breadcrumbs.push({
          text: i18n._t('Campaigns.ADD_CAMPAIGN', 'Add Campaign'),
github silverstripe / silverstripe-cms / client / src / legacy / AssetAdmin.js View on Github external
onclick: function(e) {
			if(!confirm(i18n._t('AssetAdmin.ConfirmDelete'))) return false;
			else this._super(e);
		}
	});
github silverstripe / silverstripe-cms / client / src / legacy / AssetAdmin.js View on Github external
onclick: function(e) {
			var msg;
			if(this.closest('.ss-gridfield-item').data('class') == 'Folder') {
				msg = i18n._t('AssetAdmin.ConfirmDelete');
			} else {
				msg = i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE');
			}
			if(!confirm(msg)) return false;

			this.getGridField().reload({data: [{name: this.attr('name'), value: this.val()}]});
			e.preventDefault();
			return false;
		}
	});
github silverstripe / silverstripe-asset-admin / client / src / components / UploadField / UploadFieldItem.js View on Github external
renderErrorMessage() {
    let message = null;

    if (this.hasError()) {
      message = this.props.item.message.value;
    } else if (this.missing()) {
      message = i18n._t('AssetAdmin.FILE_MISSING', 'File cannot be found');
    }

    if (message !== null) {
      return (
        <div title="{message}">
          {message}
        </div>
      );
    }

    return null;
  }
github dnadesign / silverstripe-elemental / client / src / components / ElementEditor / Element.js View on Github external
activeTab,
      connectDragSource,
      connectDropTarget,
      isDragging,
      isOver,
      onDragEnd,
    } = this.props;

    const { previewExpanded } = this.state;

    if (!element.ID) {
      return null;
    }

    const linkTitle = i18n.inject(
      i18n._t('ElementalElement.TITLE', 'Edit this {type} block'),
      { type: type.title }
    );

    const elementClassNames = classNames(
      'element-editor__element',
      {
        'element-editor__element--expandable': type.inlineEditable,
        'element-editor__element--dragging': isDragging,
        'element-editor__element--dragged-over': isOver,
      },
      this.getVersionedStateClassName()
    );

    const content = connectDropTarget(
github silverstripe / silverstripe-admin / client / src / components / Tag / Tag.js View on Github external
const DeleteButton = ({ dataKey, onDelete }) =&gt; (
  <button> { e.stopPropagation(); e.preventDefault(); onDelete(dataKey); }}
    aria-label={i18n._t('Admin.REMOVE_TAG', 'Remove Tag')}
    title={i18n._t('Admin.REMOVE_TAG', 'Remove Tag')}
    onFocus={focusOnParent}
    tabIndex={-1}
    className="tag__delete font-icon-cancel btn--no-text btn--icon-sm"
  /&gt;
);
</button>