Skip to content

Conversation

@wiedymi
Copy link

@wiedymi wiedymi commented Apr 16, 2025

Summary by CodeRabbit

  • New Features
    • Added support for Belarusian (be) locale, providing Belarusian-language error messages for validation.
  • Documentation
    • Updated documentation to include Belarusian as an available locale and made minor formatting corrections.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 16, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new Belarusian (be) locale has been introduced for error messages, expanding the set of available languages in the core package. The locale is fully implemented with localized error handling logic for various validation scenarios. The export statements are updated to include this new locale, and documentation is refreshed to mention the Belarusian option. Minor formatting tweaks are also made to the docs.

Changes

File(s) Change Summary
packages/core/src/locales.ts Added import and export for the new be (Belarusian) locale.
packages/core/src/locales/be.ts Introduced Belarusian locale module with error mapping and dynamic error message generation.
packages/docs/content/error-customization.mdx Added be to the list of locales and made minor formatting corrections.

Poem

🌍
A new locale joins the crew,
Belarusian messages, crisp and true.
Errors now speak in a Slavic tongue,
Docs got tidied, lines unstrung.
From "az" to "be", the world expands—
Validation for all, in many lands!
🚀


🪧 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 generate docstrings to generate docstrings 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.

@colinhacks
Copy link
Owner

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 16, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@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: 2

🔭 Outside diff range comments (2)
packages/core/src/locales/be.ts (1)

1-133: 💡 Verification agent

🧩 Analysis chain

Fix Prettier formatting issue

The pipeline is failing because of formatting issues. Let's run Prettier to fix it.


🏁 Script executed:

#!/bin/bash
# Description: Check for specific formatting issues in the Belarusian locale file

# Print the detected line endings in the file
file packages/core/src/locales/be.ts | grep -o "line terminators"

# Check indentation with spaces vs tabs
grep -P "^\t" packages/core/src/locales/be.ts || echo "No tabs found at line beginnings"

# Check for trailing whitespace
grep -n " $" packages/core/src/locales/be.ts || echo "No trailing whitespace found"

Length of output: 399


Run Prettier on packages/core/src/locales/be.ts to fix formatting
Hey, I didn’t spot any tabs or trailing spaces, so the CI failure is almost certainly due to Prettier style mismatches (quotes, commas, etc.). Could you run:

pnpm prettier --write packages/core/src/locales/be.ts

and commit the updated file? That should clear the formatting error.

🧰 Tools
🪛 GitHub Actions: test

[error] 31-108: Prettier formatting check failed. The file content differs from the expected formatting.

packages/docs/content/error-customization.mdx (1)

341-344: 🧹 Nitpick (assertive)

Belarusian locale added to documentation

Great job adding the Belarusian locale to the documentation! The addition looks good, but consider maintaining alphabetical order for consistency.

 - `az` — Azerbaijani
+- `be` — Belarusian
 - `en` — English
-- `be` — Belarusian
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e5e146 and dab6da6.

📒 Files selected for processing (3)
  • packages/core/src/locales.ts (1 hunks)
  • packages/core/src/locales/be.ts (1 hunks)
  • packages/docs/content/error-customization.mdx (5 hunks)
🧰 Additional context used
🪛 GitHub Actions: test
packages/core/src/locales/be.ts

[error] 31-108: Prettier formatting check failed. The file content differs from the expected formatting.

packages/core/src/locales.ts

[error] 2-4: Import statements are not sorted correctly. Please organize imports.

🔇 Additional comments (6)
packages/core/src/locales/be.ts (3)

1-40: Implementation looks solid! 👍

Nice job implementing the Belarusian language support! The imports, the Sizable object, and the helper functions all look well-structured and similar to how other locale implementations handle these aspects.


42-73: Great handling of noun formats in Belarusian

The mapping of string formats to their Belarusian representations looks comprehensive. You've covered all the standard formats used in Zod.


75-124: Error mapping implementation looks good

Your error mapping function handles all the necessary error codes and provides appropriate Belarusian error messages. The messages are well-formed and should provide clear feedback to users.

packages/docs/content/error-customization.mdx (3)

11-13: Good formatting fixes

The formatting improvements to the blockquote and surrounding text look good. These small changes help maintain consistency in the documentation.


84-84: Whitespace cleanup - nice!

Thanks for removing the trailing whitespace here. These small cleanups help maintain code quality.


241-272: More whitespace cleanup - great attention to detail

Good job cleaning up the trailing whitespace in these lines as well. These small cleanups are easy to overlook but important for code quality.

Comment on lines 100 to 102
const _issue = issue as errors.$ZodStringFormatIssues;
if (_issue.format === "starts_with")
return `Няправільны радок: павінен пачынацца з "${issue}"`;
if (_issue.format === "ends_with")
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
if (_issue.format === "includes")
return `Няправільны радок: павінен уключаць "${_issue.includes}"`;
if (_issue.format === "regex")
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
return `Няправільны ${Nouns[_issue.format] ?? issue.format}`;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

There's a small issue in the invalid_format case

In the case for "starts_with", you're passing the entire issue instead of the prefix property.

-      if (_issue.format === "starts_with")
-        return `Няправільны радок: павінен пачынацца з "${issue}"`;
+      if (_issue.format === "starts_with")
+        return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
📝 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
const _issue = issue as errors.$ZodStringFormatIssues;
if (_issue.format === "starts_with")
return `Няправільны радок: павінен пачынацца з "${issue}"`;
if (_issue.format === "ends_with")
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
if (_issue.format === "includes")
return `Няправільны радок: павінен уключаць "${_issue.includes}"`;
if (_issue.format === "regex")
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
return `Няправільны ${Nouns[_issue.format] ?? issue.format}`;
}
const _issue = issue as errors.$ZodStringFormatIssues;
if (_issue.format === "starts_with")
return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
if (_issue.format === "ends_with")
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
if (_issue.format === "includes")
return `Няправільны радок: павінен уключаць "${_issue.includes}"`;
if (_issue.format === "regex")
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
return `Няправільны ${Nouns[_issue.format] ?? issue.format}`;
}

Comment on lines 1 to 6
import az from "./locales/az.js";
import en from "./locales/en.js";
import es from "./locales/es.js";
import be from "./locales/be.js";

export { az, es, en };
export { az, es, en, be };
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering

The pipeline is failing because the imports are not sorted correctly. Let's fix that:

 import az from "./locales/az.js";
+import be from "./locales/be.js";
 import en from "./locales/en.js";
 import es from "./locales/es.js";
-import be from "./locales/be.js";

-export { az, es, en, be };
+export { az, be, en, es };

This follows alphabetical ordering, which is generally preferred for imports.

📝 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
import az from "./locales/az.js";
import en from "./locales/en.js";
import es from "./locales/es.js";
import be from "./locales/be.js";
export { az, es, en };
export { az, es, en, be };
import az from "./locales/az.js";
import be from "./locales/be.js";
import en from "./locales/en.js";
import es from "./locales/es.js";
export { az, be, en, es };
🧰 Tools
🪛 GitHub Actions: test

[error] 2-4: Import statements are not sorted correctly. Please organize imports.

@VladSez
Copy link
Contributor

VladSez commented Apr 16, 2025

Sorry, I didn’t notice this PR and created a duplicate one for Belarusian language #4199

Comment on lines +5 to +14
const Sizable: Record<string, { unit: string; verb: string }> = {
string: { unit: "сімвалаў", verb: "мець" },
file: { unit: "байтаў", verb: "мець" },
array: { unit: "элементаў", verb: "мець" },
set: { unit: "элементаў", verb: "мець" },
};

function getSizing(origin: string): { unit: string; verb: string } | null {
return Sizable[origin] ?? null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

btw are plural forms correctly handled in this PR?

image

@colinhacks
Copy link
Owner

Hey @wiedymi. Thanks for this PR! Unfortunately another PR for Belarusian exists, and we're doing to consolidate work over there. Could you look over that other PR and see if there's anything you'd recommend? Thanks again! #4199

@colinhacks colinhacks closed this Apr 17, 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.

3 participants