Skip to content

Comments

feat: add farsi support#636

Merged
MrgSub merged 6 commits intoMail-0:stagingfrom
essinn:feature/language-support-fa
Apr 17, 2025
Merged

feat: add farsi support#636
MrgSub merged 6 commits intoMail-0:stagingfrom
essinn:feature/language-support-fa

Conversation

@essinn
Copy link
Contributor

@essinn essinn commented Apr 10, 2025

Added new file (fa.json) in apps/mail/locale and updated i18n config file to include Farsi. The translations are not complete but I have tried my best to translate some parts. I have made a start and expect others to finish.

Summary by CodeRabbit

  • New Features
    • Introduced full Persian (Farsi) localization for the mail application, providing comprehensive translations for the user interface, including actions, themes, navigation, and error messages.
    • Added Farsi as a new language option in the application settings.
  • Improvements
    • Updated string formatting for language constants to use single quotes for consistency.
    • Simplified the structure of the localization configuration for clarity.

@vercel
Copy link

vercel bot commented Apr 10, 2025

@essinn is attempting to deploy a commit to the Zero Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 10, 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

This PR introduces updates to the mail application's internationalization. The LANGUAGES constant in the configuration file now includes a new Persian language entry (fa: 'Farsi') with a change from double to single quotes. In addition, the defaultLocale is updated to use single quotes, and minor formatting adjustments have been made in the arrow function. A new JSON file for Persian localization (fa.json) has also been added, providing comprehensive key-value pairs for various UI elements and messages. The i18n.json file has been updated to include the new language code for Persian.

Changes

File(s) Change Summary
apps/mail/i18n/config.ts Added Farsi entry (fa: 'Farsi') to LANGUAGES; switched string literals to single quotes; updated defaultLocale and arrow function formatting.
apps/mail/locales/fa.json Added a new localization file containing Persian translations for UI texts, pluralization rules, and error messages.
i18n.json Updated to include the language code fa for Persian; simplified the "include" array by removing line breaks.

Possibly related PRs

  • i18n #437: The changes in the main PR involve modifications to the LANGUAGES constant and the addition of a new language entry for Farsi, which is related to this PR that also modifies the same file by adding new locale entries.
  • chore(i18n): config #445: Related changes involve modifications to the LANGUAGES constant and the availableLocales export in the apps/mail/i18n/config.ts file, specifically in how languages are defined and structured.

Suggested reviewers

  • MrgSub
  • needleXO

Poem

Amid the codes and lines so fine,
I’ve hopped to add some Farsi shine.
Single quotes here and I’ve tweaked a bit,
A new locale now helps users to sit.
With whiskers twitching in joyful cheer,
This rabbit’s proud of our updates here!
🥕🐰


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

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

🧹 Nitpick comments (2)
apps/mail/locales/fa.json (2)

3-41: Partially translated actions section with mixed language content.

The common actions section has some translated items (logout, back, create) but many remain in English. Consider prioritizing the translation of frequently used actions for a more cohesive user experience.

I recommend completing translations for at least these high-frequency actions:

  • Lines 15-24: Loading, moving, and archiving actions
  • Lines 32-38: Image display and sender trust actions

47-101: Command palette and search bar sections need translation.

These important navigation components are almost entirely in English. Consider prioritizing these sections in the next round of translations to improve the overall user experience for Farsi-speaking users.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b1e800c and dd9f236.

📒 Files selected for processing (2)
  • apps/mail/i18n/config.ts (1 hunks)
  • apps/mail/locales/fa.json (1 hunks)
🔇 Additional comments (6)
apps/mail/i18n/config.ts (4)

2-16: Quote style consistency update looks good.

The change from double quotes to single quotes for language names ensures a consistent style throughout the configuration file.


16-16: Successfully added Farsi language support.

The addition of the Farsi language entry aligns perfectly with the PR objectives and follows the established pattern for language definitions.


23-23: Consistent quote style for defaultLocale.

The update to use single quotes for the defaultLocale value maintains consistency with the other string literals in the file.


27-29: Arrow function formatting improved.

The addition of parentheses around the parameter in the arrow function follows TypeScript best practices for consistency.

apps/mail/locales/fa.json (2)

42-46: Well-translated UI theme and color sections.

These sections have been fully translated to Farsi, providing a good user experience for these fundamental UI elements.

Also applies to: 207-215


1-432:

Details

❓ Verification inconclusive

Good start on Farsi translations with some sections still in English.

The file provides a solid foundation for Farsi language support. As noted in the PR description, the translations are not complete, with many sections still in English (e.g., command palette, search bar, mail actions). This is acceptable for an initial implementation, with the expectation that translations will be completed incrementally.

To ensure the Farsi translations follow proper RTL (Right-to-Left) display requirements, please verify that the application has appropriate RTL support enabled:


🏁 Script executed:

#!/bin/bash
# Check if the project has RTL support configuration
echo "Checking for RTL support in the codebase..."
rg -i "rtl|right-to-left|direction" --type ts --type tsx --type css

Length of output: 194


Action: Verify and Ensure RTL Support Configuration for Farsi Locale

The Farsi translations are a promising start for language support, even though several sections (e.g., command palette, search bar, mail actions) remain in English. However, our automated check for RTL support encountered an issue due to file-type recognition (error with tsx). This means we haven’t conclusively verified whether the application’s configuration enables proper RTL display.

Next Steps:

  • Update the RTL search command to include tsx files by adding an appropriate file-type definition. For example:

    #!/bin/bash
    echo "Checking for RTL support in the codebase..."
    rg --type-add="tsx:*.tsx" -i "rtl|right-to-left|direction" --type ts --type tsx --type css
  • Manually verify that:

    • CSS or component files correctly set the direction (e.g., using dir="rtl", CSS rules for RTL layouts, or RTL-specific configuration).
    • The UI correctly applies RTL styling in Farsi-context views.

Once these aspects are ensured, the incremental improvements in translation can continue with confidence.

Comment on lines 123 to 124
"attachmentCount": "{count, plural, =0 {attachments} one {attachment} other {attachments}}",
"fileCount": "{count, plural, =0 {files} one {file} other {files}}",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify plural rules for Farsi language.

Farsi has different pluralization rules compared to English. The current implementation uses the standard plural format, but you may need to adjust these rules to properly handle Farsi grammar for quantities.

Also applies to: 182-182, 232-235


🌐 Web query:

What are the pluralization rules for Persian/Farsi language?

💡 Result:

In Persian (Farsi), pluralization primarily involves suffixation, with contextual rules for formality, etymology, and grammatical agreement. Here are the key rules and patterns:

Plural Suffixes

1. ها (hā)

  • Most common and versatile suffix, applicable to all nouns (animate/inanimate, Persian/Arabic origin) [1][3][8].
  • Written separately in formal contexts (کتاب‌ها ketābhā = "books") but may attach colloquially (کتابها) [1][2].
  • Spoken Persian often drops the h sound, pronouncing it as (کتابا ketābā) [1][8].

2. ان (ān)

  • Used for animate nouns (e.g., humans, animals) in formal writing:
    • مرد → مردان (mardmardān = "men") [2][8].
    • Exceptions: Some nouns ending in long vowels (آ/او/ای) require ی before ان:
      آقا → آقایان (āqāāqāyān = "gentlemen") [2].
  • Less common in casual speech, where ها is preferred [3][4][8].

3. Arabic-derived plurals

  • ات (āt): For Arabic loanwords (e.g., احساس → احساسات ehsāsehsāsāt = "feelings") [3][4][8].
  • Broken plurals: Internal vowel changes (e.g., کتاب → کُتُب ketābkotob = "books") [4][8].
  • These forms are optional; ها is widely accepted even for Arabic nouns [3][4].

Special Cases

  • After numbers: Plural suffixes are omitted (دو کتاب do ketāb = "two books") [7][10].
  • Inanimate subjects: Use singular verbs (میزها بزرگ است mizhā bozorg ast = "the tables are big") [9].
  • Possessive suffixes: Attach directly to plural nouns (کتاب‌هایم ketābhāyam = "my books") [10].

Colloquial vs. Formal

Feature Formal Colloquial
Plural suffix ان for animates, ها for others ها for all nouns [1][8]
Pronunciation ها (hā) ـا (ā) after consonants [1][8]
Verb agreement Plural for animates Singular for inanimates [9]

Examples

  • Formal: پرندگان (parandegān = "birds") [8].
  • Colloquial: پرنده‌ها (parandehā) [8].
  • Arabic plural: مکاتب (makāteb = "schools") vs. مدرسه‌ها (madāresehā) [4][8].

Persian pluralization is flexible, with ها serving as the default choice in most contexts, while ان and Arabic forms persist in formal or literary usage.

Citations:


Update Farsi Pluralization Handling

Please adjust the ICU message syntax for Farsi so that it reflects the language’s pluralization rules. In Farsi, the grammar distinguishes only between the singular (when the count is exactly 1) and the plural (for all other counts), meaning that an explicit =0 case isn’t necessary. Consider removing the separate zero case and using just one and other for these entries.

  • Files/Lines Affected:
    • apps/mail/locales/fa.json: Lines 123–124, as well as similar patterns at lines 182 and 232–235.

For example, change from:

"attachmentCount": "{count, plural, =0 {attachments} one {attachment} other {attachments}}",
"fileCount": "{count, plural, =0 {files} one {file} other {files}}",

to something like:

"attachmentCount": "{count, plural, one {پیوست} other {پیوست‌ها}}",
"fileCount": "{count, plural, one {فایل} other {فایل‌ها}}",

This update will align the pluralization with Farsi grammar rules where only the singular (for 1) and the plural (for all other numbers) are needed.

@MrgSub
Copy link
Collaborator

MrgSub commented Apr 11, 2025

Thank you! We recently migrated to use Lingo.dv, to add a new language with Lingo you should:

  1. fa.json strings should be left empty, Lingo will autofill them
  2. fa should be added to this list https://github.com/Mail-0/Zero/blob/main/i18n.json#L21

@essinn
Copy link
Contributor Author

essinn commented Apr 14, 2025

Thanks for the feedback, I have updated the fa.json file to use empty strings and added 'fa' to the i18n.json file as requested.

@MrgSub MrgSub changed the base branch from main to staging April 14, 2025 19:35
@MrgSub MrgSub merged commit 32a698d into Mail-0:staging Apr 17, 2025
1 of 2 checks passed
This was referenced 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