aralroca / next-translate-plugin

Next-translate plugin for i18n in Next.js 🌍 - Load page translations and use them in an easy way!
MIT License
30 stars 17 forks source link

Configuration option to customize the pkgDir #49

Open myabeaver opened 1 year ago

myabeaver commented 1 year ago

What version of this package are you using?

What problem do you want to solve?

We use Nx to run our monorepo. Nx has made an adjustment in version 16.3.2 that causes the current working directory to dynamically adjust depending on the project. We are therefore forced to adjust thepkgDir (used to create the basePath) to '.' respectively the current working directory (process.cwd()).

What do you think is the correct solution to this problem?

Add a configuration option to NextConfig, such as nextTranslate. such as:

interface NextConfigWithNextTranslate extends NextConfig {
    nextTranslate?: {
        pkgDir?: string | (() => string);
    }
}

Are you willing to submit a pull request to implement this change?

Yes

aralroca commented 1 year ago

We added a env variable for this https://github.com/aralroca/next-translate#13-how-to-use-next-translate-in-a-mono-repo

It should work

myabeaver commented 1 year ago

@aralroca This is not suitable for our use case since it does not fallback to process.cwd() (require('pkg-dir')) gets resolved.

aralroca commented 1 year ago

@myasteiner feel free to PR 👌

myabeaver commented 1 year ago

@aralroca I've created two PR's:

@aralroca Thank you for your time