Skip to content

Commit

Permalink
make strings translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed May 25, 2022
1 parent bbdff21 commit e33d24b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { useState, useMemo, useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import {
Button,
Flex,
Expand Down Expand Up @@ -124,7 +124,6 @@ function SuggestionList( { entityForSuggestions, onSelect } ) {
return (
<>
<SearchControl
className=""
onChange={ setSearchInputValue }
value={ searchInputValue }
label={ __( 'Search' ) }
Expand All @@ -150,7 +149,9 @@ function SuggestionList( { entityForSuggestions, onSelect } ) {
) ) }
</Composite>
) }
{ !! search && ! suggestions?.length && <p>No results</p> }
{ !! search && ! suggestions?.length && (
<p>{ __( 'No results were found.' ) }</p>
) }
</>
);
}
Expand All @@ -162,7 +163,11 @@ function AddCustomTemplateModal( { onClose, onSelect, entityForSuggestions } ) {
const baseCssClass = 'edit-site-custom-template-modal';
return (
<Modal
title={ `Add a template for post type: ${ entityForSuggestions.labels.singular }` }
title={ sprintf(
// translators: %s: Name of the post type e.g: "Post".
__( 'Add %s template' ),
entityForSuggestions.labels.singular
) }
className={ baseCssClass }
closeLabel={ __( 'Close' ) }
onRequestClose={ onClose }
Expand Down Expand Up @@ -194,30 +199,45 @@ function AddCustomTemplateModal( { onClose, onSelect, entityForSuggestions } ) {
<Icon icon={ globe } />
<Heading level={ 5 }>{ __( 'General' ) }</Heading>
<Text as="span">
{ `Design a template for all ${ entityForSuggestions.labels.plural }.` }
{ sprintf(
// translators: %s: Name of the post type in plural e.g: "Posts".
__( 'Design a template for a all %s.' ),
entityForSuggestions.labels.plural
) }
</Text>
</FlexItem>
<FlexItem
isBlock
onClick={
() => {
setShowSearchEntities( true );
}
// show the available missing types...
}
onClick={ () => {
setShowSearchEntities( true );
} }
>
<Icon icon={ pin } />
<Heading level={ 5 }>{ __( 'Specific' ) }</Heading>
<Text as="span">
{ `Design a template for a specific ${ entityForSuggestions.labels.singular }.` }
{ sprintf(
// translators: %s: Name of the post type e.g: "Post".
__(
'Design a template for a specific %s.'
),
entityForSuggestions.labels.singular
) }
</Text>
</FlexItem>
</Flex>{ ' ' }
</Flex>
</>
) }
{ showSearchEntities && (
<>
<p>{ `Use the search form below to find or create a template for a certain ${ entityForSuggestions.labels.singular }.` }</p>
<p>
{ sprintf(
// translators: %s: Name of the post type e.g: "Post".
__(
'Select the %s you would like to design a template for.'
),
entityForSuggestions.labels.singular
) }
</p>
<SuggestionList
entityForSuggestions={ entityForSuggestions }
onSelect={ onSelect }
Expand Down
27 changes: 22 additions & 5 deletions packages/edit-site/src/components/add-new-template/new-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
search,
tag,
} from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import { store as noticesStore } from '@wordpress/notices';

/**
Expand Down Expand Up @@ -166,8 +166,17 @@ export default function NewTemplate( { postType } ) {
const hasEntities = postTypesHaveEntities?.[ slug ];
const menuItem = {
slug: `single-${ slug }`,
title: `Single ${ singularName }`,
description: `Displays a single ${ singularName }.`,
title: sprintf(
// translators: %s: Name of the post type e.g: "Post".
__( 'Single %s' ),
singularName
),
// title: `Single ${ singularName }`,
description: sprintf(
// translators: %s: Name of the post type e.g: "Post".
__( 'Displays a single %s.' ),
singularName
),
icon,
};
// We have a different template creation flow only if they have entities.
Expand Down Expand Up @@ -208,8 +217,16 @@ export default function NewTemplate( { postType } ) {
) {
accumulator.push( {
slug: `archive-${ slug }`,
title: `${ singularName } archive`,
description: `Displays archive of ${ name }.`,
title: sprintf(
// translators: %s: Name of the post type e.g: "Post".
__( '%s archive' ),
singularName
),
description: sprintf(
// translators: %s: Name of the post type in plural e.g: "Posts".
__( 'Displays archive of %s.' ),
name
),
icon,
} );
}
Expand Down

0 comments on commit e33d24b

Please sign in to comment.