Skip to content

Conversation

lelemm
Copy link
Collaborator

@lelemm lelemm commented Feb 10, 2025

Summary by CodeRabbit

  • New Features

    • The app now defaults to Brazilian Portuguese, offering a more consistent localization experience.
    • The language settings interface is now accessible only to users with administrator permissions.
  • Refactor

    • Enhanced translation management now automatically cleans up incomplete translations and updates error messaging for improved clarity.
    • Updated the source for cloning translation files to a new repository.

Copy link

coderabbitai bot commented Feb 10, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update the translation processing and language configuration throughout the project. The script that removes untranslated files now references pt-BR.json instead of en.json, with adjusted key and error handling logic. The internationalization setup in the i18n module and preferences loading function now default to Brazilian Portuguese ("pt-BR"). Additionally, the LanguageSettings component is modified to include a permission check that restricts rendering to users with administrator privileges.

Changes

File(s) Change Summary
packages/desktop-client/bin/…/remove-untranslated-languages
packages/desktop-client/src/i18n.ts
packages/loot-core/src/…/prefs.ts
Replaced English language references with Brazilian Portuguese ("pt-BR"), updated file paths, error messages, default language fallback, and thresholds for key comparisons.
packages/desktop-client/src/…/LanguageSettings.tsx Introduced a permission check via the useAuth hook to conditionally render the language settings component for users with the ADMINISTRATOR role.
bin/package-browser Updated the repository URL for cloning translation files from https://github.com/actualbudget/translations to https://github.com/lagoom-br/translations.git.

Sequence Diagram(s)

sequenceDiagram
    participant S as Script
    participant D as Translations Dir
    participant F as JSON File
    S->>D: Check for pt-BR.json existence
    D-->>S: Confirm pt-BR.json found
    S->>S: Count keys in pt-BR.json
    loop For each JSON file in directory
        S->>F: Read file and count keys
        alt File ≠ pt-BR.json AND keys < 50% of pt-BR
            S->>D: Delete file
        else
            S->>S: Retain file
        end
    end
Loading
sequenceDiagram
    participant LS as LanguageSettings Component
    participant Auth as useAuth Hook
    LS->>Auth: Request hasPermission('ADMINISTRATOR')
    Auth-->>LS: Return permission status
    alt Permission granted
        LS->>LS: Render language settings interface
    else Permission denied
        LS->>LS: Render empty fragment
    end
Loading

Poem

I'm a rabbit, hopping in delight,
pt-BR now guides our code so bright.
Skipping files with a careful glance,
Admin checks give settings a chance.
With JSON keys and changes so true,
I celebrate these updates—hip, hop, woo!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 46848c2 and 74a604a.

📒 Files selected for processing (3)
  • bin/package-browser (1 hunks)
  • packages/desktop-client/src/components/settings/LanguageSettings.tsx (3 hunks)
  • packages/desktop-client/src/i18n.ts (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 2

🔭 Outside diff range comments (2)
packages/desktop-client/bin/remove-untranslated-languages (1)

30-48: Remove dead code.

This code block is unreachable due to the return statement on line 28.

Remove the dead code block to improve maintainability.

packages/desktop-client/src/i18n.ts (1)

26-26: Update the default language in i18n initialization.

The i18n initialization still uses 'en' as the default language, which is inconsistent with the changes to use 'pt-BR' as the default.

Apply this diff to fix the inconsistency:

-    lng: 'en',
+    lng: 'pt-BR',
🧹 Nitpick comments (2)
packages/desktop-client/src/i18n.ts (1)

49-52: Update the outdated comment.

The comment refers to English being always available, but the code now uses Brazilian Portuguese as the default language.

Apply this diff to fix the comment:

-      // English is always available since we use natural-language keys.
+      // Brazilian Portuguese is always available since it's our default language.
packages/desktop-client/src/components/settings/LanguageSettings.tsx (1)

88-88: Fix empty fragment formatting.

The empty fragment doesn't follow the formatting rules.

Apply this diff to fix the formatting:

-  ) : <></>;
+  ) : (
+    <></>
+  );
🧰 Tools
🪛 ESLint

[error] 88-88: Replace <></> with (⏎····<></>⏎··)

(prettier/prettier)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f1fadb and 46848c2.

📒 Files selected for processing (4)
  • packages/desktop-client/bin/remove-untranslated-languages (1 hunks)
  • packages/desktop-client/src/components/settings/LanguageSettings.tsx (3 hunks)
  • packages/desktop-client/src/i18n.ts (2 hunks)
  • packages/loot-core/src/client/actions/prefs.ts (1 hunks)
🧰 Additional context used
🪛 ESLint
packages/desktop-client/src/components/settings/LanguageSettings.tsx

[error] 88-88: Replace <></> with (⏎····<></>⏎··)

(prettier/prettier)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: compare
🔇 Additional comments (1)
packages/desktop-client/src/components/settings/LanguageSettings.tsx (1)

36-36: Consider the UX impact of restricting language settings.

Restricting language settings to administrators might negatively impact non-admin users who need to use the application in their preferred language.

Consider:

  1. Should language preferences be a personal setting rather than an admin-only feature?
  2. How will non-admin users handle language preferences?

Also applies to: 88-88

Comment on lines 23 to 29
files.forEach((file) => {
if (file === 'en.json' || path.extname(file) !== '.json') return;
if (file === 'pt-BR.json' || path.extname(file) !== '.json') return;

const filePath = path.join(localRepoPath, file);
fs.unlinkSync(filePath);
return;

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review the aggressive file deletion logic.

The current implementation unconditionally deletes all JSON files except pt-BR.json. This seems overly aggressive and contradicts the internationalization support shown in other files. Consider keeping the original logic that checks for translation completeness.

Apply this diff to restore the translation completeness check:

-      if (file === 'pt-BR.json' || path.extname(file) !== '.json') return;
-
-      const filePath = path.join(localRepoPath, file);
-      fs.unlinkSync(filePath);
-      return;
+      if (file === 'pt-BR.json' || path.extname(file) !== '.json') {
+        return;
+      }
+
+      const filePath = path.join(localRepoPath, file);
+      const jsonData = JSON.parse(fs.readFileSync(filePath, 'utf8'));
+      const fileKeysCount = Object.keys(jsonData).length;
+
+      // Calculate the percentage of keys present compared to pt-BR.json
+      const percentage = (fileKeysCount / enKeysCount) * 100;
+      console.log(`${file} has ${fileKeysCount} keys (${percentage.toFixed(2)}%).`);
+
+      if (percentage < 50) {
+        fs.unlinkSync(filePath);
+        console.log(`Deleted ${file} due to insufficient keys.`);
+      } else {
+        console.log(`Keeping ${file}.`);
+      }
📝 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
files.forEach((file) => {
if (file === 'en.json' || path.extname(file) !== '.json') return;
if (file === 'pt-BR.json' || path.extname(file) !== '.json') return;
const filePath = path.join(localRepoPath, file);
fs.unlinkSync(filePath);
return;
files.forEach((file) => {
- if (file === 'pt-BR.json' || path.extname(file) !== '.json') return;
-
- const filePath = path.join(localRepoPath, file);
- fs.unlinkSync(filePath);
- return;
+ if (file === 'pt-BR.json' || path.extname(file) !== '.json') {
+ return;
+ }
+
+ const filePath = path.join(localRepoPath, file);
+ const jsonData = JSON.parse(fs.readFileSync(filePath, 'utf8'));
+ const fileKeysCount = Object.keys(jsonData).length;
+
+ // Calculate the percentage of keys present compared to pt-BR.json
+ const percentage = (fileKeysCount / enKeysCount) * 100;
+ console.log(`${file} has ${fileKeysCount} keys (${percentage.toFixed(2)}%).`);
+
+ if (percentage < 50) {
+ fs.unlinkSync(filePath);
+ console.log(`Deleted ${file} due to insufficient keys.`);
+ } else {
+ console.log(`Keeping ${file}.`);
+ }
});

@@ -43,7 +43,7 @@ export function loadPrefs() {
);

// We need to load translations before the app renders
setI18NextLanguage(globalPrefs.language ?? '');
setI18NextLanguage('pt-BR');
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Reconsider hardcoding the language.

Hardcoding the language to 'pt-BR' removes user language preference support. This change forces all users to use Brazilian Portuguese, ignoring their preferences in globalPrefs.language.

Consider restoring user language preference support:

-    setI18NextLanguage('pt-BR');
+    setI18NextLanguage(globalPrefs.language);
📝 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
setI18NextLanguage('pt-BR');
setI18NextLanguage(globalPrefs.language);

@lelemm lelemm closed this Feb 10, 2025
lelemm added a commit that referenced this pull request Feb 20, 2025
* Translation batch

* md

* Update packages/desktop-client/src/components/settings/Export.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix code review from coderabbit

* code review

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
lelemm added a commit that referenced this pull request Feb 20, 2025
* 🐛  Fix Initializing the connection to the local database hang (actualbudget#4375)

* fix initializing to the local db

* release notes

* Add percentage adjustments to schedule templates (actualbudget#4098) (actualbudget#4257)

* add percentage adjustments to schedule templates

* update release note

* remove unecessary parentheses

* Update packages/loot-core/src/server/budget/goalsSchedule.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* PR comments addressed

* Linting fixes

* Updated error handling, added tests

* Linting fixes

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: youngcw <calebyoung94@gmail.com>

* Custom mapping and import settings for bank sync providers (actualbudget#4253)

* barebones UI

* add saving and prefs

* add last sync functionality

* use mapping for synced transactions

* note

* jest -u

* Update VRT

* Coderabbit

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* add new fields

* rename migration, newer in master

* lint

* coderabbit

* update snapshots

* GoCardless handlers fallback and notes

* expose new fields from SimpleFIN

* update tests

* update instructions on GoCardless handlers

* lint

* feedback

* Update VRT

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: youngcw <calebyoung94@gmail.com>

* Add fallback value for payeename: 'undefined' - CBC Bank (actualbudget#4384)

* Add fallback value for payename: 'undefined'

* docs: add release note

* Add fallback value for payename: 'undefined' (for negative amounts)

* [TypeScript] Convert test page models to TS (actualbudget#4218)

* Dummy commit

* Delete js snapshots

* Move extended expect and test to fixtures

* Fix wrong commit

* Update VRT

* Dummy commit to run GH actions

* Convert test page models to TS

* Release notes

* Fix typecheck errors

* New page models to TS

* Fix typecheck error

* Fix page name

* Put awaits on getTableTotals

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* rename two migrations to realign with convention (actualbudget#4343)

* Updating sync server package name to @actual-app/sync-server (actualbudget#4370)

* updating sync server to have a consistent package name

* release notes

* Add today button on mobile budget page (actualbudget#4380)

* feat: today button on mobile budget page

Jumps to the current month

* add release note

* cleaner onCurrentMonth

* Update VRT

* use SvgCalendar from icons/v2

Co-authored-by: Matt Fiddaman <github@m.fiddaman.uk>

* Update VRT

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Fiddaman <github@m.fiddaman.uk>

* Development mode for sync server (React Fast Refresh on port 5006) (actualbudget#4372)

* devmode for sync server

* removed pluggy from this version

* md

* code review

* changed how open browser

* missed this

* linter

* trigger actions

* 🐛 Fix: Error rate limit at user directory page (actualbudget#4397)

* Error rate limit

* md

* 🐛 Fix new proxy middleware dependency missing on prod build (actualbudget#4400)

* fix new proxy middleware not installed on prod build

* release notes

* Remove deprecated imports for several components (actualbudget#4385)

* don't unbudget goals

* lint

* Fixes actualbudget#4069 : Ignore CSV inOutMode during OFX imports (actualbudget#4382)

* Ignore inOutMode during OFX imports

* Add release notes

---------

Co-authored-by: youngcw <calebyoung94@gmail.com>

* fix tooltip translation (actualbudget#4402)

* [TypeScript] Make `db.runQuery` generic to make it easy to type DB query results (actualbudget#4247)

* Make runQuery generic to make it easy to type DB query results.

* Release notes

* typo

* update mapping data for existing synced transactions and always show direction dropdown (actualbudget#4403)

* update sync mapping data for existing transactions on sync

* show payment direction dropdown regardless of sample data

* note

* ignore changes in raw_synced_data

* Fix top-level types of `send` function (actualbudget#4145)

* Add release notes

* Fix types of `send` function

* Fix `send` types in a number of places

* PR feedback

* Foundations for the budget automations UI (actualbudget#4308)

* Foundations for the budget automations UI

* Coderabbit

* Fix react-hooks/exhaustive-deps error on useSelected.tsx (actualbudget#4258)

* Fix react-hooks/exhaustive-deps error on useSelected.tsx

* Release notes

* Fix react-hooks/exhaustive-deps error on usePayees.ts (actualbudget#4260)

* Fix react-hooks/exhaustive-deps error on usePayees.ts

* Rename

* Release notes

* Fix react-hooks/exhaustive-deps error on useAccounts.ts (actualbudget#4262)

* Fix react-hooks/exhaustive-deps error on useAccounts.ts

* Release notes

* Fix react-hooks/exhaustive-deps error on Titlebar.tsx (actualbudget#4273)

* Fix react-hooks/exhaustive-deps error on Titlebar.tsx

* Release notes

* [WIP] BANKS_WITH_LIMITED_HISTORY constant update (actualbudget#4388)

* Fix react-hooks/exhaustive-deps error on useProperFocus.tsx (actualbudget#4259)

* Fix react-hooks/exhaustive-deps error on useProperFocus.tsx

* Remove comment in eslint config

* Release notes

* Fix react-hooks/exhaustive-deps error on TransactionsTable.jsx (actualbudget#4268)

* Fix react-hooks/exhaustive-deps error on TransactionsTable.jsx

* Release notes

* Fix lint

* Fix react-hooks/exhaustive-deps error on table.tsx (actualbudget#4274)

* Fix react-hooks/exhaustive-deps error on table.tsx

* Release notes

* Fix react-hooks/exhaustive-deps error on useCategories.ts (actualbudget#4261)

* Fix react-hooks/exhaustive-deps error on useCategories.ts

* Release notes

* 👷 Typescript: Improving typing of asyncStorage (global-store.json) (actualbudget#4369)

* typing globalprefs

* adding release notes

* unneeded partial

* removing prop that crept in

* 📚 Translation batch #1 (actualbudget#4408)

* Translation batch

* md

* Update packages/desktop-client/src/components/settings/Export.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix code review from coderabbit

* code review

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix currencyToAmount incorrectly converting input (actualbudget#4383)

* fix: ensure currencyToAmount works regardless of the configured number format

* chore: linting

* docs: add release note

* test: ensure correct amount is entered for debit when adding split transactions

* chore: rename variable thousandsSep to thousandsSeparator

Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>

* chore: rename variable decimalSep to decimalSeparator

Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>

* chore: rename decimalSep and thousandsSep variables to decimalSeparator and thousandsSeparator

---------

Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>

* useDisplayPayee hook to unify payee names in mobile and desktop. (actualbudget#4213)

* useDisplayPayee hook to unify payee logic in mobile and desktop

* Release notes

* Fix typecheck errors

* Fix test

* Update test

* Revert (No payee) color

* Fix tests

* VRT

* Fix category transactions

* Fix lint and VRT

* Update VRT

* Translate

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Extract transaction related server handlers from `main.ts` to `server/transactions/app.ts` (actualbudget#4221)

* Move transaction related handlers to server/transactions folder and use the new convention

* Fix lint and typecheck

* Release notes

* Update handler names

* Move get-earliest-transaction

* Update release notes

* Fix tests

* Fix types

* Fix lint

* Update snapshot

* Remove duplicate parse-file.ts

* Fix lint

* 🐛 Fix `On budget` / `Off budget` underline with translated languages (actualbudget#4417)

* Fix `On budget` / `Off budget` underline

* md

* ajuste para o merge

---------

Co-authored-by: Michael Clark <5285928+MikesGlitch@users.noreply.github.com>
Co-authored-by: Matt Farrell <10377148+MattFaz@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: youngcw <calebyoung94@gmail.com>
Co-authored-by: Matt Fiddaman <github@m.fiddaman.uk>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Michotte <55855805+MMichotte@users.noreply.github.com>
Co-authored-by: Joel Jeremy Marquez <joeljeremy.marquez@gmail.com>
Co-authored-by: Adam Stück <adam@adast.dk>
Co-authored-by: Alberto Cortina Eduarte <albertocortina96@gmail.com>
Co-authored-by: Gabriel J. Michael <gabriel.j.michael@gmail.com>
Co-authored-by: Julian Dominguez-Schatz <julian.dominguezschatz@gmail.com>
Co-authored-by: Michał Gołąb <23549913+michalgolab@users.noreply.github.com>
Co-authored-by: Antoine Taillard <an.taillard@gmail.com>
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.

1 participant