Set up i18n-text-domain rule and fix missing text domain (#33780)

* Set allowedTextDomain to only allow woocommmerce text domain

* Set allowedTextDomain to only allow woocommerce text domain

* Fix wrong or missing i18n text domain

* Add changelog

* Add changelog
This commit is contained in:
Chi-Hsuan Huang 2022-07-08 18:37:30 +08:00 committed by GitHub
parent c33212e612
commit 8952dac7c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 65 additions and 29 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix missing text domain

View File

@ -25,9 +25,9 @@ class ImageUpload extends Component {
}
const frame = wp.media( {
title: __( 'Select or upload image' ),
title: __( 'Select or upload image', 'woocommerce' ),
button: {
text: __( 'Select' ),
text: __( 'Select', 'woocommerce' ),
},
library: {
type: 'image',

View File

@ -5,9 +5,9 @@ import { __ } from '@wordpress/i18n';
import { OrderStatus } from '@woocommerce/components';
const orderStatusMap = {
processing: __( 'Processing Order' ),
pending: __( 'Pending Order' ),
completed: __( 'Completed Order' ),
processing: __( 'Processing Order', 'woocommerce' ),
pending: __( 'Pending Order', 'woocommerce' ),
completed: __( 'Completed Order', 'woocommerce' ),
};
export const Basic = () => (

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Update i18n-text-domain rule to only allow woocommerce text domain

View File

@ -16,6 +16,12 @@ module.exports = {
yoda: [ 'error', 'never' ],
// temporary conversion to warnings until the below are all handled.
'@wordpress/i18n-translator-comments': 'warn',
'@wordpress/i18n-text-domain': [
'error',
{
allowedTextDomain: 'woocommerce',
},
],
'@wordpress/valid-sprintf': 'warn',
'@wordpress/no-unsafe-wp-apis': 'warn',
'@wordpress/no-global-active-element': 'warn',

View File

@ -317,7 +317,7 @@ const ReportTable = ( props ) => {
label: (
<CheckboxControl
onChange={ selectAllRows }
aria-label={ __( 'Select All' ) }
aria-label={ __( 'Select All', 'woocommerce' ) }
checked={ isAllChecked }
disabled={ ! hasData }
/>

View File

@ -132,7 +132,7 @@ class VariationsReportTable extends Component {
return [
{
display: deleted ? (
name + ' ' + __( '(Deleted)', ' woocommerce-admin' )
name + ' ' + __( '(Deleted)', 'woocommerce' )
) : (
<Link href={ editPostLink } type="wp-admin">
{ name }

View File

@ -56,7 +56,7 @@ class SectionControls extends Component {
<MenuItem isClickable onInvoke={ this.onMoveUp }>
<Icon
icon={ <ChevronUpIcon /> }
label={ __( 'Move up' ) }
label={ __( 'Move up', 'woocommerce' ) }
size={ 20 }
className="icon-control"
/>
@ -68,7 +68,7 @@ class SectionControls extends Component {
<Icon
icon={ <ChevronDownIcon /> }
size={ 20 }
label={ __( 'Move down' ) }
label={ __( 'Move down', 'woocommerce' ) }
className="icon-control"
/>
{ __( 'Move down', 'woocommerce' ) }
@ -78,7 +78,7 @@ class SectionControls extends Component {
<Icon
icon={ trash }
size={ 20 }
label={ __( 'Remove block' ) }
label={ __( 'Remove block', 'woocommerce' ) }
className="icon-control"
/>
{ __( 'Remove section', 'woocommerce' ) }

View File

@ -120,7 +120,11 @@ function Snackbar(
tabIndex="0"
role={ ! explicitDismiss ? 'button' : '' }
onKeyPress={ ! explicitDismiss ? dismissMe : noop }
aria-label={ ! explicitDismiss ? __( 'Dismiss this notice' ) : '' }
aria-label={
! explicitDismiss
? __( 'Dismiss this notice', 'woocommerce' )
: ''
}
>
<div className={ snackbarContentClassnames }>
{ icon && (

View File

@ -96,7 +96,9 @@ const Header = () => {
} );
if ( siteIconUrl ) {
buttonIcon = <img alt={ __( 'Site Icon' ) } src={ siteIconUrl } />;
buttonIcon = (
<img alt={ __( 'Site Icon', 'woocommerce' ) } src={ siteIconUrl } />
);
} else if ( isRequestingSiteIcon ) {
buttonIcon = null;
}

View File

@ -81,7 +81,7 @@ export const Plugin: React.FC< PluginProps > = ( {
onManage( slug );
} }
>
{ __( 'Manage', 'woocommmerce-admin' ) }
{ __( 'Manage', 'woocommerce' ) }
</Button>
) }
{ isInstalled && ! isActive && (
@ -91,7 +91,7 @@ export const Plugin: React.FC< PluginProps > = ( {
isSecondary
onClick={ () => installAndActivate( slug ) }
>
{ __( 'Activate', 'woocommmerce-admin' ) }
{ __( 'Activate', 'woocommerce' ) }
</Button>
) }
{ ! isInstalled && (
@ -101,7 +101,7 @@ export const Plugin: React.FC< PluginProps > = ( {
isSecondary
onClick={ () => installAndActivate( slug ) }
>
{ __( 'Get started', 'woocommmerce-admin' ) }
{ __( 'Get started', 'woocommerce' ) }
</Button>
) }
</div>

View File

@ -21,10 +21,13 @@ const LoadSampleProductModal: React.FC = () => {
>
<Spinner color="#007cba" size={ 48 } />
<Text className="woocommerce-load-sample-product-modal__title">
{ __( 'Loading sample products' ) }
{ __( 'Loading sample products', 'woocommerce' ) }
</Text>
<Text className="woocommerce-load-sample-product-modal__description">
{ __( 'We are loading 9 sample products into your store' ) }
{ __(
'We are loading 9 sample products into your store',
'woocommerce'
) }
</Text>
</Modal>
);

View File

@ -30,7 +30,8 @@ const CardLayout: React.FC< CardProps > = ( { items } ) => {
<Text className="woocommerce-products-card-layout__description">
{ interpolateComponents( {
mixedString: __(
'{{sbLink}}Start blank{{/sbLink}} or select a product type:'
'{{sbLink}}Start blank{{/sbLink}} or select a product type:',
'woocommerce'
),
components: {
sbLink: (

View File

@ -76,7 +76,8 @@ export const LoadSampleProductType = {
key: 'load-sample-product' as const,
title: __( 'cant decide?', 'woocommerce' ),
content: __(
'Load sample products and see what they look like in your store.'
'Load sample products and see what they look like in your store.',
'woocommerce'
),
before: <LightBulb />,
after: <Icon icon={ chevronRight } />,

View File

@ -25,7 +25,8 @@ const Footer: React.FC = () => {
<Text className="woocommerce-products-footer__import-options">
{ interpolateComponents( {
mixedString: __(
'{{importCSVLink}}Import your products from a CSV file{{/importCSVLink}} or {{_3rdLink}}use a 3rd party migration plugin{{/_3rdLink}}.'
'{{importCSVLink}}Import your products from a CSV file{{/importCSVLink}} or {{_3rdLink}}use a 3rd party migration plugin{{/_3rdLink}}.',
'woocommerce'
),
components: {
importCSVLink: (

View File

@ -159,7 +159,7 @@ export default function ProductTemplateModal( { onClose } ) {
return (
<Modal
title={ __( 'Start with a template' ) }
title={ __( 'Start with a template', 'woocommerce' ) }
isDismissible={ true }
onRequestClose={ () => onClose() }
className="woocommerce-product-template-modal"
@ -193,7 +193,7 @@ export default function ProductTemplateModal( { onClose } ) {
disabled={ ! selectedTemplate || isRedirecting }
onClick={ createTemplate }
>
{ __( 'Go' ) }
{ __( 'Go', 'woocommerce' ) }
</Button>
</div>
</div>

View File

@ -66,7 +66,7 @@ export const TaskListItem: React.FC< TaskListItemProps > = ( {
const onDismiss = useCallback( () => {
dismissTask( id );
createNotice( 'success', __( 'Task dismissed' ), {
createNotice( 'success', __( 'Task dismissed', 'woocommerce' ), {
actions: [
{
label: __( 'Undo', 'woocommerce' ),

View File

@ -89,7 +89,7 @@ const WoocommercePaymentsHeader = ( { task, trackClick } ) => {
</Button>
<p className="woocommerce-task-header__timer">
<img src={ TimerImage } alt="Timer" />{ ' ' }
<span>{ __( '2 minutes' ) }</span>
<span>{ __( '2 minutes', 'woocommerce' ) }</span>
</p>
</div>
</div>

View File

@ -46,7 +46,7 @@ export const TaskListItemTwoColumn: React.FC< TaskListItemProps > = ( {
const onDismissTask = ( onDismiss?: () => void ) => {
dismissTask( taskId );
createNotice( 'success', __( 'Task dismissed' ), {
createNotice( 'success', __( 'Task dismissed', 'woocommerce' ), {
actions: [
{
label: __( 'Undo', 'woocommerce' ),

View File

@ -97,7 +97,7 @@ export const TaskListItem: React.FC< TaskListItemProps > = ( {
const onDismiss = useCallback( () => {
dismissTask( task.id );
createNotice( 'success', __( 'Task dismissed' ), {
createNotice( 'success', __( 'Task dismissed', 'woocommerce' ), {
actions: [
{
label: __( 'Undo', 'woocommerce' ),

View File

@ -40,7 +40,10 @@ export function getAdminSetting(
) {
if ( mutableSources.includes( name ) ) {
throw new Error(
__( 'Mutable settings should be accessed via data store.' )
__(
'Mutable settings should be accessed via data store.',
'woocommerce'
)
);
}
const value = ADMIN_SETTINGS_SOURCE.hasOwnProperty( name )
@ -75,7 +78,10 @@ export const ORDER_STATUSES = getAdminSetting( 'orderStatuses' );
export function setAdminSetting( name, value, filter = ( val ) => val ) {
if ( mutableSources.includes( name ) ) {
throw new Error(
__( 'Mutable settings should be mutated via data store.' )
__(
'Mutable settings should be mutated via data store.',
'woocommerce'
)
);
}
ADMIN_SETTINGS_SOURCE[ name ] = filter( value );

View File

@ -8,7 +8,7 @@ import { getAdminLink } from '@woocommerce/settings';
domReady( () => {
dispatch( 'core/notices' ).createSuccessNotice(
__( 'Sample products added' ),
__( 'Sample products added', 'woocommerce' ),
{
id: 'WOOCOMMERCE_ONBOARDING_LOAD_SAMPLE_PRODUCTS_NOTICE',
actions: [

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix missing text domain strings