From 1423a1ba5b928fc4e80e98f54486c6e9053371a4 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 26 Sep 2024 12:26:18 -0400 Subject: [PATCH] fix lint issues with i18n strings --- src/app/components/errorCard/index.js | 3 +- src/app/pages/home/myProductsSection.js | 1 + src/app/pages/settings/commentSettings.js | 46 ++++++++++------------- src/app/pages/settings/contentSettings.js | 36 ++++++------------ 4 files changed, 34 insertions(+), 52 deletions(-) diff --git a/src/app/components/errorCard/index.js b/src/app/components/errorCard/index.js index abba3619e..f34996015 100644 --- a/src/app/components/errorCard/index.js +++ b/src/app/components/errorCard/index.js @@ -45,7 +45,8 @@ const ErrorCard = ( { error, className, notice = 'Error!' } ) => {

{ error && error.message ? error.message : '' } { error && error.data - ? __( ' Error code: ', 'wp-plugin-bluehost' ) + + ? __( 'Error code:', 'wp-plugin-bluehost' ) + + ' ' + error.data.status : '' }

diff --git a/src/app/pages/home/myProductsSection.js b/src/app/pages/home/myProductsSection.js index 39be23d3e..c379d7970 100644 --- a/src/app/pages/home/myProductsSection.js +++ b/src/app/pages/home/myProductsSection.js @@ -1,3 +1,4 @@ +/* eslint-disable @wordpress/i18n-no-flanking-whitespace */ import apiFetch from '@wordpress/api-fetch'; import { useState, useEffect } from '@wordpress/element'; import { NewfoldRuntime } from '@newfold-labs/wp-module-runtime'; diff --git a/src/app/pages/settings/commentSettings.js b/src/app/pages/settings/commentSettings.js index 947542532..d28253e95 100644 --- a/src/app/pages/settings/commentSettings.js +++ b/src/app/pages/settings/commentSettings.js @@ -1,3 +1,4 @@ +/* global sprintf */ import { useState } from '@wordpress/element'; import { useUpdateEffect } from 'react-use'; import { @@ -9,7 +10,6 @@ import { import AppStore from '../../data/store'; import { bluehostSettingsApiFetch } from '../../util/helpers'; import { useNotification } from 'App/components/notifications'; - const OldPostsComments = ( { setError, notify } ) => { const { store, setStore } = useContext( AppStore ); const [ disableCommentsOldPosts, setDisableCommentsOldPosts ] = useState( @@ -78,37 +78,32 @@ const CloseCommentsDays = ( { setError, notify } ) => { ); const closeCommentsDaysNoticeTitle = () => { - return __( 'Comments setting saved ', 'wp-plugin-bluehost' ); + return __( 'Comments setting saved', 'wp-plugin-bluehost' ); }; const closeCommentsDaysNoticeText = () => { - //`Comments on posts are disabled after ${closeCommentsDays} days.` - return ( - __( - 'Comments on posts are disabled after ', - 'wp-plugin-bluehost' - ) + - closeCommentsDays + + return sprintf( + //translators: %s: number of days. `Comments on posts are disabled after ${closeCommentsDays} days.` _n( - ' day.', - ' days.', + 'Comments on posts are disabled after %s day.', + 'Comments on posts are disabled after %s days.', parseInt( closeCommentsDays ), 'wp-plugin-bluehost' - ) + ), + closeCommentsDays ); }; const closeCommentsDaysLabelText = () => { - //`Close comments after ${closeCommentsDays} days.` - return ( - __( 'Close comments after ', 'wp-plugin-bluehost' ) + - closeCommentsDays + + return sprintf( + //translators: %s: number of days. `Close comments after ${closeCommentsDays} days.` _n( - ' day.', - ' days.', + 'Close comments after %s day.', + 'Close comments after %s days.', parseInt( closeCommentsDays ), 'wp-plugin-bluehost' - ) + ), + closeCommentsDays ); }; @@ -178,16 +173,15 @@ const CommentsPerPage = ( { setError, notify } ) => { }; const commentsPerPageNoticeText = () => { - //`Posts will display ${commentsPerPage} comments at a time.` - return ( - __( 'Posts will display ', 'wp-plugin-bluehost' ) + - commentsPerPage + + return sprintf( + //translators: %s: number of comments. `Posts will display ${commentsPerPage} comments at a time.` _n( - ' comment at a time.', - ' comments at a time.', + 'Posts will display %s comment at a time.', + 'Posts will display %s comments at a time.', parseInt( commentsPerPage ), 'wp-plugin-bluehost' - ) + ), + commentsPerPage ); }; diff --git a/src/app/pages/settings/contentSettings.js b/src/app/pages/settings/contentSettings.js index 570824c1b..c4239ab08 100644 --- a/src/app/pages/settings/contentSettings.js +++ b/src/app/pages/settings/contentSettings.js @@ -1,3 +1,4 @@ +/* global sprintf */ import { useState } from '@wordpress/element'; import { useUpdateEffect } from 'react-use'; import { Alert, Container, SelectField } from '@newfold/ui-component-library'; @@ -13,22 +14,19 @@ const EmptyTrash = ( { setError, notify } ) => { let numTrashWeeks = Math.floor( emptyTrashDays / 7 ); const emptyTrashNoticeTitle = () => { - return __( 'Trash setting saved ', 'wp-plugin-bluehost' ); + return __( 'Trash setting saved', 'wp-plugin-bluehost' ); }; const emptyTrashNoticeText = () => { - return ( - __( - 'The trash will automatically empty every ', - 'wp-plugin-bluehost' - ) + - numTrashWeeks + + return sprintf( + //translators: %s: number of weeks. `The trash will automatically empty every ${numTrashWeeks} weeks.` _n( - ' week.', - ' weeks.', + 'The trash will automatically empty every %s week.', + 'The trash will automatically empty every %s weeks.', parseInt( numTrashWeeks ), 'wp-plugin-bluehost' - ) + ), + numTrashWeeks ); }; @@ -66,22 +64,10 @@ const EmptyTrash = ( { setError, notify } ) => { {