gtx-cli 2.6.31 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -1261
- package/README.md +12 -3
- package/dist/bin/bin-entry.js +2 -1
- package/dist/config/generateSettings.d.ts +1 -9
- package/dist/config/generateSettings.js +1 -214
- package/dist/config/resolveConfig.d.ts +1 -4
- package/dist/config/resolveConfig.js +1 -33
- package/dist/fs/config/setupConfig.d.ts +1 -17
- package/dist/fs/config/setupConfig.js +1 -50
- package/dist/fs/matchFiles.d.ts +1 -1
- package/dist/fs/matchFiles.js +1 -8
- package/dist/functions.d.ts +1 -7
- package/dist/functions.js +1 -6
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -27
- package/dist/main.js +2 -2
- package/dist/next/parse/handleInitGT.d.ts +1 -7
- package/dist/next/parse/handleInitGT.js +1 -157
- package/dist/next/parse/wrapContent.d.ts +1 -12
- package/dist/next/parse/wrapContent.js +1 -164
- package/dist/react/parse/wrapContent.d.ts +1 -12
- package/dist/react/parse/wrapContent.js +1 -162
- package/dist/types/index.d.ts +1 -243
- package/dist/types/index.js +1 -1
- package/dist/utils/installPackage.d.ts +1 -3
- package/dist/utils/installPackage.js +1 -77
- package/dist/utils/packageInfo.d.ts +1 -3
- package/dist/utils/packageInfo.js +1 -17
- package/dist/utils/packageJson.d.ts +1 -6
- package/dist/utils/packageJson.js +1 -68
- package/dist/utils/packageManager.d.ts +1 -28
- package/dist/utils/packageManager.js +1 -269
- package/package.json +11 -97
- package/dist/api/collectUserEditDiffs.d.ts +0 -9
- package/dist/api/collectUserEditDiffs.js +0 -159
- package/dist/api/downloadFileBatch.d.ts +0 -23
- package/dist/api/downloadFileBatch.js +0 -190
- package/dist/api/saveLocalEdits.d.ts +0 -6
- package/dist/api/saveLocalEdits.js +0 -38
- package/dist/cli/base.d.ts +0 -59
- package/dist/cli/base.js +0 -529
- package/dist/cli/commands/download.d.ts +0 -8
- package/dist/cli/commands/download.js +0 -51
- package/dist/cli/commands/enqueue.d.ts +0 -9
- package/dist/cli/commands/enqueue.js +0 -27
- package/dist/cli/commands/setupProject.d.ts +0 -7
- package/dist/cli/commands/setupProject.js +0 -37
- package/dist/cli/commands/stage.d.ts +0 -9
- package/dist/cli/commands/stage.js +0 -59
- package/dist/cli/commands/translate.d.ts +0 -7
- package/dist/cli/commands/translate.js +0 -70
- package/dist/cli/commands/upload.d.ts +0 -13
- package/dist/cli/commands/upload.js +0 -142
- package/dist/cli/commands/utils/validation.d.ts +0 -13
- package/dist/cli/commands/utils/validation.js +0 -38
- package/dist/cli/flags.d.ts +0 -15
- package/dist/cli/flags.js +0 -70
- package/dist/cli/inline.d.ts +0 -17
- package/dist/cli/inline.js +0 -135
- package/dist/cli/next.d.ts +0 -10
- package/dist/cli/next.js +0 -12
- package/dist/cli/node.d.ts +0 -10
- package/dist/cli/node.js +0 -9
- package/dist/cli/react.d.ts +0 -12
- package/dist/cli/react.js +0 -72
- package/dist/config/optionPresets.d.ts +0 -3
- package/dist/config/optionPresets.js +0 -65
- package/dist/config/utils.d.ts +0 -2
- package/dist/config/utils.js +0 -4
- package/dist/config/validateSettings.d.ts +0 -3
- package/dist/config/validateSettings.js +0 -32
- package/dist/console/colors.d.ts +0 -6
- package/dist/console/colors.js +0 -19
- package/dist/console/displayTranslateSummary.d.ts +0 -1
- package/dist/console/displayTranslateSummary.js +0 -42
- package/dist/console/formatting.d.ts +0 -1
- package/dist/console/formatting.js +0 -7
- package/dist/console/index.d.ts +0 -34
- package/dist/console/index.js +0 -46
- package/dist/console/logger.d.ts +0 -35
- package/dist/console/logger.js +0 -250
- package/dist/console/logging.d.ts +0 -52
- package/dist/console/logging.js +0 -175
- package/dist/formats/files/aggregateFiles.d.ts +0 -4
- package/dist/formats/files/aggregateFiles.js +0 -156
- package/dist/formats/files/collectFiles.d.ts +0 -6
- package/dist/formats/files/collectFiles.js +0 -49
- package/dist/formats/files/convertToFileTranslationData.d.ts +0 -15
- package/dist/formats/files/convertToFileTranslationData.js +0 -21
- package/dist/formats/files/fileMapping.d.ts +0 -11
- package/dist/formats/files/fileMapping.js +0 -115
- package/dist/formats/files/preprocess/mdx.d.ts +0 -6
- package/dist/formats/files/preprocess/mdx.js +0 -14
- package/dist/formats/files/preprocess/mintlify.d.ts +0 -5
- package/dist/formats/files/preprocess/mintlify.js +0 -15
- package/dist/formats/files/preprocessContent.d.ts +0 -8
- package/dist/formats/files/preprocessContent.js +0 -23
- package/dist/formats/files/save.d.ts +0 -5
- package/dist/formats/files/save.js +0 -17
- package/dist/formats/files/supportedFiles.d.ts +0 -11
- package/dist/formats/files/supportedFiles.js +0 -20
- package/dist/formats/json/extractJson.d.ts +0 -15
- package/dist/formats/json/extractJson.js +0 -101
- package/dist/formats/json/flattenJson.d.ts +0 -14
- package/dist/formats/json/flattenJson.js +0 -64
- package/dist/formats/json/mergeJson.d.ts +0 -13
- package/dist/formats/json/mergeJson.js +0 -367
- package/dist/formats/json/parseJson.d.ts +0 -2
- package/dist/formats/json/parseJson.js +0 -109
- package/dist/formats/json/utils.d.ts +0 -47
- package/dist/formats/json/utils.js +0 -150
- package/dist/formats/utils.d.ts +0 -2
- package/dist/formats/utils.js +0 -24
- package/dist/formats/yaml/mergeYaml.d.ts +0 -5
- package/dist/formats/yaml/mergeYaml.js +0 -61
- package/dist/formats/yaml/parseYaml.d.ts +0 -5
- package/dist/formats/yaml/parseYaml.js +0 -24
- package/dist/formats/yaml/utils.d.ts +0 -2
- package/dist/formats/yaml/utils.js +0 -23
- package/dist/fs/clearLocaleDirs.d.ts +0 -8
- package/dist/fs/clearLocaleDirs.js +0 -126
- package/dist/fs/config/downloadedVersions.d.ts +0 -21
- package/dist/fs/config/downloadedVersions.js +0 -50
- package/dist/fs/config/loadConfig.d.ts +0 -1
- package/dist/fs/config/loadConfig.js +0 -9
- package/dist/fs/config/parseFilesConfig.d.ts +0 -27
- package/dist/fs/config/parseFilesConfig.js +0 -150
- package/dist/fs/config/updateConfig.d.ts +0 -21
- package/dist/fs/config/updateConfig.js +0 -57
- package/dist/fs/config/updateVersions.d.ts +0 -11
- package/dist/fs/config/updateVersions.js +0 -30
- package/dist/fs/copyFile.d.ts +0 -7
- package/dist/fs/copyFile.js +0 -39
- package/dist/fs/createLoadTranslationsFile.d.ts +0 -1
- package/dist/fs/createLoadTranslationsFile.js +0 -49
- package/dist/fs/determineFramework.d.ts +0 -5
- package/dist/fs/determineFramework.js +0 -53
- package/dist/fs/findFilepath.d.ts +0 -36
- package/dist/fs/findFilepath.js +0 -90
- package/dist/fs/index.d.ts +0 -1
- package/dist/fs/index.js +0 -1
- package/dist/fs/loadJSON.d.ts +0 -6
- package/dist/fs/loadJSON.js +0 -17
- package/dist/fs/saveJSON.d.ts +0 -1
- package/dist/fs/saveJSON.js +0 -7
- package/dist/fs/utils.d.ts +0 -1
- package/dist/fs/utils.js +0 -16
- package/dist/generated/version.d.ts +0 -1
- package/dist/generated/version.js +0 -2
- package/dist/git/branches.d.ts +0 -7
- package/dist/git/branches.js +0 -88
- package/dist/hooks/postProcess.d.ts +0 -4
- package/dist/hooks/postProcess.js +0 -110
- package/dist/locadex/setupFlow.d.ts +0 -2
- package/dist/locadex/setupFlow.js +0 -9
- package/dist/next/config/parseNextConfig.d.ts +0 -10
- package/dist/next/config/parseNextConfig.js +0 -53
- package/dist/next/jsx/utils.d.ts +0 -7
- package/dist/next/jsx/utils.js +0 -42
- package/dist/react/config/createESBuildConfig.d.ts +0 -2
- package/dist/react/config/createESBuildConfig.js +0 -119
- package/dist/react/jsx/evaluateJsx.d.ts +0 -24
- package/dist/react/jsx/evaluateJsx.js +0 -123
- package/dist/react/jsx/utils/buildImportMap.d.ts +0 -9
- package/dist/react/jsx/utils/buildImportMap.js +0 -30
- package/dist/react/jsx/utils/constants.d.ts +0 -15
- package/dist/react/jsx/utils/constants.js +0 -49
- package/dist/react/jsx/utils/getCalleeNameFromExpression.d.ts +0 -9
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js +0 -32
- package/dist/react/jsx/utils/getPathsAndAliases.d.ts +0 -21
- package/dist/react/jsx/utils/getPathsAndAliases.js +0 -91
- package/dist/react/jsx/utils/isNumberLiteral.d.ts +0 -7
- package/dist/react/jsx/utils/isNumberLiteral.js +0 -13
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.d.ts +0 -9
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +0 -138
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.d.ts +0 -6
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +0 -197
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.d.ts +0 -13
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +0 -42
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.d.ts +0 -5
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +0 -69
- package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +0 -33
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +0 -918
- package/dist/react/jsx/utils/jsxParsing/parseTProps.d.ts +0 -8
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js +0 -65
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.d.ts +0 -2
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +0 -61
- package/dist/react/jsx/utils/jsxParsing/types.d.ts +0 -48
- package/dist/react/jsx/utils/jsxParsing/types.js +0 -34
- package/dist/react/jsx/utils/mapAttributeName.d.ts +0 -11
- package/dist/react/jsx/utils/mapAttributeName.js +0 -12
- package/dist/react/jsx/utils/parseAst.d.ts +0 -31
- package/dist/react/jsx/utils/parseAst.js +0 -278
- package/dist/react/jsx/utils/parseDeclareStatic.d.ts +0 -15
- package/dist/react/jsx/utils/parseDeclareStatic.js +0 -540
- package/dist/react/jsx/utils/parseString.d.ts +0 -25
- package/dist/react/jsx/utils/parseString.js +0 -540
- package/dist/react/jsx/utils/parseStringFunction.d.ts +0 -30
- package/dist/react/jsx/utils/parseStringFunction.js +0 -348
- package/dist/react/jsx/utils/resolveImportPath.d.ts +0 -11
- package/dist/react/jsx/utils/resolveImportPath.js +0 -111
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.d.ts +0 -29
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +0 -86
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.d.ts +0 -14
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +0 -24
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.d.ts +0 -19
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +0 -31
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.d.ts +0 -22
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.js +0 -51
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.d.ts +0 -18
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +0 -39
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.d.ts +0 -24
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +0 -68
- package/dist/react/jsx/utils/stringParsing/types.d.ts +0 -41
- package/dist/react/jsx/utils/stringParsing/types.js +0 -1
- package/dist/react/jsx/utils/types.d.ts +0 -14
- package/dist/react/jsx/utils/types.js +0 -1
- package/dist/react/jsx/utils/validateStringFunction.d.ts +0 -7
- package/dist/react/jsx/utils/validateStringFunction.js +0 -31
- package/dist/react/jsx/wrapJsx.d.ts +0 -51
- package/dist/react/jsx/wrapJsx.js +0 -387
- package/dist/react/parse/addVitePlugin/index.d.ts +0 -22
- package/dist/react/parse/addVitePlugin/index.js +0 -41
- package/dist/react/parse/addVitePlugin/installCompiler.d.ts +0 -8
- package/dist/react/parse/addVitePlugin/installCompiler.js +0 -22
- package/dist/react/parse/addVitePlugin/updateViteConfig.d.ts +0 -19
- package/dist/react/parse/addVitePlugin/updateViteConfig.js +0 -120
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.d.ts +0 -9
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +0 -34
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.d.ts +0 -11
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +0 -48
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.d.ts +0 -15
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +0 -113
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.d.ts +0 -12
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +0 -32
- package/dist/react/parse/createDictionaryUpdates.d.ts +0 -3
- package/dist/react/parse/createDictionaryUpdates.js +0 -187
- package/dist/react/parse/createInlineUpdates.d.ts +0 -13
- package/dist/react/parse/createInlineUpdates.js +0 -161
- package/dist/react/utils/flattenDictionary.d.ts +0 -20
- package/dist/react/utils/flattenDictionary.js +0 -75
- package/dist/react/utils/getEntryAndMetadata.d.ts +0 -5
- package/dist/react/utils/getEntryAndMetadata.js +0 -11
- package/dist/react/utils/getVariableName.d.ts +0 -25
- package/dist/react/utils/getVariableName.js +0 -37
- package/dist/setup/agentInstructions.d.ts +0 -24
- package/dist/setup/agentInstructions.js +0 -138
- package/dist/setup/detectFramework.d.ts +0 -31
- package/dist/setup/detectFramework.js +0 -106
- package/dist/setup/frameworkUtils.d.ts +0 -3
- package/dist/setup/frameworkUtils.js +0 -30
- package/dist/setup/instructions/base.md +0 -29
- package/dist/setup/instructions/gt-next.md +0 -107
- package/dist/setup/instructions/gt-react.md +0 -98
- package/dist/setup/userInput.d.ts +0 -4
- package/dist/setup/userInput.js +0 -32
- package/dist/setup/wizard.d.ts +0 -3
- package/dist/setup/wizard.js +0 -147
- package/dist/state/recentDownloads.d.ts +0 -12
- package/dist/state/recentDownloads.js +0 -18
- package/dist/state/translateWarnings.d.ts +0 -10
- package/dist/state/translateWarnings.js +0 -13
- package/dist/translation/parse.d.ts +0 -17
- package/dist/translation/parse.js +0 -77
- package/dist/translation/stage.d.ts +0 -3
- package/dist/translation/stage.js +0 -44
- package/dist/translation/validate.d.ts +0 -14
- package/dist/translation/validate.js +0 -100
- package/dist/types/branch.d.ts +0 -14
- package/dist/types/branch.js +0 -1
- package/dist/types/data/json.d.ts +0 -6
- package/dist/types/data/json.js +0 -1
- package/dist/types/data.d.ts +0 -37
- package/dist/types/data.js +0 -1
- package/dist/types/files.d.ts +0 -8
- package/dist/types/files.js +0 -1
- package/dist/types/libraries.d.ts +0 -31
- package/dist/types/libraries.js +0 -72
- package/dist/types/parsing.d.ts +0 -3
- package/dist/types/parsing.js +0 -1
- package/dist/utils/addExplicitAnchorIds.d.ts +0 -24
- package/dist/utils/addExplicitAnchorIds.js +0 -416
- package/dist/utils/constants.d.ts +0 -5
- package/dist/utils/constants.js +0 -6
- package/dist/utils/credentials.d.ts +0 -12
- package/dist/utils/credentials.js +0 -120
- package/dist/utils/flattenJsonFiles.d.ts +0 -2
- package/dist/utils/flattenJsonFiles.js +0 -36
- package/dist/utils/gitDiff.d.ts +0 -8
- package/dist/utils/gitDiff.js +0 -34
- package/dist/utils/gt.d.ts +0 -2
- package/dist/utils/gt.js +0 -2
- package/dist/utils/hash.d.ts +0 -6
- package/dist/utils/hash.js +0 -11
- package/dist/utils/headers.d.ts +0 -1
- package/dist/utils/headers.js +0 -14
- package/dist/utils/localizeRelativeAssets.d.ts +0 -8
- package/dist/utils/localizeRelativeAssets.js +0 -166
- package/dist/utils/localizeStaticImports.d.ts +0 -15
- package/dist/utils/localizeStaticImports.js +0 -397
- package/dist/utils/localizeStaticUrls.d.ts +0 -19
- package/dist/utils/localizeStaticUrls.js +0 -450
- package/dist/utils/mintlifyTitleFallback.d.ts +0 -6
- package/dist/utils/mintlifyTitleFallback.js +0 -80
- package/dist/utils/parse/needsCJS.d.ts +0 -20
- package/dist/utils/parse/needsCJS.js +0 -72
- package/dist/utils/persistPostprocessHashes.d.ts +0 -12
- package/dist/utils/persistPostprocessHashes.js +0 -39
- package/dist/utils/processAnchorIds.d.ts +0 -6
- package/dist/utils/processAnchorIds.js +0 -56
- package/dist/utils/processOpenApi.d.ts +0 -8
- package/dist/utils/processOpenApi.js +0 -651
- package/dist/utils/sanitizeFileContent.d.ts +0 -6
- package/dist/utils/sanitizeFileContent.js +0 -29
- package/dist/utils/sharedStaticAssets.d.ts +0 -9
- package/dist/utils/sharedStaticAssets.js +0 -384
- package/dist/utils/validateMdx.d.ts +0 -10
- package/dist/utils/validateMdx.js +0 -25
- package/dist/utils/wrapPlainUrls.d.ts +0 -8
- package/dist/utils/wrapPlainUrls.js +0 -72
- package/dist/workflows/download.d.ts +0 -32
- package/dist/workflows/download.js +0 -131
- package/dist/workflows/enqueue.d.ts +0 -17
- package/dist/workflows/enqueue.js +0 -59
- package/dist/workflows/setupProject.d.ts +0 -13
- package/dist/workflows/setupProject.js +0 -48
- package/dist/workflows/stage.d.ts +0 -18
- package/dist/workflows/stage.js +0 -59
- package/dist/workflows/steps/BranchStep.d.ts +0 -13
- package/dist/workflows/steps/BranchStep.js +0 -161
- package/dist/workflows/steps/DownloadStep.d.ts +0 -19
- package/dist/workflows/steps/DownloadStep.js +0 -131
- package/dist/workflows/steps/EnqueueStep.d.ts +0 -15
- package/dist/workflows/steps/EnqueueStep.js +0 -33
- package/dist/workflows/steps/PollJobsStep.d.ts +0 -31
- package/dist/workflows/steps/PollJobsStep.js +0 -288
- package/dist/workflows/steps/SetupStep.d.ts +0 -16
- package/dist/workflows/steps/SetupStep.js +0 -72
- package/dist/workflows/steps/UploadSourcesStep.d.ts +0 -27
- package/dist/workflows/steps/UploadSourcesStep.js +0 -131
- package/dist/workflows/steps/UploadTranslationsStep.d.ts +0 -22
- package/dist/workflows/steps/UploadTranslationsStep.js +0 -71
- package/dist/workflows/steps/UserEditDiffsStep.d.ts +0 -11
- package/dist/workflows/steps/UserEditDiffsStep.js +0 -30
- package/dist/workflows/steps/WorkflowStep.d.ts +0 -4
- package/dist/workflows/steps/WorkflowStep.js +0 -2
- package/dist/workflows/upload.d.ts +0 -15
- package/dist/workflows/upload.js +0 -47
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { logErrorAndExit } from '../../console/logging.js';
|
|
2
|
-
const createDuplicateKeyError = (key) => `Duplicate key found in dictionary: "${key}"`;
|
|
3
|
-
/**
|
|
4
|
-
* Flattens a nested dictionary by concatenating nested keys.
|
|
5
|
-
* Throws an error if two keys result in the same flattened key.
|
|
6
|
-
* @param {Record<string, any>} dictionary - The dictionary to flatten.
|
|
7
|
-
* @param {string} [prefix=''] - The prefix for nested keys.
|
|
8
|
-
* @returns {Record<string, React.ReactNode>} The flattened dictionary object.
|
|
9
|
-
* @throws {Error} If two keys result in the same flattened key.
|
|
10
|
-
*/
|
|
11
|
-
export default function flattenDictionary(dictionary, prefix = '') {
|
|
12
|
-
const flattened = {};
|
|
13
|
-
for (const key in dictionary) {
|
|
14
|
-
if (dictionary.hasOwnProperty(key)) {
|
|
15
|
-
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
16
|
-
if (typeof dictionary[key] === 'object' &&
|
|
17
|
-
dictionary[key] !== null &&
|
|
18
|
-
!Array.isArray(dictionary[key])) {
|
|
19
|
-
const nestedFlattened = flattenDictionary(dictionary[key], newKey);
|
|
20
|
-
for (const flatKey in nestedFlattened) {
|
|
21
|
-
if (flattened.hasOwnProperty(flatKey)) {
|
|
22
|
-
logErrorAndExit(createDuplicateKeyError(flatKey));
|
|
23
|
-
}
|
|
24
|
-
flattened[flatKey] = nestedFlattened[flatKey];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
if (flattened.hasOwnProperty(newKey)) {
|
|
29
|
-
logErrorAndExit(createDuplicateKeyError(newKey));
|
|
30
|
-
}
|
|
31
|
-
flattened[newKey] = dictionary[key];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return flattened;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Flattens a nested dictionary containing only string values
|
|
39
|
-
* Throws an error if two keys result in the same flattened key.
|
|
40
|
-
* @param {JSONDictionary} dictionary - The dictionary to flatten.
|
|
41
|
-
* @param {string} [prefix=''] - The prefix for nested keys.
|
|
42
|
-
* @returns {FlattenedJSONDictionary} The flattened dictionary with string values.
|
|
43
|
-
* @throws {Error} If two keys result in the same flattened key.
|
|
44
|
-
* @throws {Error} If a value is an array.
|
|
45
|
-
*/
|
|
46
|
-
export function flattenJsonDictionary(dictionary, prefix = '') {
|
|
47
|
-
const flattened = {};
|
|
48
|
-
for (const key in dictionary) {
|
|
49
|
-
if (dictionary.hasOwnProperty(key)) {
|
|
50
|
-
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
51
|
-
const value = dictionary[key];
|
|
52
|
-
if (Array.isArray(value)) {
|
|
53
|
-
logErrorAndExit(`Arrays are not supported in JSON dictionary at key: "${newKey}"`);
|
|
54
|
-
}
|
|
55
|
-
else if (typeof value === 'object' && value !== null) {
|
|
56
|
-
// Recursively flatten nested objects
|
|
57
|
-
const nestedFlattened = flattenJsonDictionary(value, newKey);
|
|
58
|
-
for (const flatKey in nestedFlattened) {
|
|
59
|
-
if (flattened.hasOwnProperty(flatKey)) {
|
|
60
|
-
logErrorAndExit(createDuplicateKeyError(flatKey));
|
|
61
|
-
}
|
|
62
|
-
flattened[flatKey] = nestedFlattened[flatKey];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else if (typeof value === 'string') {
|
|
66
|
-
// Handle string values
|
|
67
|
-
if (flattened.hasOwnProperty(newKey)) {
|
|
68
|
-
logErrorAndExit(createDuplicateKeyError(newKey));
|
|
69
|
-
}
|
|
70
|
-
flattened[newKey] = value;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return flattened;
|
|
75
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default function getEntryAndMetadata(value) {
|
|
2
|
-
if (Array.isArray(value)) {
|
|
3
|
-
if (value.length === 1) {
|
|
4
|
-
return { entry: value[0] };
|
|
5
|
-
}
|
|
6
|
-
if (value.length === 2) {
|
|
7
|
-
return { entry: value[0], metadata: value[1] };
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return { entry: value };
|
|
11
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { VariableType } from 'generaltranslation/types';
|
|
2
|
-
/**
|
|
3
|
-
* These are the names of the variable components as they appear in gt-next and gt-react
|
|
4
|
-
*/
|
|
5
|
-
export declare const defaultVariableNames: {
|
|
6
|
-
readonly Var: "value";
|
|
7
|
-
readonly Num: "n";
|
|
8
|
-
readonly DateTime: "date";
|
|
9
|
-
readonly Currency: "cost";
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Minify the variable type from the name of the variable component (from gt-next and gt-react)
|
|
13
|
-
* @param variableType - The type of the variable (Var, Num, DateTime, Currency)
|
|
14
|
-
* @returns The minified variable type
|
|
15
|
-
*/
|
|
16
|
-
export declare const minifyVariableType: (variableType: keyof typeof defaultVariableNames) => VariableType;
|
|
17
|
-
export declare const baseVariablePrefix = "_gt_";
|
|
18
|
-
/**
|
|
19
|
-
* Get the name of a variable
|
|
20
|
-
* @param props - The props of the variable
|
|
21
|
-
* @param variableType - The type of the variable (Var, Num, DateTime, Currency)
|
|
22
|
-
* @param id - The id of the variable
|
|
23
|
-
* @returns The name of the variable
|
|
24
|
-
*/
|
|
25
|
-
export declare function getVariableName(props: Record<string, any> | undefined, variableType: keyof typeof defaultVariableNames, id: number): string;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* These are the names of the variable components as they appear in gt-next and gt-react
|
|
3
|
-
*/
|
|
4
|
-
export const defaultVariableNames = {
|
|
5
|
-
Var: 'value',
|
|
6
|
-
Num: 'n',
|
|
7
|
-
DateTime: 'date',
|
|
8
|
-
Currency: 'cost',
|
|
9
|
-
};
|
|
10
|
-
const minifyVariableTypeMap = {
|
|
11
|
-
Var: 'v',
|
|
12
|
-
Num: 'n',
|
|
13
|
-
DateTime: 'd',
|
|
14
|
-
Currency: 'c',
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Minify the variable type from the name of the variable component (from gt-next and gt-react)
|
|
18
|
-
* @param variableType - The type of the variable (Var, Num, DateTime, Currency)
|
|
19
|
-
* @returns The minified variable type
|
|
20
|
-
*/
|
|
21
|
-
export const minifyVariableType = (variableType) => {
|
|
22
|
-
return minifyVariableTypeMap[variableType];
|
|
23
|
-
};
|
|
24
|
-
export const baseVariablePrefix = '_gt_';
|
|
25
|
-
/**
|
|
26
|
-
* Get the name of a variable
|
|
27
|
-
* @param props - The props of the variable
|
|
28
|
-
* @param variableType - The type of the variable (Var, Num, DateTime, Currency)
|
|
29
|
-
* @param id - The id of the variable
|
|
30
|
-
* @returns The name of the variable
|
|
31
|
-
*/
|
|
32
|
-
export function getVariableName(props = {}, variableType, id) {
|
|
33
|
-
if (props.name)
|
|
34
|
-
return props.name;
|
|
35
|
-
const baseVariableName = defaultVariableNames[variableType] || 'value';
|
|
36
|
-
return `${baseVariablePrefix}${baseVariableName}_${id}`;
|
|
37
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SupportedLibraries } from '../types/index.js';
|
|
2
|
-
export declare const CURSOR_GT_RULES_FILE = ".cursor/rules/gt-i18n.mdc";
|
|
3
|
-
/**
|
|
4
|
-
* Detect existing AI agent instruction files in the project.
|
|
5
|
-
*/
|
|
6
|
-
export declare function findAgentFiles(): string[];
|
|
7
|
-
/**
|
|
8
|
-
* Find agent files that already contain GT instructions.
|
|
9
|
-
*/
|
|
10
|
-
export declare function findAgentFilesWithInstructions(): string[];
|
|
11
|
-
/**
|
|
12
|
-
* Check if the .cursor/rules/ directory exists (for offering to create gt-i18n.mdc).
|
|
13
|
-
*/
|
|
14
|
-
export declare function hasCursorRulesDir(): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Generate GT agent instructions content based on the detected library.
|
|
17
|
-
*/
|
|
18
|
-
export declare function getAgentInstructions(library: SupportedLibraries): string;
|
|
19
|
-
/**
|
|
20
|
-
* Append or replace GT instructions in an agent file.
|
|
21
|
-
* Skips writing if the file already contains identical instructions.
|
|
22
|
-
* For .cursor/rules/gt.md, writes the file fresh (dedicated GT rules file).
|
|
23
|
-
*/
|
|
24
|
-
export declare function appendAgentInstructions(filePath: string, instructions: string): boolean;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { getCLIVersion, getPackageVersion } from '../utils/packageJson.js';
|
|
5
|
-
import { Libraries } from '../types/libraries.js';
|
|
6
|
-
const INSTRUCTIONS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), 'instructions');
|
|
7
|
-
const AGENT_FILE_PATHS = [
|
|
8
|
-
'CLAUDE.md',
|
|
9
|
-
'AGENTS.md',
|
|
10
|
-
'GPT.md',
|
|
11
|
-
'CHATGPT.md',
|
|
12
|
-
'.cursorrules',
|
|
13
|
-
];
|
|
14
|
-
const CURSOR_RULES_DIR = '.cursor/rules';
|
|
15
|
-
export const CURSOR_GT_RULES_FILE = '.cursor/rules/gt-i18n.mdc';
|
|
16
|
-
const GT_SECTION_START = '<!-- GT I18N RULES START -->';
|
|
17
|
-
const GT_SECTION_END = '<!-- GT I18N RULES END -->';
|
|
18
|
-
function getLibraryVersion(library) {
|
|
19
|
-
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
20
|
-
if (!fs.existsSync(packageJsonPath))
|
|
21
|
-
return undefined;
|
|
22
|
-
try {
|
|
23
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
24
|
-
return getPackageVersion(library, packageJson);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Detect existing AI agent instruction files in the project.
|
|
32
|
-
*/
|
|
33
|
-
export function findAgentFiles() {
|
|
34
|
-
const cwd = process.cwd();
|
|
35
|
-
const found = [];
|
|
36
|
-
for (const filePath of [...AGENT_FILE_PATHS, CURSOR_GT_RULES_FILE]) {
|
|
37
|
-
const fullPath = path.resolve(cwd, filePath);
|
|
38
|
-
if (fs.existsSync(fullPath)) {
|
|
39
|
-
found.push(filePath);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return found;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Find agent files that already contain GT instructions.
|
|
46
|
-
*/
|
|
47
|
-
export function findAgentFilesWithInstructions() {
|
|
48
|
-
const cwd = process.cwd();
|
|
49
|
-
const found = [];
|
|
50
|
-
for (const filePath of [...AGENT_FILE_PATHS, CURSOR_GT_RULES_FILE]) {
|
|
51
|
-
const fullPath = path.resolve(cwd, filePath);
|
|
52
|
-
if (fs.existsSync(fullPath)) {
|
|
53
|
-
const content = fs.readFileSync(fullPath, 'utf8');
|
|
54
|
-
if (content.includes(GT_SECTION_START)) {
|
|
55
|
-
found.push(filePath);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return found;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Check if the .cursor/rules/ directory exists (for offering to create gt-i18n.mdc).
|
|
63
|
-
*/
|
|
64
|
-
export function hasCursorRulesDir() {
|
|
65
|
-
const cursorRulesDir = path.resolve(process.cwd(), CURSOR_RULES_DIR);
|
|
66
|
-
return (fs.existsSync(cursorRulesDir) && fs.statSync(cursorRulesDir).isDirectory());
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Generate GT agent instructions content based on the detected library.
|
|
70
|
-
*/
|
|
71
|
-
export function getAgentInstructions(library) {
|
|
72
|
-
const libraryVersion = getLibraryVersion(library);
|
|
73
|
-
const versionLine = libraryVersion
|
|
74
|
-
? `- **${library}**: ${libraryVersion}\n- **gtx-cli**: v${getCLIVersion()}`
|
|
75
|
-
: `- **gtx-cli**: v${getCLIVersion()}`;
|
|
76
|
-
const base = fs.readFileSync(path.join(INSTRUCTIONS_DIR, 'base.md'), 'utf8');
|
|
77
|
-
let body = '';
|
|
78
|
-
const libToFile = {
|
|
79
|
-
[Libraries.GT_NEXT]: 'gt-next.md',
|
|
80
|
-
[Libraries.GT_REACT]: 'gt-react.md',
|
|
81
|
-
// TODO: add gt-react-native.md
|
|
82
|
-
[Libraries.GT_REACT_NATIVE]: 'gt-react.md',
|
|
83
|
-
};
|
|
84
|
-
const instructionFile = libToFile[library];
|
|
85
|
-
if (instructionFile) {
|
|
86
|
-
body += '\n\n'; // add two newlines between the base and the specific instructions
|
|
87
|
-
body += fs.readFileSync(path.join(INSTRUCTIONS_DIR, instructionFile), 'utf8');
|
|
88
|
-
}
|
|
89
|
-
return `${GT_SECTION_START}
|
|
90
|
-
|
|
91
|
-
${versionLine}
|
|
92
|
-
|
|
93
|
-
${base}${body}
|
|
94
|
-
${GT_SECTION_END}`;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Append or replace GT instructions in an agent file.
|
|
98
|
-
* Skips writing if the file already contains identical instructions.
|
|
99
|
-
* For .cursor/rules/gt.md, writes the file fresh (dedicated GT rules file).
|
|
100
|
-
*/
|
|
101
|
-
export function appendAgentInstructions(filePath, instructions) {
|
|
102
|
-
const fullPath = path.resolve(process.cwd(), filePath);
|
|
103
|
-
// For .cursor/rules/gt.md, write as a standalone file with frontmatter
|
|
104
|
-
if (filePath === CURSOR_GT_RULES_FILE) {
|
|
105
|
-
const cursorContent = `---\ndescription: GT internationalization instructions\nalwaysApply: true\n---\n${instructions}\n`;
|
|
106
|
-
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
107
|
-
if (fs.existsSync(fullPath)) {
|
|
108
|
-
const existing = fs.readFileSync(fullPath, 'utf8');
|
|
109
|
-
if (existing === cursorContent)
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
fs.writeFileSync(fullPath, cursorContent, 'utf8');
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
// For other files, read existing content and append/replace
|
|
116
|
-
let content = '';
|
|
117
|
-
if (fs.existsSync(fullPath)) {
|
|
118
|
-
content = fs.readFileSync(fullPath, 'utf8');
|
|
119
|
-
}
|
|
120
|
-
// Already has identical instructions — skip
|
|
121
|
-
if (content.includes(instructions))
|
|
122
|
-
return false;
|
|
123
|
-
const startIdx = content.indexOf(GT_SECTION_START);
|
|
124
|
-
const endIdx = startIdx !== -1 ? content.indexOf(GT_SECTION_END, startIdx) : -1;
|
|
125
|
-
if (startIdx !== -1 && endIdx !== -1) {
|
|
126
|
-
// Replace existing section
|
|
127
|
-
const before = content.substring(0, startIdx);
|
|
128
|
-
const after = content.substring(endIdx + GT_SECTION_END.length);
|
|
129
|
-
content = before + instructions + after;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
// Append to end
|
|
133
|
-
const separator = content.length > 0 && !content.endsWith('\n') ? '\n' : '';
|
|
134
|
-
content = content + separator + '\n' + instructions + '\n';
|
|
135
|
-
}
|
|
136
|
-
fs.writeFileSync(fullPath, content, 'utf8');
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { FrameworkObject } from '../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Detects the frontend framework used in the current project.
|
|
4
|
-
*
|
|
5
|
-
* Analyzes the project structure and dependencies to identify the framework.
|
|
6
|
-
* Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → Vite → React.
|
|
7
|
-
*
|
|
8
|
-
* For Next.js projects, further determines whether it uses App Router or Pages Router
|
|
9
|
-
* by checking for the presence of `app/` or `pages/` directories.
|
|
10
|
-
*
|
|
11
|
-
* @returns A promise resolving to a FrameworkObject containing:
|
|
12
|
-
* - `name`: The detected framework identifier (e.g., 'next-app', 'gatsby', 'react')
|
|
13
|
-
* or undefined if no framework is detected
|
|
14
|
-
* - `type`: The framework category (currently only 'react' for React-based frameworks)
|
|
15
|
-
*/
|
|
16
|
-
export declare function detectFramework(): Promise<FrameworkObject | {
|
|
17
|
-
name: undefined;
|
|
18
|
-
type?: undefined;
|
|
19
|
-
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Detects if the current project is a Mintlify documentation project.
|
|
22
|
-
*
|
|
23
|
-
* Checks for the presence of docs.json (preferred) or mint.json (legacy) files.
|
|
24
|
-
* For docs.json, validates that the $schema field contains "mintlify.com/docs.json".
|
|
25
|
-
* Rejects projects with Next.js config files to avoid misclassification.
|
|
26
|
-
*
|
|
27
|
-
* @param _packageJson - The parsed package.json object (not used for Mintlify detection,
|
|
28
|
-
* but kept for API consistency with other detection functions)
|
|
29
|
-
* @returns True if the project is identified as a Mintlify project, false otherwise
|
|
30
|
-
*/
|
|
31
|
-
export declare function isMintlifyProject(_packageJson: Record<string, any> | null): boolean;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { isPackageInstalled } from '../utils/packageJson.js';
|
|
2
|
-
import { searchForPackageJson } from '../utils/packageJson.js';
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
/* ----- MAIN ----- */
|
|
6
|
-
/**
|
|
7
|
-
* Detects the frontend framework used in the current project.
|
|
8
|
-
*
|
|
9
|
-
* Analyzes the project structure and dependencies to identify the framework.
|
|
10
|
-
* Detection order: Mintlify → Next.js (App/Pages Router) → Gatsby → RedwoodJS → Vite → React.
|
|
11
|
-
*
|
|
12
|
-
* For Next.js projects, further determines whether it uses App Router or Pages Router
|
|
13
|
-
* by checking for the presence of `app/` or `pages/` directories.
|
|
14
|
-
*
|
|
15
|
-
* @returns A promise resolving to a FrameworkObject containing:
|
|
16
|
-
* - `name`: The detected framework identifier (e.g., 'next-app', 'gatsby', 'react')
|
|
17
|
-
* or undefined if no framework is detected
|
|
18
|
-
* - `type`: The framework category (currently only 'react' for React-based frameworks)
|
|
19
|
-
*/
|
|
20
|
-
export async function detectFramework() {
|
|
21
|
-
const packageJson = await searchForPackageJson();
|
|
22
|
-
if (isMintlifyProject(packageJson)) {
|
|
23
|
-
return { name: 'mintlify' };
|
|
24
|
-
}
|
|
25
|
-
if (!packageJson) {
|
|
26
|
-
return { name: undefined };
|
|
27
|
-
}
|
|
28
|
-
// Check for Next.js first
|
|
29
|
-
if (isPackageInstalled('next', packageJson, false, true)) {
|
|
30
|
-
// Determine if it's App Router or Pages Router
|
|
31
|
-
const cwd = process.cwd();
|
|
32
|
-
const hasAppDir = fs.existsSync(path.join(cwd, 'app')) ||
|
|
33
|
-
fs.existsSync(path.join(cwd, 'src', 'app'));
|
|
34
|
-
const hasPagesDir = fs.existsSync(path.join(cwd, 'pages')) ||
|
|
35
|
-
fs.existsSync(path.join(cwd, 'src', 'pages'));
|
|
36
|
-
// App Router takes precedence if both exist
|
|
37
|
-
if (hasAppDir) {
|
|
38
|
-
return { name: 'next-app', type: 'react' };
|
|
39
|
-
}
|
|
40
|
-
if (hasPagesDir) {
|
|
41
|
-
return { name: 'next-pages', type: 'react' };
|
|
42
|
-
}
|
|
43
|
-
// Default to app router for new Next.js projects
|
|
44
|
-
return { name: 'next-app', type: 'react' };
|
|
45
|
-
}
|
|
46
|
-
// Check for Gatsby
|
|
47
|
-
if (isPackageInstalled('gatsby', packageJson, false, true)) {
|
|
48
|
-
return { name: 'gatsby', type: 'react' };
|
|
49
|
-
}
|
|
50
|
-
// Check for RedwoodJS
|
|
51
|
-
if (isPackageInstalled('@redwoodjs/core', packageJson, false, true)) {
|
|
52
|
-
return { name: 'redwood', type: 'react' };
|
|
53
|
-
}
|
|
54
|
-
// Check for Vite
|
|
55
|
-
if (isPackageInstalled('vite', packageJson, false, true)) {
|
|
56
|
-
return { name: 'vite', type: 'react' };
|
|
57
|
-
}
|
|
58
|
-
// Check for React (generic)
|
|
59
|
-
if (isPackageInstalled('react', packageJson, false, true)) {
|
|
60
|
-
return { name: 'react', type: 'react' };
|
|
61
|
-
}
|
|
62
|
-
return { name: undefined };
|
|
63
|
-
}
|
|
64
|
-
// ----- HELPER FUNCTIONS ----- //
|
|
65
|
-
/**
|
|
66
|
-
* Detects if the current project is a Mintlify documentation project.
|
|
67
|
-
*
|
|
68
|
-
* Checks for the presence of docs.json (preferred) or mint.json (legacy) files.
|
|
69
|
-
* For docs.json, validates that the $schema field contains "mintlify.com/docs.json".
|
|
70
|
-
* Rejects projects with Next.js config files to avoid misclassification.
|
|
71
|
-
*
|
|
72
|
-
* @param _packageJson - The parsed package.json object (not used for Mintlify detection,
|
|
73
|
-
* but kept for API consistency with other detection functions)
|
|
74
|
-
* @returns True if the project is identified as a Mintlify project, false otherwise
|
|
75
|
-
*/
|
|
76
|
-
export function isMintlifyProject(_packageJson) {
|
|
77
|
-
const cwd = process.cwd();
|
|
78
|
-
// Check for Next.js config files - if present, this is not a Mintlify project
|
|
79
|
-
const nextConfigFiles = [
|
|
80
|
-
'next.config.js',
|
|
81
|
-
'next.config.ts',
|
|
82
|
-
'next.config.mjs',
|
|
83
|
-
'next.config.cjs',
|
|
84
|
-
];
|
|
85
|
-
for (const configFile of nextConfigFiles) {
|
|
86
|
-
if (fs.existsSync(path.join(cwd, configFile))) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Check for docs.json (preferred format)
|
|
91
|
-
const docsJsonPath = path.join(cwd, 'docs.json');
|
|
92
|
-
if (fs.existsSync(docsJsonPath)) {
|
|
93
|
-
try {
|
|
94
|
-
const docsJson = JSON.parse(fs.readFileSync(docsJsonPath, 'utf-8'));
|
|
95
|
-
// Validate the $schema field contains mintlify.com/docs.json
|
|
96
|
-
if (docsJson.$schema &&
|
|
97
|
-
docsJson.$schema.includes('mintlify.com/docs.json')) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Libraries } from '../types/libraries.js';
|
|
2
|
-
export function getFrameworkDisplayName(frameworkObject) {
|
|
3
|
-
if (frameworkObject.name === 'mintlify') {
|
|
4
|
-
return 'Mintlify';
|
|
5
|
-
}
|
|
6
|
-
if (frameworkObject.name === 'next-app') {
|
|
7
|
-
return 'Next.js App Router';
|
|
8
|
-
}
|
|
9
|
-
if (frameworkObject.name === 'next-pages') {
|
|
10
|
-
return 'Next.js Pages Router';
|
|
11
|
-
}
|
|
12
|
-
if (frameworkObject.name === 'vite') {
|
|
13
|
-
return 'Vite + React';
|
|
14
|
-
}
|
|
15
|
-
if (frameworkObject.name === 'gatsby') {
|
|
16
|
-
return 'Gatsby';
|
|
17
|
-
}
|
|
18
|
-
if (frameworkObject.name === 'redwood') {
|
|
19
|
-
return 'RedwoodJS';
|
|
20
|
-
}
|
|
21
|
-
if (frameworkObject.type === 'react') {
|
|
22
|
-
return 'React';
|
|
23
|
-
}
|
|
24
|
-
return 'another framework';
|
|
25
|
-
}
|
|
26
|
-
export function getReactFrameworkLibrary(frameworkObject) {
|
|
27
|
-
return frameworkObject.name === 'next-app'
|
|
28
|
-
? Libraries.GT_NEXT
|
|
29
|
-
: Libraries.GT_REACT;
|
|
30
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# General Translation (GT) Internationalization Rules
|
|
2
|
-
|
|
3
|
-
This project is using [General Translation](https://generaltranslation.com/docs/overview.md) for internationalization (i18n) and translations. General Translation is a developer-first localization stack, built for the world's best engineering teams to ship apps in every language with ease.
|
|
4
|
-
|
|
5
|
-
## Configuration
|
|
6
|
-
|
|
7
|
-
The General Translation configuration file is called `gt.config.json`. It is usually located in the root or src directory of a project.
|
|
8
|
-
|
|
9
|
-
```json
|
|
10
|
-
{
|
|
11
|
-
"defaultLocale": "en",
|
|
12
|
-
"locales": ["es", "fr", "de"],
|
|
13
|
-
"files": {
|
|
14
|
-
"json": {
|
|
15
|
-
"include": ["./**/[locale]/*.json"]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
The API reference for the config file can be found at <https://generaltranslation.com/docs/cli/reference/config.md>.
|
|
22
|
-
|
|
23
|
-
## Translation
|
|
24
|
-
|
|
25
|
-
Run `npx gtx-cli translate` to create translation files for your project. You must have an API key to do this.
|
|
26
|
-
|
|
27
|
-
## Documentation
|
|
28
|
-
|
|
29
|
-
<https://generaltranslation.com/llms.txt>
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# gt-next
|
|
2
|
-
|
|
3
|
-
This project is using the `gt-next` internationalization library for Next.js App Router.
|
|
4
|
-
|
|
5
|
-
## gt-next setup
|
|
6
|
-
|
|
7
|
-
- `GTProvider` must wrap the app in the root layout to provide translation context.
|
|
8
|
-
- The `withGTConfig()` plugin wraps `next.config` in the Next.js config file.
|
|
9
|
-
- (optional) `createNextMiddleware()` is used in `proxy.ts` for automatic locale routing.
|
|
10
|
-
|
|
11
|
-
## Translating JSX
|
|
12
|
-
|
|
13
|
-
`gt-next` uses the `<T>` component for translation.
|
|
14
|
-
|
|
15
|
-
Pass JSX content as the direct children of `<T>` to translate it. Children of `<T>` must be static — no JS expressions or variables directly inside.
|
|
16
|
-
|
|
17
|
-
```jsx
|
|
18
|
-
import { T } from 'gt-next';
|
|
19
|
-
|
|
20
|
-
<T>
|
|
21
|
-
<h1>Welcome to our store</h1>
|
|
22
|
-
<p>
|
|
23
|
-
Browse our <a href='/products'>latest products</a> and find something you
|
|
24
|
-
love.
|
|
25
|
-
</p>
|
|
26
|
-
</T>;
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
You can also add a `context` prop to `<T>` to give context to the translator. For example:
|
|
30
|
-
|
|
31
|
-
```jsx
|
|
32
|
-
import { T } from 'gt-next';
|
|
33
|
-
|
|
34
|
-
<T context="Cookies as in web cookies">
|
|
35
|
-
View your <a href="/cookies">Cookies</a>
|
|
36
|
-
</T>;
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Translating simple strings
|
|
40
|
-
|
|
41
|
-
Use the `gt` function returned by the `useGT()` hook to translate strings directly. Invoke `useGT()` in synchronous components or `await getGT()` in async components only.
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
import { useGT } from 'gt-next';
|
|
45
|
-
const gt = useGT();
|
|
46
|
-
gt('Hello, world!'); // returns "Hola, mundo"
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
```js
|
|
50
|
-
import { getGT } from 'gt-next/server';
|
|
51
|
-
const gt = await getGT(); // use await version in async components only
|
|
52
|
-
gt('Hello, world!');
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
- Just like with the children of the `<T>` component, all strings passed to `gt()` must be static string literals. No variables or template literals.
|
|
56
|
-
|
|
57
|
-
## Translating shared or out-of-scope strings
|
|
58
|
-
|
|
59
|
-
Use `msg()` to register strings for translation, and `useMessages()` to translate them. `const m = useMessages()` should be used equivalently to `const gt = useGT()`.
|
|
60
|
-
|
|
61
|
-
```js
|
|
62
|
-
import { msg, useMessages } from 'gt-next';
|
|
63
|
-
|
|
64
|
-
const greeting = msg('Hello, world!');
|
|
65
|
-
|
|
66
|
-
export default function Greeting() {
|
|
67
|
-
const m = useMessages();
|
|
68
|
-
return <p>{m(greeting)}</p>;
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
- All strings passed to `msg()` must be static string literals. No variables or template literals.
|
|
73
|
-
- Use the equivalent `await getMessages()` for async components.
|
|
74
|
-
- `useMessages()` / `getMessages()` take no arguments.
|
|
75
|
-
|
|
76
|
-
## Dynamic content inside `<T>`
|
|
77
|
-
|
|
78
|
-
Use variable components for dynamic values inside `<T>`:
|
|
79
|
-
|
|
80
|
-
- `<Var>{value}</Var>` — variables (strings, numbers, etc.)
|
|
81
|
-
- `<Num>{value}</Num>` — formatted numbers
|
|
82
|
-
- `<Currency>{value}</Currency>` — formatted currency
|
|
83
|
-
- `<DateTime>{value}</DateTime>` — formatted dates/times
|
|
84
|
-
|
|
85
|
-
```jsx
|
|
86
|
-
import { T, Var, Num } from 'gt-next';
|
|
87
|
-
|
|
88
|
-
<T>
|
|
89
|
-
<Var>{userName}</Var> ordered <Num>{itemCount}</Num> items.
|
|
90
|
-
</T>;
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Utility hooks
|
|
94
|
-
|
|
95
|
-
### `useLocale()`
|
|
96
|
-
|
|
97
|
-
`useLocale` returns the user's current language, as a BCP 47 locale tag.
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
import { useLocale } from 'gt-next'
|
|
101
|
-
|
|
102
|
-
const locale = useLocale(); // "en-US"
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Quickstart
|
|
106
|
-
|
|
107
|
-
See <https://generaltranslation.com/docs/next.md>
|