Skip to content

Commit 19ae4eb

Browse files
fix: apply style guide to error messages and warnings (extended) (#1076)
Extends #1074 with a comprehensive pass across the entire monorepo. ## Changes ### Style guide compliance (29 files) - Remove "Please" from all error/warning messages (direct voice) - Remove "You are using/attempting" patterns (active voice) - `in-line` → `inline` in CLI messages - Simplify verbose messages while preserving meaning - Use present tense where appropriate ### Bug fixes (from main, not yet in #1074) - `will like fallback` → `will likely fall back` - Capitalize sentence starts (`no locales` → `No locales`) ### Packages touched - `next` (errors/cacheComponents, errors/createErrors, errors/ssg) - `react-core` (errors-dir/createErrors) - `cli` (console/index, console/logging, setup, config, formats, workflows, utils) - `compiler` (state/StringCollector) - `locadex` (logging/console) - `sanity` (serialization/serialize) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated user-facing messages throughout the CLI and SDK for improved clarity and consistency. Messages now use more direct phrasing by removing redundant words and adjusting wording for a cleaner tone. Minor text corrections, including spelling standardization. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR extends #1074 with a comprehensive, monorepo-wide style guide pass across 29 files, applying direct voice to all error and warning messages (removing "Please", "You are using/attempting" patterns, `in-line` → `inline`) while also fixing two correctness issues from `main`: the typo `"will like fallback"` → `"will likely fall back"` and a missing sentence-start capitalisation in `ssg.ts`. Key changes: - **Style guide compliance** applied consistently across `packages/next`, `packages/react-core`, `packages/cli`, `packages/compiler`, `packages/locadex`, and `packages/sanity` - **Bug fix**: `createSsrFunctionDuringSsgWarning` in `ssg.ts` corrects a long-standing typo and now ends with a period for consistency - **Pre-existing inconsistency in react-core**: `customLoadDictionaryWarning` uses `Error:` prefix but should use `Warning:` to match the function name and align with the corresponding function in `packages/next`; since the file is touched by this PR it would be a low-cost fix to correct here <details open><summary><h3>Confidence Score: 4/5</h3></summary> - This PR is safe to merge. All changes are pure string literal modifications with no logic or type signature changes. - Safe to merge with minor action item: one function in react-core named `customLoadDictionaryWarning` uses "Error:" prefix instead of "Warning:", which should be corrected while the file is open. The file is already being edited in this PR, making this a low-cost fix. All other style guide changes are correct and consistent. - packages/react-core/src/errors-dir/createErrors.ts — change "Error:" to "Warning:" in `customLoadDictionaryWarning` to match function name and the corresponding function in `packages/next` </details> <details><summary><h3>Flowchart</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD subgraph packages["Packages with updated messages"] CLI["packages/cli<br/>(console/index, logging,<br/>base, react, config,<br/>formats, fs, locadex,<br/>setup, translation,<br/>utils, workflows)"] NEXT["packages/next<br/>(errors/cacheComponents,<br/>errors/createErrors,<br/>errors/ssg)"] RC["packages/react-core<br/>(errors-dir/createErrors)"] COMP["packages/compiler<br/>(state/StringCollector)"] LOC["packages/locadex<br/>(logging/console)"] SAN["packages/sanity<br/>(serialization/serialize)"] end subgraph changes["Style Changes Applied"] P["Remove 'Please'"] Y["Remove 'You are using/attempting'"] IL["in-line → inline"] TF["Typo fix: 'will like fallback'<br/>→ 'will likely fall back'"] CAP["Capitalise sentence starts"] end CLI --> P & Y & IL NEXT --> P & Y & TF & CAP RC --> P & Y COMP --> Y LOC --> P SAN --> P ``` </details> <sub>Last reviewed commit: 134fa69</sub> > Greptile also left **1 inline comment** on this PR. <!-- /greptile_comment --> --------- Co-authored-by: moss-bryophyta <261561981+moss-bryophyta@users.noreply.github.com>
1 parent 66917c9 commit 19ae4eb

File tree

32 files changed

+90
-80
lines changed

32 files changed

+90
-80
lines changed

.changeset/style-guide-errors.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"gt": patch
3+
"gt-next": patch
4+
"@generaltranslation/react-core": patch
5+
"@generaltranslation/compiler": patch
6+
"locadex": patch
7+
"gt-sanity": patch
8+
---
9+
10+
Apply style guide to error messages and warnings: remove "Please", simplify verbose phrasing, fix `in-line``inline`.

packages/cli/src/cli/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ See https://generaltranslation.com/en/docs/next/guides/local-tx`
599599
const files: FilesOptions = {};
600600
for (const fileExtension of fileExtensions) {
601601
const paths = await promptText({
602-
message: `${chalk.cyan(FILE_EXT_TO_EXT_LABEL[fileExtension])}: Please enter a space-separated list of glob patterns matching the location of the ${FILE_EXT_TO_EXT_LABEL[fileExtension]} files you would like to translate.\nMake sure to include [locale] in the patterns.\nSee https://generaltranslation.com/docs/cli/reference/config#include for more information.`,
602+
message: `${chalk.cyan(FILE_EXT_TO_EXT_LABEL[fileExtension])}: Enter a space-separated list of glob patterns matching the location of the ${FILE_EXT_TO_EXT_LABEL[fileExtension]} files you would like to translate.\nMake sure to include [locale] in the patterns.\nSee https://generaltranslation.com/docs/cli/reference/config#include for more information.`,
603603
defaultValue: `./**/[locale]/*.${fileExtension}`,
604604
});
605605

packages/cli/src/cli/commands/upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export async function upload(
122122

123123
if (allFiles.length === 0) {
124124
logger.error(
125-
'No files to upload were found. Please check your configuration and try again.'
125+
'No files to upload were found. Check your configuration and try again.'
126126
);
127127
return;
128128
}

packages/cli/src/cli/react.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ReactCLI extends InlineCLI {
104104
filesUpdated.map((file) => `${chalk.green('-')} ${file}`).join('\n')
105105
);
106106
if (filesUpdated.length > 0) {
107-
logger.step(chalk.green('Please verify the changes before committing.'));
107+
logger.step(chalk.green('Verify the changes before committing.'));
108108
}
109109

110110
if (warnings.length > 0) {

packages/cli/src/config/generateSettings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ export async function generateSettings(
7373
gtConfig.projectId !== flags.projectId
7474
) {
7575
logErrorAndExit(
76-
`Project ID mismatch between ${chalk.green(gtConfig.projectId)} and ${chalk.green(flags.projectId)}! Please use the same projectId in all configs.`
76+
`Project ID mismatch between ${chalk.green(gtConfig.projectId)} and ${chalk.green(flags.projectId)}! Use the same projectId in all configs.`
7777
);
7878
} else if (
7979
gtConfig.projectId &&
8080
projectIdEnv &&
8181
gtConfig.projectId !== projectIdEnv
8282
) {
8383
logErrorAndExit(
84-
`Project ID mismatch between ${chalk.green(gtConfig.projectId)} and ${chalk.green(projectIdEnv)}! Please use the same projectId in all configs.`
84+
`Project ID mismatch between ${chalk.green(gtConfig.projectId)} and ${chalk.green(projectIdEnv)}! Use the same projectId in all configs.`
8585
);
8686
}
8787

packages/cli/src/config/validateSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function validateSettings(settings: Settings) {
3535
isSupersetLocale(settings.defaultLocale, locale)
3636
);
3737
return logErrorAndExit(
38-
`defaultLocale: ${settings.defaultLocale} is a superset of another locale (${locale})! Please change the defaultLocale to a more specific locale.`
38+
`defaultLocale: ${settings.defaultLocale} is a superset of another locale (${locale})! Change the defaultLocale to a more specific locale.`
3939
);
4040
}
4141
}

packages/cli/src/console/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const withDeclareStaticError = (message: string): string =>
2222
export const warnApiKeyInConfigSync = (optionsFilepath: string): string =>
2323
`${colorizeFilepath(
2424
optionsFilepath
25-
)}: Your API key is exposed! Please remove it from the file and include it as an environment variable.`;
25+
)}: Your API key is exposed! Remove it from the file and include it as an environment variable.`;
2626

2727
export const warnVariablePropSync = (
2828
file: string,
@@ -288,13 +288,13 @@ export const warnDeclareStaticNoResultsSync = (
288288
);
289289

290290
// Re-export error messages
291-
export const noLocalesError = `No locales found! Please provide a list of locales for translation, or specify them in your gt.config.json file.`;
292-
export const noDefaultLocaleError = `No default locale found! Please provide a default locale, or specify it in your gt.config.json file.`;
293-
export const noFilesError = `Incorrect or missing files configuration! Please make sure your files are configured correctly in your gt.config.json file.`;
294-
export const noSourceFileError = `No source file found! Please double check your translations directory and default locale.`;
295-
export const noSupportedFormatError = `Unsupported data format! Please make sure your translationsDir parameter ends with a supported file extension.`;
296-
export const noApiKeyError = `No API key found! Please provide an API key using the --api-key flag or set the GT_API_KEY environment variable.`;
297-
export const devApiKeyError = `You are using a development API key. Please use a production API key to use the General Translation API.\nYou can generate a production API key with the command: npx gt auth -t production`;
298-
export const noProjectIdError = `No project ID found! Please provide a project ID using the --project-id flag, specify it in your gt.config.json file, or set the GT_PROJECT_ID environment variable.`;
299-
export const noVersionIdError = `No version ID found! Please provide a version ID using the --version-id flag or specify it in your gt.config.json file as the _versionId property.`;
300-
export const invalidConfigurationError = `Invalid files configuration! Please either provide a valid configuration to download local translations or set the --publish flag to true to upload translations to the CDN.`;
291+
export const noLocalesError = `No locales found! Provide a list of locales for translation, or specify them in your gt.config.json file.`;
292+
export const noDefaultLocaleError = `No default locale found! Provide a default locale, or specify it in your gt.config.json file.`;
293+
export const noFilesError = `Incorrect or missing files configuration! Make sure your files are configured correctly in your gt.config.json file.`;
294+
export const noSourceFileError = `No source file found! Double-check your translations directory and default locale.`;
295+
export const noSupportedFormatError = `Unsupported data format! Make sure your translationsDir parameter ends with a supported file extension.`;
296+
export const noApiKeyError = `No API key found! Provide an API key using the --api-key flag or set the GT_API_KEY environment variable.`;
297+
export const devApiKeyError = `Development API keys cannot be used with the General Translation API. Use a production API key instead.\nGenerate a production API key with: npx gt auth -t production`;
298+
export const noProjectIdError = `No project ID found! Provide a project ID using the --project-id flag, specify it in your gt.config.json file, or set the GT_PROJECT_ID environment variable.`;
299+
export const noVersionIdError = `No version ID found! Provide a version ID using the --version-id flag or specify it in your gt.config.json file as the _versionId property.`;
300+
export const invalidConfigurationError = `Invalid files configuration! Provide a valid configuration to download local translations or set the --publish flag to true to upload translations to the CDN.`;

packages/cli/src/console/logging.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export function warnApiKeyInConfig(optionsFilepath: string) {
206206
logger.warn(
207207
`Found ${chalk.cyan('apiKey')} in "${chalk.green(optionsFilepath)}". ` +
208208
chalk.white(
209-
'Your API key is exposed! Please remove it from the file and include it as an environment variable.'
209+
'Your API key is exposed! Remove it from the file and include it as an environment variable.'
210210
)
211211
);
212212
}

packages/cli/src/formats/files/aggregateFiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export async function aggregateFiles(
203203

204204
if (allFiles.length === 0 && !settings.publish) {
205205
logger.error(
206-
'No files to translate were found. Please check your configuration and try again.'
206+
'No files to translate were found. Check your configuration and try again.'
207207
);
208208
}
209209

packages/cli/src/formats/json/__tests__/parseJson.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ describe('parseJson', () => {
312312
}).toThrow('Process exit called');
313313

314314
expect(mockLogError).toHaveBeenCalledWith(
315-
'Matching sourceItem not found at path: /test for locale: en. Please check your JSON schema'
315+
'Matching sourceItem not found at path: /test for locale: en. Check your JSON schema'
316316
);
317317
expect(mockExit).toHaveBeenCalledWith(1);
318318
});

0 commit comments

Comments
 (0)