From 379e58ab66aa8aa61252581d015faa946fd75847 Mon Sep 17 00:00:00 2001 From: Ionut Pasca Date: Mon, 18 Nov 2024 15:21:51 +0200 Subject: [PATCH] Fix NextJS project generation, if no internationalization is used --- .../src/internationalization/locale-mapper-component.ts | 3 ++- packages/teleport-project-generator-next/src/utils.ts | 7 +------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts b/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts index 641c3baa9..56284519f 100644 --- a/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts +++ b/packages/teleport-project-generator-next/src/internationalization/locale-mapper-component.ts @@ -86,6 +86,8 @@ export const createNextInternationalizationPlugin: ComponentPluginFactory<{}> = } const reactHooks: types.VariableDeclaration[] = [] + structure.dependencies.useTranslations = USE_TRANSLATIONS_HOOK + if (jsxComponent.meta?.localeReferences?.length > 0 && !useTranslationsInBody) { const translationsAST = types.variableDeclaration('const', [ types.variableDeclarator( @@ -94,7 +96,6 @@ export const createNextInternationalizationPlugin: ComponentPluginFactory<{}> = ), ]) reactHooks.push(translationsAST) - structure.dependencies.useTranslations = USE_TRANSLATIONS_HOOK useTranslationsInBody = true } diff --git a/packages/teleport-project-generator-next/src/utils.ts b/packages/teleport-project-generator-next/src/utils.ts index 9a6cdeb85..0cbe38788 100644 --- a/packages/teleport-project-generator-next/src/utils.ts +++ b/packages/teleport-project-generator-next/src/utils.ts @@ -11,7 +11,7 @@ import { } from '@teleporthq/teleport-types' export const createDocumentFileChunks = (uidl: ProjectUIDL, options: EntryFileOptions) => { - const { settings, meta, assets, manifest, customCode } = uidl.globals + const { meta, assets, manifest, customCode } = uidl.globals const htmlNode = ASTBuilders.createJSXTag('Html') const headNode = ASTBuilders.createJSXTag('Head') @@ -25,12 +25,7 @@ export const createDocumentFileChunks = (uidl: ProjectUIDL, options: EntryFileOp ASTUtils.addChildJSXTag(htmlNode, headNode) ASTUtils.addChildJSXTag(htmlNode, bodyNode) - if (settings.language) { - ASTUtils.addAttributeToJSXTag(htmlNode, 'lang', settings.language) - } - // NOTE: Title is added in per page, not in the layout file - if (manifest) { const linkTag = ASTBuilders.createJSXTag('link') ASTUtils.addAttributeToJSXTag(linkTag, 'rel', 'manifest')