How to use @wordpress/i18n - 10 common examples

To help you get started, we’ve selected a few @wordpress/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 wordpress-mobile / gutenberg-mobile / src / index.js View on Github external
const setupLocale = ( locale, extraTranslations ) => {
	I18nManager.forceRTL( false ); // Change to `true` to debug RTL layout easily.

	let gutenbergTranslations = getTranslation( locale );
	if ( locale && ! gutenbergTranslations ) {
		// Try stripping out the regional
		locale = locale.replace( /[-_][A-Za-z]+$/, '' );
		gutenbergTranslations = getTranslation( locale );
	}
	const translations = Object.assign( {}, gutenbergTranslations, extraTranslations );
	// eslint-disable-next-line no-console
	console.log( 'locale', locale, translations );
	// Only change the locale if it's supported by gutenberg
	if ( gutenbergTranslations || extraTranslations ) {
		setLocaleData( translations );
	}
};
github WordPress / gutenberg / packages / react-native-editor / src / index.js View on Github external
const setupLocale = ( locale, extraTranslations ) => {
	I18nManager.forceRTL( false ); // Change to `true` to debug RTL layout easily.

	let gutenbergTranslations = getTranslation( locale );
	if ( locale && ! gutenbergTranslations ) {
		// Try stripping out the regional
		locale = locale.replace( /[-_][A-Za-z]+$/, '' );
		gutenbergTranslations = getTranslation( locale );
	}
	const translations = Object.assign( {}, gutenbergTranslations, extraTranslations );
	// eslint-disable-next-line no-console
	console.log( 'locale', locale, translations );
	// Only change the locale if it's supported by gutenberg
	if ( gutenbergTranslations || extraTranslations ) {
		setLocaleData( translations );
	}
};
github maximebj / agb.plugin / src / blocks / giphy / index.js View on Github external
import './style.scss'
import './editor.scss'

import SearchGiphy from './search'

import { __ } from '@wordpress/i18n'
const { registerBlockType } = wp.blocks

export default registerBlockType(
  'advanced-gutenberg-blocks/giphy',
  {
    title: __( 'Giphy', 'advanced-gutenberg-blocks' ),
    description: __( 'Search and insert a GIF from Giphy.', 'advanced-gutenberg-blocks' ),
    category: 'agb',
    icon: { background: '#2F313A', foreground: '#DEBB8F', src: 'images-alt2' },
    keywords: [
      __( 'gif', 'advanced-gutenberg-blocks' ),
    ],
    attributes: {},

    edit: props => {

      const { clientId, insertBlocksAfter } = props
      
      // If API key is not yet provided
      if ( typeof advancedGutenbergBlocksGiphy.error !== "undefined" ) {
        return (
          <p class="AGB-block-message"></p>
github moderntribe / events-gutenberg / plugins / events-pro / src / modules / data / status / sagas.js View on Github external
const { items_created, last_created_at } = response;

			const date = momentUtils.toDate( momentUtils.toMoment( last_created_at ) );

			// Show editing notice
			yield call(
				[ wpDispatch( 'core/editor' ), 'createSuccessNotice' ],
				NOTICES[ NOTICE_EDITING_SERIES ],
				{ id: NOTICE_EDITING_SERIES, isDismissible: false }
			);

			// Show progress notice
			yield call(
				[ wpDispatch( 'core/editor' ), 'createSuccessNotice' ],
				`${ sprintf( NOTICES[ NOTICE_PROGRESS_ON_SERIES_CREATION_COUNT ], items_created ) } ${ sprintf( NOTICES[ NOTICE_PROGRESS_ON_SERIES_CREATION ], date ) }`,
				{ id: NOTICE_PROGRESS_ON_SERIES_CREATION, isDismissible: true }
			);
		}

		if ( yield select( selectors.isCompleted ) ) {
			yield put( allowEdits() ); // Allow datetime block to be editable again
			// Remove editing notice
			yield call(
				[ wpDispatch( 'core/editor' ), 'removeNotice' ],
				NOTICE_EDITING_SERIES
			);
			yield call(
				[ wpDispatch( 'core/editor' ), 'removeNotice' ],
				NOTICE_PROGRESS_ON_SERIES_CREATION
			);
			break; // We done
github WordPress / gutenberg / editor / components / inserter / menu.js View on Github external
componentDidUpdate( prevProps, prevState ) {
		const searchResults = this.searchItems( this.props.items );
		// Announce the search results to screen readers.
		if ( this.state.filterValue && !! searchResults.length ) {
			this.props.debouncedSpeak( sprintf( _n(
				'%d result found',
				'%d results found',
				searchResults.length
			), searchResults.length ), 'assertive' );
		} else if ( this.state.filterValue ) {
			this.props.debouncedSpeak( __( 'No results.' ), 'assertive' );
		}

		if ( this.state.tab !== prevState.tab ) {
			this.tabContainer.scrollTop = this.tabScrollTop[ this.state.tab ];
		}
	}
github WordPress / gutenberg / packages / editor / src / components / post-title / index.native.js View on Github external
focusedBorderColor,
			borderStyle,
		} = this.props;

		const decodedPlaceholder = decodeEntities( placeholder );
		const borderColor = this.props.isSelected ? focusedBorderColor : 'transparent';

		return (
github WordPress / gutenberg / packages / editor / src / components / post-publish-modal / prepublish.js View on Github external
function PostPublishModalPrepublish( {
	hasPublishAction,
	publishDate,
	isFloating,
	visibility,
	children,
	postType,
} ) {
	const postLabel = get( postType, [ 'labels', 'singular_name' ] );
	let prePublishBodyText,
		prePublishDateText;

	if ( ! hasPublishAction ) {
		prePublishBodyText = __( 'When you’re ready, submit your work for review, and an Editor will be able to approve it for you.' );
	} else {
		prePublishBodyText = sprintf(
			/* translators: %s: post type singular name */
			__( 'Double-check your settings, then publish your %s.' ), postLabel
		);
	}

	if ( isFloating ) {
		prePublishDateText = __( 'Your work will be published right now.' );
	} else if ( new Date( publishDate ) &lt; new Date() ) {
		prePublishDateText = __( 'Your work will be published right now and back-dated.' );
	} else {
		prePublishDateText = __( 'Your work will be published at the specified date and time.' );
	}

	const getVisibilityInfo = () =&gt; find( visibilityOptions, { value: visibility } ).info;

	return (
github WordPress / gutenberg / packages / components / src / mobile / bottom-sheet / cell.native.js View on Github external
const getAccessibilityLabel = () => {
			if ( accessibilityLabel || ! showValue ) {
				return accessibilityLabel || label;
			}
			return isEmpty( value ) ?
				sprintf(
					/* translators: accessibility text. Empty state of a inline textinput cell. %s: The cell's title */
					_x( '%s. Empty', 'inline textinput cell' ),
					label
				) :
				// Separating by ',' is necessary to make a pause on urls (non-capitalized text)
				sprintf(
					/* translators: accessibility text. Inline textinput title and value.%1: Cell title, %2: cell value. */
					_x( '%1$s, %2$s', 'inline textinput cell' ),
					label,
					value
				);
		};
github google / site-kit-wp / assets / js / googlesitekit-dashboard-splash.js View on Github external
constructor( props ) {
		super( props );
		this.state = {
			hasError: false,
		};

		// Set up translations.
		setLocaleData( googlesitekit.locale, 'google-site-kit' );
	}
github google / site-kit-wp / assets / js / googlesitekit-module.js View on Github external
constructor( props ) {
		super( props );
		this.state = { hasError: false };

		// Set up translations.
		setLocaleData( googlesitekit.locale, 'google-site-kit' );

		const {
			showModuleSetupWizard,
		} = googlesitekit.setup;

		this.state = {
			showModuleSetupWizard,
		};
	}

@wordpress/i18n

WordPress internationalization (i18n) library.

GPL-2.0-or-later
Latest version published 1 day ago

Package Health Score

98 / 100
Full package analysis