Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adapt to the japanese languange #1311

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

serapieTuyishime
Copy link
Contributor

Submit a pull request

  • This is not a duplicate of an existing pull request.
  • No existing features have been broken without good reason.
  • Your commit messages are detailed
  • The code style guideline have been followed.
  • Documentation has been updated to reflect your changes.
  • Tests have been added or updated to reflect your changes.
  • All tests pass.

Replace any ":question:" below with information about your pull request.

Pull Request Details

Provide details about your pull request and what it adds, fixes, or changes.

Breaking Changes

Describe what features are broken by this pull request and why, if any.

Issues Fixed

Enter the issue numbers resolved by this pull request below, if any.

Other Relevant Information

Provide any other important details below.

@serapieTuyishime serapieTuyishime self-assigned this Nov 11, 2024
Copy link

coderabbitai bot commented Nov 11, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces several changes to enhance localization support for the Japanese language in the application. The next-i18next.config.js file has been updated to include "ja" in the locales array. Correspondingly, the languages constant in src/constants/languages.ts has been modified to associate the key ja with the value "Japanese." Additionally, the LOCALES constant in src/constants/locales.ts has been updated to include "ja." A new JSON file, public/locales/ja/common.json, has also been added, containing translations for various application components in Japanese.

Changes

File Change Summary
next-i18next.config.js Updated locales array to include "ja".
src/constants/languages.ts Added entry ja: "Japanese" to the languages constant.
src/constants/locales.ts Updated LOCALES constant to include "ja".
public/locales/ja/common.json Added new file containing localization strings for the Japanese language.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant LocaleService

    User->>App: Select Japanese language
    App->>LocaleService: Request translations for "ja"
    LocaleService-->>App: Provide translations
    App-->>User: Display content in Japanese
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4b51cb8 and f81f44d.

📒 Files selected for processing (1)
  • public/locales/ja/common.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • public/locales/ja/common.json

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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

netlify bot commented Nov 11, 2024

Deploy Preview for staging-dacade ready!

Name Link
🔨 Latest commit f81f44d
🔍 Latest deploy log https://app.netlify.com/sites/staging-dacade/deploys/673bd79e2c31cf00085ae56b
😎 Deploy Preview https://deploy-preview-1311--staging-dacade.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 site configuration.

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: 3

🧹 Outside diff range and nitpick comments (1)
next-i18next.config.js (1)

Line range hint 1-11: Consider adding JSDoc comments for configuration

While the configuration is working, it would be helpful to add JSDoc comments explaining the purpose of each configuration option and any specific requirements for adding new locales.

Add documentation like this:

// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");

+/**
+ * next-i18next configuration
+ * @see https://next.i18next.com/overview/configuration
+ * @type {import('next-i18next').UserConfig}
+ */
module.exports = {
  i18n: {
    locales: ["en", "bg", "es", "hr", "ko", "zh", "ja"],
    defaultLocale: "en",
  },
  localePath: path.resolve("./public/locales"),
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0403451 and ad61fb2.

📒 Files selected for processing (3)
  • next-i18next.config.js (1 hunks)
  • src/constants/languages.ts (1 hunks)
  • src/constants/locales.ts (1 hunks)

@@ -1,3 +1,3 @@
export const LOCALES = ["en", "bg", "es", "hr", "ko", "zh"];
export const LOCALES = ["en", "bg", "es", "hr", "ko", "zh", "jp"];
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Critical: Incorrect Japanese locale code used across multiple files

The incorrect locale code "jp" for Japanese is consistently used across three files. This needs to be changed to the ISO 639-1 standard "ja":

  • src/constants/locales.ts:
-export const LOCALES = ["en", "bg", "es", "hr", "ko", "zh", "jp"];
+export const LOCALES = ["en", "bg", "es", "hr", "ko", "zh", "ja"];
  • next-i18next.config.js:
-    locales: ["en", "bg", "es", "hr", "ko", "zh", "jp"],
+    locales: ["en", "bg", "es", "hr", "ko", "zh", "ja"],
  • src/constants/languages.ts:
-  jp: "Japanese",
+  ja: "Japanese",
🔗 Analysis chain

Critical: Use correct ISO language code for Japanese

The locale code "jp" is incorrect for Japanese. According to ISO 639-1 standards, the correct language code for Japanese is "ja". While "jp" is the country code (ISO 3166-1), for language localization we should use the language code "ja".

Apply this fix:

-export const LOCALES = ["en", "bg", "es", "hr", "ko", "zh", "jp"];
+export const LOCALES = ["en", "bg", "es", "hr", "ko", "zh", "ja"];

This change should also be reflected in:

  • next-i18next.config.js
  • src/constants/languages.ts

Let's verify the usage of this locale code across the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any hardcoded usage of 'jp' locale
# to ensure we catch all instances that need updating

echo "Checking for 'jp' locale usage..."
rg -l '"jp"' --type ts --type js --type json

echo "Checking for Japanese language configuration..."
rg -l 'Japanese' --type ts --type js --type json

Length of output: 358


Script:

#!/bin/bash
# Let's check the actual content of these files to confirm the usage
echo "Content of next-i18next.config.js:"
cat next-i18next.config.js

echo -e "\nContent of src/constants/languages.ts:"
cat src/constants/languages.ts

Length of output: 673

@@ -5,4 +5,5 @@ export const languages: { [key: string]: string } = {
hr: "Croatian",
ko: "Korean",
zh: "Chinese",
jp: "Japanese",
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Update Japanese locale code from 'jp' to 'ja' across configuration files

The incorrect ISO code 'jp' is indeed used in multiple files. Here are all the locations that need to be updated:

  • src/constants/languages.ts: Change jp: "Japanese" to ja: "日本語"
  • next-i18next.config.js: Update locale array to use ja instead of jp
  • src/constants/locales.ts: Update locale array to use ja instead of jp

Additionally, ensure the locale files under public/locales/ are named correctly using the 'ja' code instead of 'jp'.

🔗 Analysis chain

Update Japanese language entry to use correct ISO code and native name

There are two issues with the Japanese language entry:

  1. The language code 'jp' is incorrect. According to ISO 639-1 standards, the correct code for Japanese is 'ja'. Note that 'jp' is often confused with Japanese but actually refers to the country code (Japan), not the language code.

  2. For consistency with entries like "Español", consider using the native name "日本語" (Nihongo) instead of "Japanese".

Apply this change:

-  jp: "Japanese",
+  ja: "日本語",

This change will require corresponding updates in other files where the locale code is used (e.g., next-i18next.config.js and locales.ts).

Let's verify other files that need to be updated:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for 'jp' locale usage across the codebase
rg -l '\bjp\b' --type ts --type js --type json

Length of output: 123


Script:

#!/bin/bash
# Check the content of these files to see how 'jp' is used
echo "=== next-i18next.config.js ==="
cat next-i18next.config.js

echo -e "\n=== src/constants/locales.ts ==="
cat src/constants/locales.ts

Length of output: 564

@@ -3,7 +3,7 @@ const path = require("path");

module.exports = {
i18n: {
locales: ["en", "bg", "es", "hr", "ko", "zh"],
locales: ["en", "bg", "es", "hr", "ko", "zh", "jp"],
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Critical: Incorrect ISO language code needs to be updated in multiple files

The incorrect "jp" language code is consistently used across three files that need to be updated:

  • next-i18next.config.js: Change "jp" to "ja" in locales array
  • src/constants/locales.ts: Change "jp" to "ja" in LOCALES array
  • src/constants/languages.ts: Change "jp" to "ja" in languages object key

Apply this fix across all files:

- "jp": "Japanese"
+ "ja": "Japanese"

The ISO 639-1 language code "ja" must be used for Japanese localization to work correctly.

🔗 Analysis chain

Critical: Incorrect ISO language code for Japanese

The locale code "jp" is incorrect. The ISO 639-1 language code for Japanese is "ja". While "jp" is the country code for Japan, "ja" is the correct language code that should be used for internationalization.

Apply this fix:

- locales: ["en", "bg", "es", "hr", "ko", "zh", "jp"],
+ locales: ["en", "bg", "es", "hr", "ko", "zh", "ja"],

Let's verify the usage of this incorrect code across other files:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of incorrect 'jp' locale code across the codebase
# Expected: Should find instances where we need to update 'jp' to 'ja'

echo "Checking for 'jp' usage in language/locale related files..."
rg -l "jp" --type ts --type js src/constants/

Length of output: 232


Script:

#!/bin/bash
# Let's check the actual content of these files to see how 'jp' is used
echo "Content of src/constants/locales.ts:"
cat src/constants/locales.ts

echo -e "\nContent of src/constants/languages.ts:"
cat src/constants/languages.ts

Length of output: 510

@@ -0,0 +1,455 @@
{
"app.name": "ダケード",
Copy link
Contributor

Choose a reason for hiding this comment

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

the file name doesn't match the language code

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