chapter-three / next-drupal

Next.js for Drupal has everything you need to build a next-generation front-end for your Drupal site: SSG, SSR, and ISR, Multi-site, Authentication, Webforms, Search API, I18n and Preview mode (works with JSON:API and GraphQL).
https://next-drupal.org
MIT License
639 stars 178 forks source link

Error: Initial locale argument was not passed into serverSideTranslations #248

Closed septembre2018 closed 2 years ago

septembre2018 commented 2 years ago

Hello,

I'm trying to test the new example-umami out of the box. While I'm trying to access to a node i'll get the error : Initial locale argument was not passed into serverSideTranslations

Errors logs : error - Error: Initial locale argument was not passed into serverSideTranslations at _callee$ (/Users/septembre/Documents/GitHub/japi/test-umami/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:172:19) at tryCatch (/Users/septembre/Documents/GitHub/japi/test-umami/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:86:17) at Generator._invoke (/Users/septembre/Documents/GitHub/japi/test-umami/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:66:24) at Generator.next (/Users/septembre/Documents/GitHub/japi/test-umami/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:117:21) at asyncGeneratorStep (/Users/septembre/Documents/GitHub/japi/test-umami/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24) at _next (/Users/septembre/Documents/GitHub/japi/test-umami/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9) at /Users/septembre/Documents/GitHub/japi/test-umami/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7 at new Promise (<anonymous>) at /Users/septembre/Documents/GitHub/japi/test-umami/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12 at serverSideTranslations (/Users/septembre/Documents/GitHub/japi/test-umami/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:272:17) { page: '/[...slug]' }

I don't think it is an auth issue because all the pages works correctly except nodes. Not sure if it come from my drupal config or something in the local dev version of example-umami. Drupal instance Drupal : 9.4.1 Php : 8.1

Next-drupal "next": "^12.1.4", "next-auth": "^4.3.4", "next-drupal": "^1.4.0", "next-i18next": "^11.0.0",

Next.config is the same as github :

const { i18n } = require("./next-i18next.config")

module.exports = {
  i18n,
  images: {
    domains: [process.env.NEXT_IMAGE_DOMAIN],
  },
}

next-i18next.config.js is the same as github

const path = require("path")

const config = require("./site.config")

module.exports = {
  i18n: {
    defaultLocale: config.defaultLocale,
    locales: Object.keys(config.locales),
    localePath: path.resolve("./public/locales"),
  },
}

Would appreciate it if someone have a clue for this

shadcn commented 2 years ago

@septembre2018 quick question. Are you following the guide at https://gist.github.com/shadcn/23d2cff86eb68836774f877a3ecc88a3?

septembre2018 commented 2 years ago

no, I've tried with my server where I've install a drupal instance as I did with starter kit. I'll try with the guide

septembre2018 commented 2 years ago

HI, I've strictly follow the guide and I still have the same error and I don't know where to investigate...

shadcn commented 2 years ago

OK this might sound like an easy fix but I just had this error as well and clearing the cache on the Drupal site fixed it. Can you give it a try?

septembre2018 commented 2 years ago

Clearing cache didn't change the situation. I've "reset" the local permission on the dev folder and it finally work... Thank you for patience.

ranx2k commented 2 years ago

Hello

I'm getting the exact same error with my Umami installation - error : Initial locale argument was not passed into serverSideTranslations

I have followed the install guide to the letter. I also have cleared the caches several times. Everything seems to be working but when I click on any node, the error pops up.

@septembre2018 could you please tell me in more detail which permissions were to blame?

septembre2018 commented 2 years ago

Hi, As I remember, it was due to a misconfiguration on the Drupal Instance. It was a mix of permissions on server side folders incorrectly sets (because the umami db is inside a file) and the language recognition settings of drupal.

ranx2k commented 2 years ago

Thank you for a quick answer. I deleted everything and started from scratch. Everything is working now.

I think that for some reason the required Drupal patches in composer.json failed to apply. That was probably the reason for the error for me.

RobinHoutevelts commented 1 year ago

I also can't seem to trigger the patches

Composer version 2.5.4 2023-02-15 13:10:06
PHP 8.1.16 (cli) (built: Feb 16 2023 07:22:21) (NTS)
composer.json ```json { "name": "drupal/recommended-project", "description": "Project template for Drupal projects with a relocated document root", "type": "project", "license": "GPL-2.0-or-later", "homepage": "https://www.drupal.org/project/drupal", "support": { "docs": "https://www.drupal.org/docs/user_guide/en/index.html", "chat": "https://www.drupal.org/node/314178" }, "repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8" } ], "require": { "composer-runtime-api": "^2.0.0", "composer/installers": "^2.0", "cweagans/composer-patches": "^1.7", "drupal/core-composer-scaffold": "^10.0", "drupal/core-project-message": "^10.0", "drupal/core-recommended": "^10.0", "drupal/dotenv": "^1.2", "drupal/jsonapi_menu_items": "^1.2", "drupal/jsonapi_resources": "^1.0@beta", "drupal/jsonapi_views": "^1.1", "drupal/next": "^1.6", "drush/drush": "^11.5" }, "conflict": { "drupal/drupal": "*" }, "minimum-stability": "stable", "prefer-stable": true, "config": { "discard-changes": true, "platform": { "php": "8.1.16" }, "sort-packages": true, "allow-plugins": { "ergebnis/composer-normalize": true, "composer/installers": true, "cweagans/composer-patches": true, "composer/package-versions-deprecated": true, "drupal/core-composer-scaffold": true, "oomphinc/composer-installers-extender": true, "drupal-composer/drupal-scaffold": true, "drupal/core-project-message": false } }, "extra": { "drupal-scaffold": { "locations": { "web-root": "public/" } }, "installer-paths": { "public/core": [ "type:drupal-core" ], "public/libraries/{$name}": [ "type:drupal-library" ], "public/modules/contrib/{$name}": [ "type:drupal-module" ], "public/profiles/contrib/{$name}": [ "type:drupal-profile" ], "public/themes/contrib/{$name}": [ "type:drupal-theme" ], "drush/Commands/contrib/{$name}": [ "type:drupal-drush" ], "public/modules/custom/{$name}": [ "type:drupal-custom-module" ], "public/profiles/custom/{$name}": [ "type:drupal-custom-profile" ], "public/themes/custom/{$name}": [ "type:drupal-custom-theme" ] }, "extra": { "composer-exit-on-patch-failure": true, "patches": { "drupal/subrequests": { "Get same results on different request": "https://www.drupal.org/files/issues/2019-07-18/change_request_type-63049395-09.patch" }, "drupal/decoupled_router": { "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2021-05-05/3111456-34.patch" } } } } } ```
composer install ``` ▶ composer install No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information. Loading composer repositories with package information Info from https://repo.packagist.org: #StandWithUkraine Updating dependencies Lock file operations: 104 installs, 0 updates, 0 removals - Locking asm89/stack-cors (v2.1.1) - Locking chi-teck/drupal-code-generator (2.6.2) - Locking composer/installers (v2.2.0) - Locking composer/semver (3.3.2) - Locking consolidation/annotated-command (4.7.1) - Locking consolidation/config (2.1.2) - Locking consolidation/filter-via-dot-access-data (2.0.2) - Locking consolidation/log (3.0.0) - Locking consolidation/output-formatters (4.2.3) - Locking consolidation/robo (4.0.3) - Locking consolidation/self-update (2.1.0) - Locking consolidation/site-alias (4.0.0) - Locking consolidation/site-process (5.2.0) - Locking cweagans/composer-patches (1.7.3) - Locking defuse/php-encryption (v2.3.1) - Locking dflydev/dot-access-data (v3.0.2) - Locking doctrine/annotations (1.13.3) - Locking doctrine/lexer (1.2.3) - Locking drupal/consumers (1.16.0) - Locking drupal/core (10.0.3) - Locking drupal/core-composer-scaffold (10.0.3) - Locking drupal/core-project-message (10.0.3) - Locking drupal/core-recommended (10.0.3) - Locking drupal/ctools (4.0.3) - Locking drupal/decoupled_router (2.0.4) - Locking drupal/dotenv (1.2.0) - Locking drupal/jsonapi_menu_items (1.2.4) - Locking drupal/jsonapi_resources (1.0.0-beta5) - Locking drupal/jsonapi_views (1.1.0) - Locking drupal/next (1.6.2) - Locking drupal/pathauto (1.11.0) - Locking drupal/simple_oauth (5.2.3) - Locking drupal/subrequests (3.0.6) - Locking drupal/token (1.11.0) - Locking drush/drush (11.5.1) - Locking egulias/email-validator (3.2.5) - Locking enlightn/security-checker (v1.10.0) - Locking galbar/jsonpath (1.3.1) - Locking grasmash/expander (3.0.0) - Locking guzzlehttp/guzzle (7.5.0) - Locking guzzlehttp/promises (1.5.2) - Locking guzzlehttp/psr7 (2.4.3) - Locking lcobucci/clock (3.0.0) - Locking lcobucci/jwt (4.3.0) - Locking league/container (4.2.0) - Locking league/event (2.2.0) - Locking league/oauth2-server (8.4.0) - Locking league/uri (6.8.0) - Locking league/uri-interfaces (2.3.0) - Locking masterminds/html5 (2.7.6) - Locking nikic/php-parser (v4.15.3) - Locking paragonie/random_compat (v9.99.100) - Locking pear/archive_tar (1.4.14) - Locking pear/console_getopt (v1.4.3) - Locking pear/pear-core-minimal (v1.10.11) - Locking pear/pear_exception (v1.0.2) - Locking phootwork/collection (v3.2.1) - Locking phootwork/lang (v3.2.1) - Locking phpowermove/docblock (v4.0) - Locking psr/cache (3.0.0) - Locking psr/clock (1.0.0) - Locking psr/container (2.0.2) - Locking psr/event-dispatcher (1.0.0) - Locking psr/http-client (1.0.1) - Locking psr/http-factory (1.0.1) - Locking psr/http-message (1.0.1) - Locking psr/log (3.0.0) - Locking psy/psysh (v0.11.12) - Locking ralouphie/getallheaders (3.0.3) - Locking steverhoades/oauth2-openid-connect-server (v2.5.0) - Locking symfony/console (v6.2.5) - Locking symfony/dependency-injection (v6.2.6) - Locking symfony/deprecation-contracts (v3.2.0) - Locking symfony/dotenv (v6.2.5) - Locking symfony/error-handler (v6.2.5) - Locking symfony/event-dispatcher (v6.2.5) - Locking symfony/event-dispatcher-contracts (v3.2.0) - Locking symfony/filesystem (v6.2.5) - Locking symfony/finder (v6.2.5) - Locking symfony/http-foundation (v6.2.6) - Locking symfony/http-kernel (v6.2.6) - Locking symfony/mime (v6.2.5) - Locking symfony/polyfill-ctype (v1.27.0) - Locking symfony/polyfill-iconv (v1.27.0) - Locking symfony/polyfill-intl-grapheme (v1.27.0) - Locking symfony/polyfill-intl-idn (v1.27.0) - Locking symfony/polyfill-intl-normalizer (v1.27.0) - Locking symfony/polyfill-mbstring (v1.27.0) - Locking symfony/polyfill-php72 (v1.27.0) - Locking symfony/polyfill-php80 (v1.27.0) - Locking symfony/polyfill-php81 (v1.27.0) - Locking symfony/process (v6.2.5) - Locking symfony/psr-http-message-bridge (v2.1.4) - Locking symfony/routing (v6.2.5) - Locking symfony/serializer (v6.2.5) - Locking symfony/service-contracts (v3.2.0) - Locking symfony/string (v6.2.5) - Locking symfony/translation-contracts (v3.2.0) - Locking symfony/validator (v6.2.5) - Locking symfony/var-dumper (v6.2.5) - Locking symfony/var-exporter (v6.2.5) - Locking symfony/yaml (v6.2.5) - Locking twig/twig (v3.5.1) - Locking webflo/drupal-finder (1.2.2) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 104 installs, 0 updates, 0 removals - Installing composer/installers (v2.2.0): Extracting archive - Installing drupal/core-composer-scaffold (10.0.3): Extracting archive - Installing drupal/core-project-message (10.0.3): Extracting archive - Installing cweagans/composer-patches (1.7.3): Extracting archive - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.27.0): Extracting archive - Installing symfony/polyfill-intl-grapheme (v1.27.0): Extracting archive - Installing symfony/polyfill-ctype (v1.27.0): Extracting archive - Installing symfony/string (v6.2.5): Extracting archive - Installing psr/container (2.0.2): Extracting archive - Installing symfony/service-contracts (v3.2.0): Extracting archive - Installing symfony/deprecation-contracts (v3.2.0): Extracting archive - Installing symfony/console (v6.2.5): Extracting archive - Installing psr/log (3.0.0): Extracting archive - Installing consolidation/log (3.0.0): Extracting archive - Installing symfony/finder (v6.2.5): Extracting archive - Installing dflydev/dot-access-data (v3.0.2): Extracting archive - Installing consolidation/output-formatters (4.2.3): Extracting archive - Installing symfony/filesystem (v6.2.5): Extracting archive - Installing composer/semver (3.3.2): Extracting archive - Installing consolidation/self-update (2.1.0): Extracting archive - Installing paragonie/random_compat (v9.99.100): Extracting archive - Installing defuse/php-encryption (v2.3.1): Extracting archive - Installing twig/twig (v3.5.1): Extracting archive - Installing symfony/yaml (v6.2.5): Extracting archive - Installing symfony/var-exporter (v6.2.5): Extracting archive - Installing symfony/var-dumper (v6.2.5): Extracting archive - Installing symfony/translation-contracts (v3.2.0): Extracting archive - Installing symfony/validator (v6.2.5): Extracting archive - Installing symfony/serializer (v6.2.5): Extracting archive - Installing symfony/routing (v6.2.5): Extracting archive - Installing symfony/http-foundation (v6.2.6): Extracting archive - Installing psr/http-message (1.0.1): Extracting archive - Installing symfony/psr-http-message-bridge (v2.1.4): Extracting archive - Installing symfony/process (v6.2.5): Extracting archive - Installing symfony/polyfill-php72 (v1.27.0): Extracting archive - Installing symfony/polyfill-intl-idn (v1.27.0): Extracting archive - Installing symfony/polyfill-iconv (v1.27.0): Extracting archive - Installing symfony/mime (v6.2.5): Extracting archive - Installing psr/event-dispatcher (1.0.0): Extracting archive - Installing symfony/event-dispatcher-contracts (v3.2.0): Extracting archive - Installing symfony/event-dispatcher (v6.2.5): Extracting archive - Installing symfony/error-handler (v6.2.5): Extracting archive - Installing symfony/http-kernel (v6.2.6): Extracting archive - Installing symfony/dependency-injection (v6.2.6): Extracting archive - Installing ralouphie/getallheaders (3.0.3): Extracting archive - Installing psr/http-factory (1.0.1): Extracting archive - Installing psr/http-client (1.0.1): Extracting archive - Installing psr/cache (3.0.0): Extracting archive - Installing pear/pear_exception (v1.0.2): Extracting archive - Installing pear/console_getopt (v1.4.3): Extracting archive - Installing pear/pear-core-minimal (v1.10.11): Extracting archive - Installing pear/archive_tar (1.4.14): Extracting archive - Installing masterminds/html5 (2.7.6): Extracting archive - Installing guzzlehttp/psr7 (2.4.3): Extracting archive - Installing guzzlehttp/promises (1.5.2): Extracting archive - Installing guzzlehttp/guzzle (7.5.0): Extracting archive - Installing doctrine/lexer (1.2.3): Extracting archive - Installing egulias/email-validator (3.2.5): Extracting archive - Installing doctrine/annotations (1.13.3): Extracting archive - Installing asm89/stack-cors (v2.1.1): Extracting archive - Installing drupal/core (10.0.3): Extracting archive - Installing drupal/core-recommended (10.0.3) - Installing symfony/dotenv (v6.2.5): Extracting archive - Installing drupal/dotenv (1.2.0): Extracting archive - Installing drupal/jsonapi_resources (1.0.0-beta5): Extracting archive - Installing drupal/jsonapi_menu_items (1.2.4): Extracting archive - Installing drupal/jsonapi_views (1.1.0): Extracting archive - Installing galbar/jsonpath (1.3.1): Extracting archive - Installing drupal/subrequests (3.0.6): Extracting archive - Installing league/uri-interfaces (2.3.0): Extracting archive - Installing league/uri (6.8.0): Extracting archive - Installing league/event (2.2.0): Extracting archive - Installing psr/clock (1.0.0): Extracting archive - Installing lcobucci/clock (3.0.0): Extracting archive - Installing lcobucci/jwt (4.3.0): Extracting archive - Installing league/oauth2-server (8.4.0): Extracting archive - Installing steverhoades/oauth2-openid-connect-server (v2.5.0): Extracting archive - Installing drupal/consumers (1.16.0): Extracting archive - Installing drupal/simple_oauth (5.2.3): Extracting archive - Installing drupal/token (1.11.0): Extracting archive - Installing drupal/ctools (4.0.3): Extracting archive - Installing drupal/pathauto (1.11.0): Extracting archive - Installing drupal/decoupled_router (2.0.4): Extracting archive - Installing drupal/next (1.6.2): Extracting archive - Installing webflo/drupal-finder (1.2.2): Extracting archive - Installing symfony/polyfill-php80 (v1.27.0): Extracting archive - Installing nikic/php-parser (v4.15.3): Extracting archive - Installing psy/psysh (v0.11.12): Extracting archive - Installing league/container (4.2.0): Extracting archive - Installing enlightn/security-checker (v1.10.0): Extracting archive - Installing grasmash/expander (3.0.0): Extracting archive - Installing consolidation/config (2.1.2): Extracting archive - Installing consolidation/site-alias (4.0.0): Extracting archive - Installing consolidation/site-process (5.2.0): Extracting archive - Installing symfony/polyfill-php81 (v1.27.0): Extracting archive - Installing phootwork/lang (v3.2.1): Extracting archive - Installing phootwork/collection (v3.2.1): Extracting archive - Installing phpowermove/docblock (v4.0): Extracting archive - Installing consolidation/annotated-command (4.7.1): Extracting archive - Installing consolidation/robo (4.0.3): Extracting archive - Installing consolidation/filter-via-dot-access-data (2.0.2): Extracting archive - Installing chi-teck/drupal-code-generator (2.6.2): Extracting archive - Installing drush/drush (11.5.1): Extracting archive 30 package suggestions were added by new dependencies, use `composer suggest` to see details. Generating autoload files 48 packages you are using are looking for funding. Use the `composer fund` command to find out more! Scaffolding files for drupal/core: - Copy [project-root]/.editorconfig from assets/scaffold/files/editorconfig - Copy [project-root]/.gitattributes from assets/scaffold/files/gitattributes - Copy [web-root]/.csslintrc from assets/scaffold/files/csslintrc - Copy [web-root]/.eslintignore from assets/scaffold/files/eslintignore - Copy [web-root]/.eslintrc.json from assets/scaffold/files/eslintrc.json - Copy [web-root]/.ht.router.php from assets/scaffold/files/ht.router.php - Copy [web-root]/.htaccess from assets/scaffold/files/htaccess - Copy [web-root]/example.gitignore from assets/scaffold/files/example.gitignore - Copy [web-root]/index.php from assets/scaffold/files/index.php - Copy [web-root]/INSTALL.txt from assets/scaffold/files/drupal.INSTALL.txt - Copy [web-root]/README.md from assets/scaffold/files/drupal.README.md - Copy [web-root]/robots.txt from assets/scaffold/files/robots.txt - Copy [web-root]/update.php from assets/scaffold/files/update.php - Copy [web-root]/web.config from assets/scaffold/files/web.config - Copy [web-root]/sites/README.txt from assets/scaffold/files/sites.README.txt - Copy [web-root]/sites/development.services.yml from assets/scaffold/files/development.services.yml - Copy [web-root]/sites/example.settings.local.php from assets/scaffold/files/example.settings.local.php - Copy [web-root]/sites/example.sites.php from assets/scaffold/files/example.sites.php - Copy [web-root]/sites/default/default.services.yml from assets/scaffold/files/default.services.yml - Copy [web-root]/sites/default/default.settings.php from assets/scaffold/files/default.settings.php - Copy [web-root]/modules/README.txt from assets/scaffold/files/modules.README.txt - Copy [web-root]/profiles/README.txt from assets/scaffold/files/profiles.README.txt - Copy [web-root]/themes/README.txt from assets/scaffold/files/themes.README.txt ```

Edit: 🙈 I placed my patches in the wrong object.