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

πŸ› Fix parameter formatting issues #3841

Merged

Conversation

MikesGlitch
Copy link
Contributor

@MikesGlitch MikesGlitch commented Nov 15, 2024

Some translation string formatting fixes that slipped through my review. πŸ€¦β€β™‚οΈ

Copy link

netlify bot commented Nov 15, 2024

βœ… Deploy Preview for actualbudget ready!

Name Link
πŸ”¨ Latest commit c665105
πŸ” Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67373ad2ad0fde00084c18e6
😎 Deploy Preview https://deploy-preview-3841.demo.actualbudget.org
πŸ“± 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
Contributor

Bundle Stats β€” desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
9 5.36 MB β†’ 5.36 MB (+26 B) +0.00%
Changeset
File Ξ” Size
home/runner/work/actual/actual/packages/loot-core/src/shared/errors.ts πŸ“ˆ +8 B (+0.23%) 3.4 kB β†’ 3.41 kB
src/components/modals/EnvelopeBudgetMonthMenuModal.tsx πŸ“ˆ +10 B (+0.14%) 7.07 kB β†’ 7.08 kB
src/components/modals/TrackingBudgetMonthMenuModal.tsx πŸ“ˆ +8 B (+0.12%) 6.72 kB β†’ 6.73 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.37 MB β†’ 3.37 MB (+26 B) +0.00%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 82.76 kB 0%
static/js/AppliedFilters.js 21.3 kB 0%
static/js/wide.js 242.64 kB 0%
static/js/ReportRouter.js 1.49 MB 0%

Copy link
Contributor

Bundle Stats β€” loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.31 MB β†’ 1.31 MB (+6 B) +0.00%
Changeset
File Ξ” Size
packages/loot-core/src/shared/errors.ts πŸ“ˆ +8 B (+0.19%) 4.05 kB β†’ 4.06 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.31 MB β†’ 1.31 MB (+6 B) +0.00%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@MikesGlitch MikesGlitch marked this pull request as ready for review November 15, 2024 12:16
Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

The pull request introduces changes to three files related to modal components and error handling within the application. In the EnvelopeBudgetMonthMenuModal.tsx and TrackingBudgetMonthMenuModal.tsx files, the updates involve modifying the string interpolation syntax for localization, changing from single curly braces ({displayMonth}) to double curly braces ({{displayMonth}}). This adjustment affects various notification messages and ensures proper interpretation by the translation function. Additionally, the Notes component in EnvelopeBudgetMonthMenuModal now conditionally displays "No notes" if originalNotes is empty, and the onShowMore function manages the visibility of additional content. In the errors.ts file, similar changes were made to error message formatting, transitioning to double curly braces for variable interpolation in functions related to upload, download, and synchronization errors. The overall structure and functionality of the components and functions remain unchanged.

Possibly related PRs

Suggested labels

sparkles: Merged

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

πŸ”§ eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eslint-plugin".

(The package "eslint-plugin-eslint-plugin" was not found when loaded as a Node module from the directory "/packages/eslint-plugin-actual".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eslint-plugin@latest --save-dev

The plugin "eslint-plugin-eslint-plugin" was referenced from the config file in "packages/eslint-plugin-actual/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


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.

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

🧹 Outside diff range and nitpick comments (4)
packages/loot-core/src/shared/errors.ts (2)

70-72: Consider standardizing error message format

While the i18next syntax is correct, the error message format differs from others in the file. Consider standardizing the format:

-        'Something went wrong trying to download that file, sorry! Visit https://actualbudget.org/contact/ for support. reason: {{reason}}{{info}}',
+        'Something went wrong trying to download that file, sorry! Visit https://actualbudget.org/contact/ for support. (ref: {{reason}}{{info}})',

This matches the format used in getUploadError where "ref:" precedes the technical details.


Line range hint 103-108: Fix inconsistent string interpolation in getSyncError

There's an inconsistency in the string interpolation syntax within the same function:

-      'Budget "{id}" not found. Check the id of your budget in the Advanced section of the settings page.',
+      'Budget "{{id}}" not found. Check the id of your budget in the Advanced section of the settings page.',

Line 104 uses single quotes around id while line 108 correctly uses double curly braces. This should be updated for consistency and proper i18next functionality.

packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx (1)

Line range hint 184-184: Consider using i18next for consistency

This message uses template literals instead of i18next translations, unlike other notification messages in this file.

Consider updating to use i18next translation:

-    message: `${displayMonth} budgets have all been set to ${numberOfMonths === 12 ? 'yearly' : `${numberOfMonths} month`} average.`,
+    message: t('{{displayMonth}} budgets have all been set to {{period}} average.', 
+      { 
+        displayMonth,
+        period: numberOfMonths === 12 ? t('yearly') : t('{{count}} month', { count: numberOfMonths })
+      }
+    ),
packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx (1)

Line range hint 178-181: Inconsistent translation handling detected.

This notification message is using direct string interpolation instead of the translation system. This should be consistent with other notification messages to support proper localization.

Consider updating to use the translation system:

- message: `${displayMonth} budgets have all been set to ${numberOfMonths === 12 ? 'yearly' : `${numberOfMonths} month`} average.`,
+ message: t(
+   '{{displayMonth}} budgets have all been set to {{period}} average.',
+   { 
+     displayMonth,
+     period: numberOfMonths === 12 ? t('yearly') : t('{{count}} month', { count: numberOfMonths })
+   }
+ ),
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 670419b and c665105.

β›” Files ignored due to path filters (1)
  • upcoming-release-notes/3841.md is excluded by !**/*.md
πŸ“’ Files selected for processing (3)
  • packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx (5 hunks)
  • packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx (4 hunks)
  • packages/loot-core/src/shared/errors.ts (3 hunks)
πŸ”‡ Additional comments (9)
packages/loot-core/src/shared/errors.ts (2)

37-39: LGTM! Correct i18next string interpolation syntax

The update to double curly braces {{reason}} follows i18next's proper variable interpolation syntax.


Line range hint 37-108: Verify consistent i18next syntax across the codebase

Let's ensure all translation strings use the correct double curly braces syntax.

βœ… Verification successful

Translation interpolation syntax is consistent across the codebase

The verification shows that all variable interpolations in translation strings correctly use the double curly braces syntax {{variable}}. The few instances with single braces found are either:

  1. Template literals using ${} for string interpolation
  2. JSX markup with curly braces for embedding expressions
  3. Not actual variable interpolations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential single-brace i18next interpolation
rg "t\(['\"].*?[^{]{[^{].*?['\"]" --type ts

# Search for translation calls with variables to verify
rg "t\(['\"].*?{.*?}.*?['\"].*?,.*?{.*?}" --type ts

Length of output: 359


Script:

#!/bin/bash
# Search for t() function calls with single curly brace interpolation
rg "t\('.*\{[^{].*'\)" --type ts
rg 't\(".*\{[^{].*"\)' --type ts

# Search for t() function calls with variables
rg "t\(['\"].*\{\{.*\}\}.*['\"].*,.*\{.*\}" --type ts

Length of output: 2051

🧰 Tools
πŸͺ› Biome

[error] 68-68: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 68-68: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx (4)

163-166: LGTM: Correct translation string format

The updated string interpolation syntax using double curly braces is correct for i18next translations.


173-176: LGTM: Consistent translation format

The translation string format is consistent with the previous change and follows i18next conventions.


194-197: LGTM: Proper translation string format

The translation string format is correct for i18next.


204-207: LGTM: Translation format is correct

The translation string format follows i18next conventions consistently.

Let's verify if there are any other translation strings that need similar updates:

βœ… Verification successful

Translation format is consistent throughout the modal component

After reviewing the entire modal component and similar patterns across other modal components, I can confirm that:

  • The translation string format {{displayMonth}} is used consistently throughout the file
  • All notification messages in the component follow the same i18next convention
  • The specific translation string for overwriting templates follows the same pattern as other similar notifications in the same component
  • No template literals are used for notification messages that should be translated
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential single-brace translation patterns that might need updating
rg "t\(['\"].*\{[^{].*['\"]" --type ts

# Search for template literals in notification messages that could be converted to translations
rg "showUndoNotification.*message:\s+`.*`" --type ts

Length of output: 6412


Script:

#!/bin/bash
# Let's search more specifically for translation patterns in the modal component
rg -A 2 "t\(['\"].*\{\{.*\}\}.*['\"]" "packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx"

# Also search for similar patterns in other modal components
rg -A 2 "t\(['\"].*\{\{.*\}\}.*['\"]" "packages/desktop-client/src/components/modals/"

# Check for any template literals in the same modal file
rg "`.*`" "packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx"

Length of output: 8348

packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx (3)

161-163: LGTM! Correct translation string format.

The updated string interpolation syntax using double curly braces {{displayMonth}} is the correct format for i18next translations.


171-173: LGTM! Consistent translation format.

The string interpolation syntax is correctly updated and maintains consistency with other translation strings.


192-194: LGTM! Translation format consistently applied.

All notification messages are correctly using the double curly braces syntax for variable interpolation, maintaining consistency throughout the file.

Also applies to: 202-204, 212-214

@MikesGlitch MikesGlitch merged commit 224d445 into actualbudget:master Nov 15, 2024
20 checks passed
@MikesGlitch MikesGlitch deleted the fix/translations-incorrect-format branch November 15, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants