Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #91
Changes and Fixes for Next Translate Turbopack Support
This document summarizes the changes made to the
next-translate-pluginto resolve translation issues and crashes when using Next.js with Turbopack, specifically addressing thebasic,complex, andwithout-loaderexamples.Key Fixes
1. Absolute Path Correction in
index.tsFixed a bug in the plugin's entry point where an absolute path to the
_appfile was being incorrectly concatenated with thebasePath, resulting in aMODULE_NOT_FOUNDerror during the file parsing stage.parseFilecall to usepath.relative(basePath, path.join(pagesPath, app)).2. Turbopack Compatibility for
loadLocaleFromResolved the "Cannot find module as expression is too dynamic" error that occurred when Turbopack encountered the plugin's default
import()template for loading locales.index.tsto detect if the user'si18n.jsconfiguration includes a customloadLocaleFromfunction.hasLoadLocaleFromboolean flag passed from the plugin options to the loader and subsequently to all template generators (templateWithHoc,templateWithLoader,templateAppDir).addLoadLocalesFrominutils.tsto return an emptyloadLocaleFromdefinition if the user provides their own, preventing the injection of the problematic dynamic import template.3. Server-Side Config Access for
getTandloadNamespacesFixed an issue where server-side functions like
getServerSidePropsandgetStaticPropscouldn't access the i18n configuration, causing translation failures in the Pages router.templateWithLoader.tsto explicitly setglobal.i18nConfigbefore executing the original page loader.getTandloadNamespacescan retrieve the configuration even when running in the server environment without a request context.4. Build Process and Parameter Robustness
build-packages.jsto usepath.join(__dirname, ...)for all filesystem operations, making the build process more robust across different working directories and monorepo structures.loader.tsto correctly pass thehasLoadLocaleFromflag to thegetDefaultAppJsutility, ensuring the generated_appwrapper respects the custom loader configuration.Verified Examples
/en/more-examples/dynamicroute/example) now correctly load translations viagetServerSidePropswithout crashing.loadNamespacescalls behave as expected without interfering with the plugin's transformation logic.