Skip to content

Commit

Permalink
Misc i18n fixes (WordPress#66510)
Browse files Browse the repository at this point in the history
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: peterwilsoncc <peterwilsoncc@git.wordpress.org>
  • Loading branch information
3 people authored and karthick-murugan committed Nov 13, 2024
1 parent e9d473c commit 371497e
Show file tree
Hide file tree
Showing 71 changed files with 193 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ function getDownloadableBlockLabel(
const stars = Math.round( rating / 0.5 ) * 0.5;

if ( ! isInstalled && hasNotice ) {
/* translators: %1$s: block title */
/* translators: %s: block title */
return sprintf( 'Retry installing %s.', decodeEntities( title ) );
}

if ( isInstalled ) {
/* translators: %1$s: block title */
/* translators: %s: block title */
return sprintf( 'Add %s.', decodeEntities( title ) );
}

if ( isInstalling ) {
/* translators: %1$s: block title */
/* translators: %s: block title */
return sprintf( 'Installing %s.', decodeEntities( title ) );
}

// No ratings yet, just use the title.
if ( ratingCount < 1 ) {
/* translators: %1$s: block title */
/* translators: %s: block title */
return sprintf( 'Install %s.', decodeEntities( title ) );
}

return sprintf(
/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */
/* translators: 1: block title, 2: average rating, 3: total ratings count. */
_n(
'Install %1$s. %2$s stars with %3$s review.',
'Install %1$s. %2$s stars with %3$s reviews.',
Expand Down Expand Up @@ -131,7 +131,7 @@ function DownloadableBlockListItem( { item, onClick } ) {
<span className="block-directory-downloadable-block-list-item__title">
{ createInterpolateElement(
sprintf(
/* translators: %1$s: block title, %2$s: author name. */
/* translators: 1: block title. 2: author name. */
__( '%1$s <span>by %2$s</span>' ),
decodeEntities( title ),
author
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/block-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { chevronLeft, chevronRight } from '@wordpress/icons';
import { __, isRTL, sprintf } from '@wordpress/i18n';
import { __, _x, isRTL, sprintf } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';

/**
Expand Down Expand Up @@ -68,8 +68,8 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
<h2 className="block-editor-block-card__title">
{ name?.length
? sprintf(
// translators: %1$s: Custom block name. %2$s: Block title.
__( '%1$s (%2$s)' ),
// translators: 1: Custom block name. 2: Block title.
_x( '%1$s (%2$s)', 'block label' ),
name,
title
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function Pagination( {
</HStack>
<Text variant="muted">
{ sprintf(
// translators: %1$s: Current page number, %2$s: Total number of pages.
// translators: 1: Current page number. 2: Total number of pages.
_x( '%1$s of %2$s', 'paging' ),
currentPage,
numPages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function VariationsButtons( {
selectedValue === variation.name
? variation.title
: sprintf(
/* translators: %s: Name of the block variation */
/* translators: %s: Block or block variation name. */
__( 'Transform to %s' ),
variation.title
)
Expand Down Expand Up @@ -127,7 +127,7 @@ function VariationsToggleGroupControl( {
selectedValue === variation.name
? variation.title
: sprintf(
/* translators: %s: Name of the block variation */
/* translators: %s: Block or block variation name. */
__( 'Transform to %s' ),
variation.title
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MenuItem extends Component {
const accessibilityLabelFormat = blockIsNew
? // translators: Newly available block name. %s: The localized block name
__( '%s block, newly available' )
: // translators: Block name. %s: The localized block name
: // translators: %s: Block name e.g. "Image block"
__( '%s block' );
const accessibilityLabel = sprintf(
accessibilityLabelFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { useState } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { _x, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -89,8 +89,8 @@ export default function SpacingSizesControl( {
ALL_SIDES.includes( view ) && showSideInLabel ? LABELS[ view ] : '';

const label = sprintf(
// translators: 2. Type of spacing being modified (Padding, margin, etc). 1: The side of the block being modified (top, bottom, left etc.).
__( '%1$s %2$s' ),
// translators: 1: The side of the block being modified (top, bottom, left etc.). 2. Type of spacing being modified (padding, margin, etc).
_x( '%1$s %2$s', 'spacing' ),
labelProp,
sideLabel
).trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { useSelect } from '@wordpress/data';
import { useState, useMemo } from '@wordpress/element';
import { usePrevious } from '@wordpress/compose';
import { __, sprintf } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';
import { settings } from '@wordpress/icons';

/**
Expand Down Expand Up @@ -124,7 +124,7 @@ export default function SpacingInputControl( {
...spacingSizes,
{
name: ! isMixed
? // translators: A custom measurement, eg. a number followed by a unit like 12px.
? // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px.
sprintf( __( 'Custom (%s)' ), value )
: __( 'Mixed' ),
slug: 'custom',
Expand Down Expand Up @@ -200,8 +200,8 @@ export default function SpacingInputControl( {
const typeLabel = showSideInLabel ? type?.toLowerCase() : type;

const ariaLabel = sprintf(
// translators: 1: The side of the block being modified (top, bottom, left, All sides etc.). 2. Type of spacing being modified (Padding, margin, etc)
__( '%1$s %2$s' ),
// translators: 1: The side of the block being modified (top, bottom, left etc.). 2. Type of spacing being modified (padding, margin, etc).
_x( '%1$s %2$s', 'spacing' ),
sideLabel,
typeLabel
).trim();
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class URLInput extends Component {
if ( !! suggestions.length ) {
this.props.debouncedSpeak(
sprintf(
/* translators: %s: number of results. */
/* translators: %d: number of results. */
_n(
'%d result found, use up and down arrow keys to navigate.',
'%d results found, use up and down arrow keys to navigate.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const useTransformCommands = () => {
const { name, title, icon } = transformation;
return {
name: 'core/block-editor/transform-to-' + name.replace( '/', '-' ),
// translators: %s: block title/name.
/* translators: %s: Block or block variation name. */
label: sprintf( __( 'Transform to %s' ), title ),
icon: <BlockIcon icon={ icon } />,
callback: ( { close } ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { _x, __, sprintf } from '@wordpress/i18n';
import { _x, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -173,7 +173,7 @@ export function getFontStylesAndWeights( fontFamilyFaces ) {
? weightName
: sprintf(
/* translators: 1: Font weight name. 2: Font style name. */
__( '%1$s %2$s' ),
_x( '%1$s %2$s', 'font' ),
weightName,
styleName
);
Expand Down
5 changes: 2 additions & 3 deletions packages/block-library/src/avatar/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ export function useCommentAvatar( { commentId } ) {
src: avatarUrls ? avatarUrls[ avatarUrls.length - 1 ] : defaultAvatar,
minSize,
maxSize,
// translators: %s is the Author name.
alt: authorName
? // translators: %s is the Author name.
? // translators: %s: Author name.
sprintf( __( '%s Avatar' ), authorName )
: __( 'Default Avatar' ),
};
Expand Down Expand Up @@ -89,7 +88,7 @@ export function useUserAvatar( { userId, postId, postType } ) {
minSize,
maxSize,
alt: authorDetails
? // translators: %s is the Author name.
? // translators: %s: Author name.
sprintf( __( '%s Avatar' ), authorDetails?.name )
: __( 'Default Avatar' ),
};
Expand Down
9 changes: 4 additions & 5 deletions packages/block-library/src/avatar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
}

$author_name = get_the_author_meta( 'display_name', $author_id );
// translators: %s is the Author name.
// translators: %s: Author name.
$alt = sprintf( __( '%s Avatar' ), $author_name );
$avatar_block = get_avatar(
$author_id,
Expand All @@ -64,7 +64,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
// translators: %s is the Author name.
$label = 'aria-label="' . esc_attr( sprintf( __( '(%s author archive, opens in a new tab)' ), $author_name ) ) . '"';
}
// translators: %1$s: Author archive link. %2$s: Link target. %3$s Aria label. %4$s Avatar image.
// translators: 1: Author archive link. 2: Link target. %3$s Aria label. %4$s Avatar image.
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( get_author_posts_url( $author_id ) ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
}
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
Expand All @@ -73,7 +73,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
if ( ! $comment ) {
return '';
}
/* translators: %s is the Comment Author name */
/* translators: %s: Author name. */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
$avatar_block = get_avatar(
$comment,
Expand All @@ -88,10 +88,9 @@ function render_block_core_avatar( $attributes, $content, $block ) {
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) {
$label = '';
if ( '_blank' === $attributes['linkTarget'] ) {
// translators: %s is the Comment Author name.
// translators: %s: Comment author name.
$label = 'aria-label="' . esc_attr( sprintf( __( '(%s website link, opens in a new tab)' ), $comment->comment_author ) ) . '"';
}
// translators: %1$s: Comment Author website link. %2$s: Link target. %3$s Aria label. %4$s Avatar image.
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( $comment->comment_author_url ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
}
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/comment-author-avatar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function render_block_core_comment_author_avatar( $attributes, $content, $block
$styles = isset( $wrapper_attributes['style'] ) ? $wrapper_attributes['style'] : '';
$classes = isset( $wrapper_attributes['class'] ) ? $wrapper_attributes['class'] : '';

/* translators: %s is the Comment Author name */
/* translators: %s: Author name. */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );

$avatar_block = get_avatar(
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
{ displayAuthor && currentAuthor && (
<div className="wp-block-latest-posts__post-author">
{ sprintf(
/* translators: byline. %s: current author. */
/* translators: byline. %s: author. */
__( 'by %s' ),
currentAuthor.name
) }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/latest-posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function render_block_core_latest_posts( $attributes ) {
if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) {
$author_display_name = get_the_author_meta( 'display_name', $post->post_author );

/* translators: byline. %s: current author. */
/* translators: byline. %s: author. */
$byline = sprintf( __( 'by %s' ), $author_display_name );

if ( ! empty( $author_display_name ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import LeafMoreMenu from './leaf-more-menu';
import { updateAttributes } from '../../navigation-link/update-attributes';
import { LinkUI } from '../../navigation-link/link-ui';

/* translators: %s: The name of a menu. */
const actionLabel = __( "Switch to '%s'" );
const actionLabel =
/* translators: %s: The name of a menu. */ __( "Switch to '%s'" );
const BLOCKS_WITH_LINK_UI_SUPPORT = [
'core/navigation-link',
'core/navigation-submenu',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import useNavigationEntities from '../use-navigation-entities';

function buildMenuLabel( title, id, status ) {
if ( ! title ) {
/* translators: %s is the index of the menu in the list of menus. */
/* translators: %s: the index of the menu in the list of menus. */
return sprintf( __( '(no title %s)' ), id );
}

Expand All @@ -30,7 +30,7 @@ function buildMenuLabel( title, id, status ) {
}

return sprintf(
// translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.).
// translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.).
__( '%1$s (%2$s)' ),
decodeEntities( title ),
status
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default function PostFeaturedImageEdit( {
label={
postType?.labels.singular_name
? sprintf(
// translators: %s: Name of the post type e.g: "Page".
// translators: %s: Name of the post type e.g: "post".
__( 'Link to %s' ),
postType.labels.singular_name
)
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/post-time-to-read/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ function PostTimeToReadEdit( { attributes, setAttributes, context } ) {
);

return sprintf(
/* translators: %d is the number of minutes the post will take to read. */
_n( '%d minute', '%d minutes', minutesToRead ),
/* translators: %s: the number of minutes to read the post. */
_n( '%s minute', '%s minutes', minutesToRead ),
minutesToRead
);
}, [ contentStructure, blocks ] );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-time-to-read/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function render_block_core_post_time_to_read( $attributes, $content, $block ) {
$minutes_to_read = max( 1, (int) round( wp_word_count( $content, $word_count_type ) / $average_reading_rate ) );

$minutes_to_read_string = sprintf(
/* translators: %s is the number of minutes the post will take to read. */
/* translators: %s: the number of minutes to read the post. */
_n( '%s minute', '%s minutes', $minutes_to_read ),
$minutes_to_read
);
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/query-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
HeadingLevelDropdown,
} from '@wordpress/block-editor';
import { ToggleControl, PanelBody } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function QueryTitleEdit( {
if ( archiveNameLabel ) {
title = sprintf(
/* translators: 1: Archive type title e.g: "Category", 2: Label of the archive e.g: "Shoes" */
__( '%1$s: %2$s' ),
_x( '%1$s: %2$s', 'archive label' ),
archiveTypeLabel,
archiveNameLabel
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const orderOptions = [
value: 'date/asc',
},
{
/* translators: label for ordering posts by title in ascending order */
/* translators: Label for ordering posts by title in ascending order. */
label: __( 'A → Z' ),
value: 'title/asc',
},
{
/* translators: label for ordering posts by title in descending order */
/* translators: Label for ordering posts by title in descending order. */
label: __( 'Z → A' ),
value: 'title/desc',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/rss/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function render_block_core_rss( $attributes ) {
if ( is_object( $author ) ) {
$author = $author->get_name();
$author = '<span class="wp-block-rss__item-author">' . sprintf(
/* translators: %s: the author. */
/* translators: byline. %s: author. */
__( 'by %s' ),
esc_html( strip_tags( $author ) )
) . '</span>';
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function TemplatePartEdit( {
<TagName { ...blockProps }>
<Warning>
{ sprintf(
/* translators: %s: Template part slug */
/* translators: %s: Template part slug. */
__(
'Template part has been deleted or is unavailable: %s'
),
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/video/tracks-editor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';
import {
NavigableMenu,
MenuItem,
Expand Down Expand Up @@ -63,7 +63,7 @@ function TrackList( { tracks, onEditPress } ) {
onClick={ () => onEditPress( index ) }
aria-label={ sprintf(
/* translators: %s: Label of the video text track e.g: "French subtitles" */
__( 'Edit %s' ),
_x( 'Edit %s', 'text tracks' ),
track.label
) }
>
Expand Down
Loading

0 comments on commit 371497e

Please sign in to comment.