Skip to content

Conversation

@triklozoid
Copy link
Collaborator

@triklozoid triklozoid commented Aug 3, 2025

Описание общей логики: https://github.com/dtpstat/dtp-project/wiki/%D0%9B%D0%BE%D0%BA%D0%B0%D0%BB%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F

Summary by CodeRabbit

  • New Features

    • Added multilingual support for Russian and English throughout the application.
    • Introduced English and Russian translations for common interface elements.
    • Enabled dynamic language switching for filter panel and map iframe page.
  • Chores

    • Updated and added dependencies for internationalization support.
    • Configured localization settings for seamless integration with Next.js.

@netlify
Copy link

netlify bot commented Aug 3, 2025

Deploy Preview for dtp-stat ready!

Name Link
🔨 Latest commit 03877b9
🔍 Latest deploy log https://app.netlify.com/projects/dtp-stat/deploys/688fdb6280295f00086c1e64
😎 Deploy Preview https://deploy-preview-122--dtp-stat.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Aug 3, 2025

Walkthrough

Internationalization (i18n) support is introduced and configured for a Next.js application. The changes add i18n configuration files, update dependencies to include i18n libraries, provide English and Russian translation resources, and refactor UI components and pages to use translation hooks and server-side translation loading. The application is now set up for multilingual support.

Changes

Cohort / File(s) Change Summary
i18n Configuration
next-i18next.config.js, next.config.mjs
Added and configured i18n settings: default locale set to Russian ("ru"), English ("en") as additional locale, disabled automatic locale detection, and customized locale cookie settings for compatibility with Django.
Localization Resources
public/locales/en/common.json, public/locales/ru/common.json
Added English and Russian translation JSON files with key-value pairs for common UI strings.
i18n Dependencies
package.json
Updated Prisma dependencies to "latest" and added i18next, next-i18next, and react-i18next for internationalization support.
App-wide i18n Integration
src/pages/_app.tsx
Wrapped the main App export with appWithTranslation to enable translation support throughout the application.
Component-level i18n Usage
src/components/inherited-map/components/filter-panel/filter-panel-normal.js
Replaced hardcoded Russian strings with translation keys using useTranslation from next-i18next.
Page-level i18n Integration
src/pages/iframes/map.tsx
Added useTranslation for UI strings and implemented getServerSideProps to load translations server-side for the "common" namespace.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant NextJS_Server
    participant i18n_Library
    participant Translation_Files

    User->>Browser: Request page (with locale)
    Browser->>NextJS_Server: HTTP request (locale info)
    NextJS_Server->>i18n_Library: Load translations for locale
    i18n_Library->>Translation_Files: Fetch translation JSON
    Translation_Files-->>i18n_Library: Return translations
    i18n_Library-->>NextJS_Server: Provide translations
    NextJS_Server->>Browser: Rendered page with localized strings
    Browser->>User: Display localized UI
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch localization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (4)
next-i18next.config.js (1)

1-6: Consider adding fallback & detection flags explicitly
Adding fallbackLng: "ru" and localeDetection: false prevents runtime warnings and unwanted redirects when a user’s browser provides an unsupported locale.

   i18n: {
     defaultLocale: "ru",
     locales: ["ru", "en"],
+    fallbackLng: "ru",
+    localeDetection: false,
   },
public/locales/ru/common.json (1)

2-6: Minor: keep key order identical across locale files
Maintaining identical ordering eases diffing and spotting missing keys. Consider sorting both en and ru files alphabetically.

src/pages/iframes/map.tsx (2)

4-5: Remove unused i18n import / variable

useTranslation is imported and const { t } = useTranslation("common"); is declared, but t is never referenced afterwards.
This will survive build-time lint suppression but is still dead code and a tiny chunk of unnecessary client bundle.

-import { useTranslation } from "next-i18next";
 ...
-  const { t } = useTranslation("common");

Also applies to: 18-18


35-41: Type the getServerSideProps context correctly for future safety

The param is declared as a plain object { locale: string }, but Next.js already provides a typed context: GetServerSidePropsContext.
Switching to the official type avoids accidental shape mismatches and gives IDE help.

-import type { GetServerSidePropsContext } from "next";
 ...
-export async function getServerSideProps({ locale }: { locale: string }) {
+import type { GetServerSidePropsContext } from "next";
+
+export async function getServerSideProps({ locale }: GetServerSidePropsContext) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c12f684 and 03877b9.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (8)
  • next-i18next.config.js (1 hunks)
  • next.config.mjs (1 hunks)
  • package.json (2 hunks)
  • public/locales/en/common.json (1 hunks)
  • public/locales/ru/common.json (1 hunks)
  • src/components/inherited-map/components/filter-panel/filter-panel-normal.js (4 hunks)
  • src/pages/_app.tsx (2 hunks)
  • src/pages/iframes/map.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/pages/iframes/map.tsx (1)
src/components/inherited-map/components/filter-panel/filter-panel-normal.js (1)
  • useTranslation (69-69)
🔇 Additional comments (2)
public/locales/en/common.json (1)

2-6: Sync with RU locale – missing future keys will break runtime look-ups
Ensure any future keys added to one locale are added to the other to avoid fallback to the default language.

src/components/inherited-map/components/filter-panel/filter-panel-normal.js (1)

2-2: i18n integration looks correct

The new useTranslation hook is wired up properly and the static text has been replaced with keys that will be resolved at runtime.
No functional or stylistic issues spotted in these lines. Nice and minimal change.

Also applies to: 69-69, 88-88, 105-105

Comment on lines +24 to +35
i18n: {
defaultLocale: "ru",
locales: ["ru", "en"],
localeDetection: false, // отключить автоопределение по Accept-Language
localeCookie: {
name: "django_language",
httpOnly: false,
sameSite: false, // Django uses None, Next.js uses false for None
path: "/",
secure: false, // same as Django DEBUG mode
},
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

i18n.localeCookie is not supported by Next config

Next.js (≤ 13.5) validates next.config.js and fails on unknown keys.
localeCookie is not part of the documented i18n schema, so this block will either be ignored or throw during next build, breaking the pipeline.

If you need custom cookie handling, move that logic to middleware.ts or your own server layer and drop the unsupported field:

   i18n: {
     defaultLocale: "ru",
     locales: ["ru", "en"],
     localeDetection: false,
-    localeCookie: {
-      name: "django_language",
-      httpOnly: false,
-      sameSite: false,
-      path: "/",
-      secure: false,
-    },
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
i18n: {
defaultLocale: "ru",
locales: ["ru", "en"],
localeDetection: false, // отключить автоопределение по Accept-Language
localeCookie: {
name: "django_language",
httpOnly: false,
sameSite: false, // Django uses None, Next.js uses false for None
path: "/",
secure: false, // same as Django DEBUG mode
},
},
i18n: {
defaultLocale: "ru",
locales: ["ru", "en"],
localeDetection: false, // отключить автоопределение по Accept-Language
},
🤖 Prompt for AI Agents
In next.config.mjs around lines 24 to 35, the i18n.localeCookie configuration is
not supported by Next.js and will cause build failures. Remove the entire
localeCookie block from the i18n config. If custom cookie handling is required,
implement that logic separately in middleware.ts or your server code instead of
placing it in next.config.mjs.

Comment on lines +35 to 36
"@prisma/client": "latest",
"@sentry/nextjs": "^6.17.9",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Avoid un-pinned "latest" for Prisma – introduces non-deterministic builds
Using "latest" for both @prisma/client and prisma means every fresh install can silently pick up a new major version and break your compiled client or schema workflow. Pin to an explicit semver range you’ve verified.

-    "@prisma/client": "latest",
+    "@prisma/client": "^5.9.0",-    "prisma": "latest",
+    "prisma": "^5.9.0",

Also applies to: 84-85


🏁 Script executed:

#!/bin/bash
# Verify use of un-pinned “latest” for Prisma packages
echo "@prisma/client version in dependencies:"
jq -r '.dependencies["@prisma/client"] // "not found"' package.json
echo "prisma version in devDependencies:"
jq -r '.devDependencies["prisma"] // "not found"' package.json
echo "All occurrences of “latest” in package.json:"
rg -n '"latest"' -n package.json

Length of output: 512


Avoid un-pinned “latest” for Prisma – introduce deterministic, reproducible builds
Using "latest" for both @prisma/client and prisma means any fresh install can pull in a new major release and silently break your generated client or migration workflow. Pin each to an explicit, tested semver range.

Locations to update:

  • package.json – Line 35: "@prisma/client": "latest"
  • package.json – Line 84: "prisma": "latest"

Suggested diff:

-    "@prisma/client": "latest",
+    "@prisma/client": "^5.9.0",-    "prisma": "latest",
+    "prisma": "^5.9.0",

Adjust ^5.9.0 to whichever patch/minor you’ve verified in your CI before merging.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@prisma/client": "latest",
"@sentry/nextjs": "^6.17.9",
// … in your "dependencies" section around line 35 …
"@prisma/client": "^5.9.0",
"@sentry/nextjs": "^6.17.9",
// … other dependencies …
// … in your "devDependencies" section around line 84 …
"prisma": "^5.9.0",
// … other devDependencies …
🤖 Prompt for AI Agents
In package.json at lines 35 and 84, the dependencies "@prisma/client" and
"prisma" are set to "latest", which can cause unpredictable builds. Replace
"latest" with a specific semver version range, such as "^5.9.0" or the exact
version verified in your CI, to ensure deterministic and reproducible builds.

Comment on lines +40 to 48
"i18next": "^25.3.2",
"lru-cache": "^7.4.0",
"mobx": "^6.4.0",
"mobx-devtools-mst": "^0.9.30",
"mobx-react": "^7.3.0",
"mobx-state-tree": "^5.1.3",
"next": "^12.1.0",
"next-i18next": "^15.4.2",
"react": "^17.0.2",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Version incompatibility: next-i18next@15 requires Next ≥ 13.4 but project is on 12.1
next-i18next v15 moved to Next.js’ App Router and relies on features that do not exist in Next 12. Either:

  1. Upgrade next (and React) to a compatible version,
  2. or downgrade next-i18next to ≤ 13.x.

Failing to align these will surface at build time with Module not found/appDir errors.

🤖 Prompt for AI Agents
In package.json around lines 40 to 48, the version of next-i18next (15.4.2)
requires Next.js version 13.4 or higher, but the project currently uses Next
12.1. To fix this, either upgrade the next dependency to at least 13.4 along
with a compatible React version, or downgrade next-i18next to version 13.x or
lower to maintain compatibility and avoid build errors related to missing
modules or appDir features.

Comment on lines +5 to 6
import { appWithTranslation } from "next-i18next";
import * as React from "react";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Pass the config object to appWithTranslation to ensure SSR parity
next-i18next looks for the config via CJS require, which fails in some ESM/monorepo setups and on Netlify. Importing and passing the config makes the linkage explicit.

-import { appWithTranslation } from "next-i18next";
+import { appWithTranslation } from "next-i18next";
+import nextI18NextConfig from "../../next-i18next.config.js";-export default appWithTranslation(App);
+export default appWithTranslation(App, nextI18NextConfig);

Also applies to: 28-28


I’ll verify whether a next-i18next.config file exists and inspect how appWithTranslation is currently being invoked.


🏁 Script executed:

#!/bin/bash
# Locate the i18next config file
fd next-i18next.config.* --max-depth 2

# Show the top of _app.tsx to see current imports and usage
sed -n '1,80p' src/pages/_app.tsx

Length of output: 906


Import and pass the Next-i18next config to appWithTranslation

To ensure the config is resolved correctly in ESM/monorepo setups (and on Netlify), explicitly import your next-i18next.config.js and pass it into appWithTranslation.

• In src/pages/_app.tsx, add:

import nextI18NextConfig from "../../next-i18next.config.js";

• Replace the default export on line 28:

- export default appWithTranslation(App);
+ export default appWithTranslation(App, nextI18NextConfig);

This makes the CJS→ESM linkage explicit and avoids SSR parity issues.

🤖 Prompt for AI Agents
In src/pages/_app.tsx around lines 5 to 6, import the next-i18next configuration
explicitly by adding "import nextI18NextConfig from
'../../next-i18next.config.js';" and then update the default export on line 28
to pass this config into appWithTranslation, i.e., use appWithTranslation(MyApp,
nextI18NextConfig). This ensures proper config resolution in ESM/monorepo
environments and prevents SSR parity issues.

@triklozoid triklozoid closed this Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants