How to use the i18n.sprintf 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 symbiote / silverstripe-advancedworkflow / client / src / bundles / WorkflowField.js View on Github external
const noPublishDate = (publishDate === undefined || publishDate.length === 0);
      const noPublishTime = (publishTime === undefined || publishTime.length === 0);

      if (noPublishDate && noPublishTime) {
        // No Embargo, remove customizations
        $('#Form_EditForm_action_publish').removeClass('embargo');
        $('#Form_EditForm_action_publish').prev('button').removeClass('ui-corner-right');
      } else {
        let message = '';

        $('#Form_EditForm_action_publish').addClass('embargo');
        $('#Form_EditForm_action_publish').prev('button').addClass('ui-corner-right');

        if (publishDate === '') {
            // Has time, not date
          message = i18n.sprintf(
            i18n._t('Workflow.EMBARGOMESSAGETIME'),
            publishTime
          );
        } else if (publishTime === '') {
            // has date no time
          message = i18n.sprintf(
            i18n._t('Workflow.EMBARGOMESSAGEDATE'),
            publishDate
          );
        } else {
          // has date and time
          message = i18n.sprintf(
            i18n._t('Workflow.EMBARGOMESSAGEDATETIME'),
            publishDate,
            publishTime
          );
github silverstripe / silverstripe-asset-admin / client / src / containers / Gallery / Gallery.js View on Github external
const successes = resultItems.filter((result) => result).length;
        if (successes !== items.length) {
          this.props.actions.gallery.setErrorMessage(
            i18n.sprintf(
              i18n._t(
                'AssetAdmin.BULK_ACTIONS_DELETE_FAIL',
                '%s folders/files were successfully deleted, but %s files were not able to be deleted.'
              ),
              successes,
              items.length - successes
            )
          );
          this.props.actions.gallery.setNoticeMessage(null);
        } else {
          this.props.actions.gallery.setNoticeMessage(
            i18n.sprintf(
              i18n._t('AssetAdmin.BULK_ACTIONS_DELETE_SUCCESS', '%s folders/files were successfully deleted.'),
              successes
            )
          );
          this.props.actions.gallery.setErrorMessage(null);
          this.props.actions.gallery.deselectFiles();
        }
      });
  }
github silverstripe / silverstripe-asset-admin / client / src / containers / Gallery / Gallery.js View on Github external
.then((resultItems) => {
        this.props.actions.gallery.setLoading(false);
        this.props.actions.gallery.setNoticeMessage(
          i18n.sprintf(
            i18n._t('AssetAdmin.BULK_ACTIONS_UNPUBLISH_SUCCESS', '%s folders/files were successfully unpublished.'),
            resultItems.length
          )
        );
        this.props.actions.gallery.setErrorMessage(null);
        this.props.actions.gallery.deselectFiles();
      });
  }
github silverstripe / silverstripe-asset-admin / client / src / containers / BulkDeleteConfirmation / BulkDeleteMessage.js View on Github external
if (fileInUseCount === 0) {
    return i18n._t('AssetAdmin.BULK_ACTIONS_DELETE_CONFIRM', 'Are you sure you want to delete these files?');
  }

  if (fileCount === 1 && fileInUseCount === 1) {
    return i18n.sprintf(
      i18n._t(
        'AssetAdmin.BULK_ACTIONS_DELETE_SINGLE_CONFIRM',
        'This file is currently used in %s place(s), are you sure you want to delete it?'
      ),
      inUseCount
    );
  }

  return i18n.sprintf(
    i18n._t(
      'AssetAdmin.BULK_ACTIONS_DELETE_MULTI_CONFIRM',
      'There are %s files currently in use, are you sure you want to delete these files?'
    ),
    fileInUseCount
  );
};
github silverstripe / silverstripe-asset-admin / client / src / containers / BulkDeleteConfirmation / BulkDeleteMessage.js View on Github external
const confirmationMessage = (folderInUse, fileCount, fileInUseCount, inUseCount) => {
  if (folderInUse) {
    return i18n._t(
      'AssetAdmin.BULK_ACTIONS_DELETE_FOLDER',
      'These folders contain files which are currently in use, you must move or delete their contents before ' +
      'you can delete the folder.'
    );
  }

  if (fileInUseCount === 0) {
    return i18n._t('AssetAdmin.BULK_ACTIONS_DELETE_CONFIRM', 'Are you sure you want to delete these files?');
  }

  if (fileCount === 1 && fileInUseCount === 1) {
    return i18n.sprintf(
      i18n._t(
        'AssetAdmin.BULK_ACTIONS_DELETE_SINGLE_CONFIRM',
        'This file is currently used in %s place(s), are you sure you want to delete it?'
      ),
      inUseCount
    );
  }

  return i18n.sprintf(
    i18n._t(
      'AssetAdmin.BULK_ACTIONS_DELETE_MULTI_CONFIRM',
      'There are %s files currently in use, are you sure you want to delete these files?'
    ),
    fileInUseCount
  );
};
github silverstripe / silverstripe-asset-admin / client / src / containers / MoveModal / MoveModal.js View on Github external
if (typeof onSuccess === 'function') {
          onSuccess(FolderID, selectedFiles);
        }

        setBadge(id, `${selectedFiles.length}`, 'success', CONSTANTS.MOVE_SUCCESS_DURATION);

        const goToFolder = (e) => {
          e.preventDefault();
          this.props.onOpenFolder(id);
          setNotice(null);
        };

        setNotice({
          react: (
            <span>
              {i18n.sprintf(
                i18n._t('AssetAdmin.MOVED_ITEMS_TO', 'Moved %s item(s) to ')
                , selectedFiles.length
              )}
              <a href="#">{filename}</a>
            </span>
          ),
        });
        this.timeout = setTimeout(() =&gt; setNotice(null), CONSTANTS.MOVE_SUCCESS_DURATION);
        onClosed();
      })
      .catch(() =&gt; {
github silverstripe / silverstripe-asset-admin / client / src / containers / Gallery / Gallery.js View on Github external
.then((resultItems) => {
        const successes = resultItems.filter((result) => result).length;
        if (successes !== items.length) {
          this.props.actions.gallery.setErrorMessage(
            i18n.sprintf(
              i18n._t(
                'AssetAdmin.BULK_ACTIONS_DELETE_FAIL',
                '%s folders/files were successfully deleted, but %s files were not able to be deleted.'
              ),
              successes,
              items.length - successes
            )
          );
          this.props.actions.gallery.setNoticeMessage(null);
        } else {
          this.props.actions.gallery.setNoticeMessage(
            i18n.sprintf(
              i18n._t('AssetAdmin.BULK_ACTIONS_DELETE_SUCCESS', '%s folders/files were successfully deleted.'),
              successes
            )
          );
github silverstripe / silverstripe-asset-admin / client / src / containers / MoveModal / MoveModal.js View on Github external
function mapStateToProps(state) {
  const { modal, selectedFiles } = state.assetAdmin.gallery;
  return {
    isOpen: modal === CONSTANTS.MODAL_MOVE,
    selectedFiles,
    title: i18n.sprintf(
      i18n._t('AssetAdmin.MOVE_ITEMS_TO', 'Move %s item(s) to...'),
      selectedFiles.length
    ),
  };
}