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 untranslatable donation field string #22175

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

cathysarisky
Copy link
Contributor

@cathysarisky cathysarisky commented Feb 12, 2025

closes #21766

This PR adds the "Add a personal note" string to portal's API request when someone tries to make a donation. And adjusts the API endpoint to take it.

Request: Please review my handling of what could be user-generated content at the api endpoint. [It shouldn't be, but...] Sufficient handling, or more needed?

And tests... always tests.

Copy link
Contributor

coderabbitai bot commented Feb 12, 2025

Walkthrough

The changes introduce a new parameter, personalNoteText, to several methods involved in processing donations. In the portal’s support page and API modules, this parameter is appended to existing method signatures and is defaulted to the string "Add a personal note" if not provided. Similar updates have been made in the payments service and Stripe API integration where the new parameter is incorporated into the data passed through to external payment systems. Additionally, numerous localization files across different languages have been updated to include a new key for the phrase "Add a personal note" along with various related adjustments. These modifications enhance the donation features by enabling personalized messages without altering the core application logic or error handling.

Possibly related PRs

  • Insertion of phrases without translation in pt-BR #22075: The changes in the main PR, which involve adding a personalNoteText parameter to the checkoutDonation function, are related to the changes in the retrieved PR, which also includes updates to localization strings that mention adding a personal note, indicating a direct connection in functionality.
  • Finished and edited Slovak locale #21800: The changes in the main PR, which involve adding a personalNoteText parameter to the checkoutDonation function, are related to the modifications in the retrieved PR, as both involve updates to the Slovak localization files that enhance user interaction by including new phrases and improving existing translations.
  • Full translation into Russian (for new strings) #22186: The changes in the main PR, which involve adding a personalNoteText parameter to the checkoutDonation function, are related to the modifications in the retrieved PR that also focus on enhancing the localization and user interface for Russian, including the addition of the phrase "Add a personal note" in various contexts. Both PRs address the same functionality regarding personal notes in the donation process.

Suggested labels

affects:i18n, browser-tests


📜 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 cca2684 and ca0c6e0.

📒 Files selected for processing (1)
  • ghost/stripe/lib/StripeAPI.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/stripe/lib/StripeAPI.js
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Ghost-CLI tests

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

🔭 Outside diff range comments (6)
ghost/i18n/locales/sv/portal.json (1)

41-41: ⚠️ Potential issue

Regression: Previously translated strings are now empty.

The following strings have lost their Swedish translations:

  • "Comment preferences updated."
  • "Email preferences updated."
  • "Signups from this email domain are currently restricted."

This appears to be an unintended regression that reduces the localization coverage.

Please restore the previous Swedish translations for these strings. If you need help finding the previous translations, I can help search through the git history.

Also applies to: 63-63, 142-142

ghost/i18n/locales/zh/portal.json (1)

114-115: ⚠️ Potential issue

Verify the removal of existing translations.

Several existing translations have been removed (set to empty strings). This might be unintentional and could impact the user experience for Chinese users. Please verify if these translations should be preserved:

  • "No member exists with this e-mail address."
  • "No member exists with this e-mail address. Please sign up first."
  • Error messages for subscription and email operations

Also applies to: 166-169, 210-210

ghost/i18n/locales/ja/portal.json (1)

71-82: ⚠️ Potential issue

Verify the removal of existing translations.

Several existing translations have been removed (set to empty strings). This might be unintentional and could impact the user experience for Japanese users. Please verify if these translations should be preserved:

  • Error messages for login, logout, and signup operations
  • Error messages for account and subscription operations
  • Error messages for email operations

Also applies to: 166-169, 210-210

ghost/i18n/locales/cs/portal.json (1)

67-68: ⚠️ Potential issue

Inconsistent translations for similar strings.

Some strings have translations while similar ones don't:

  • "Enter your email address" is empty but "Invalid email address" has a translation
  • "Enter your name" is empty but "Name" has a translation

Also applies to: 100-100

ghost/i18n/locales/de-CH/portal.json (1)

67-68: ⚠️ Potential issue

Inconsistent translations for similar strings.

Some strings have translations while similar ones don't:

  • "Enter your email address" is empty but "Email" has a translation
  • "Enter your name" is empty but "Name" has a translation

Also applies to: 100-100

ghost/i18n/locales/fr/portal.json (1)

41-41: 🛠️ Refactor suggestion

Missing translations for several user-facing strings in French locale.

The following strings need French translations to ensure a complete localization experience:

  • "Comment preferences updated."
  • "Email preferences updated."
  • "Signups from this email domain are currently restricted."
  • "This site only accepts paid members."
  • "Too many sign-up attempts, try again later"

Also applies to: 63-63, 142-142, 172-172, 181-181

🧹 Nitpick comments (24)
ghost/i18n/locales/sv/portal.json (1)

18-18: Swedish translation needed for the new donation field string.

The new string "Add a personal note" requires a Swedish translation to maintain localization coverage.

Would you like me to help find a native Swedish speaker to provide the translation? I can create an issue to track this task.

ghost/i18n/locales/ro/portal.json (1)

101-101: Consider removing or transliterating the example name.

The entry "Jamie Larson" appears to be a placeholder name. Consider either:

  1. Removing it if not needed
  2. Using a Romanian name that would be more familiar to Romanian users
  3. Keeping it as is if it's a specific person's name that shouldn't be translated
ghost/i18n/locales/lt/portal.json (1)

1-215: Consider implementing a translation coverage check.

The file shows a pattern of missing translations for both new and existing strings. This could impact the user experience for Lithuanian users.

Consider implementing a CI check that:

  1. Prevents removal of existing translations
  2. Flags new strings without translations
  3. Reports translation coverage percentage

Here's a script to check translation coverage:

#!/bin/bash
# Description: Check translation coverage in portal.json

# Count total number of translation keys
total_keys=$(cat ghost/i18n/locales/lt/portal.json | jq 'length')

# Count number of empty translations
empty_translations=$(cat ghost/i18n/locales/lt/portal.json | jq '[to_entries[] | select(.value == "")] | length')

# Calculate and display coverage
coverage=$((100 * (total_keys - empty_translations) / total_keys))
echo "Translation coverage: $coverage% ($empty_translations empty translations out of $total_keys keys)"

# List keys with empty translations
echo -e "\nKeys missing translations:"
cat ghost/i18n/locales/lt/portal.json | jq 'to_entries[] | select(.value == "") | .key'
ghost/payments/lib/PaymentsService.js (1)

125-125: Add JSDoc documentation for the personalNoteText parameter.

The method signature should include documentation for the new parameter to improve code maintainability.

Apply this diff to add documentation:

     /**
      * @param {object} params
      * @param {Member} [params.member]
      * @param {Object.<string, any>} [params.metadata]
      * @param {string} params.successUrl
      * @param {string} params.cancelUrl
      * @param {boolean} [params.isAuthenticated]
      * @param {string} [params.email]
+     * @param {string} [params.personalNoteText] Personal note to be displayed with the donation
      *
      * @returns {Promise<URL>}
      */
ghost/i18n/locales/he/portal.json (1)

1-216: Consider implementing a translation management system.

The changes consistently add new keys across all localization files, but managing translations manually across multiple files can be error-prone. Consider:

  1. Implementing a translation management system to track missing translations
  2. Adding a CI check to flag missing translations
  3. Setting up a process to notify translators when new strings are added

Run this script to get an overview of translation coverage across all localization files:

#!/bin/bash
# Description: Generate a translation coverage report for all localization files
for file in ghost/i18n/locales/*/portal.json; do
  lang=$(echo $file | cut -d'/' -f4)
  total=$(jq 'length' $file)
  empty=$(jq 'to_entries | map(select(.value == "")) | length' $file)
  echo "Language: $lang"
  echo "Total strings: $total"
  echo "Empty translations: $empty"
  echo "---"
done
ghost/i18n/locales/ms/portal.json (1)

18-18: LGTM! Consider adding the English translation as a fallback.

The addition of the "Add a personal note" key follows the established pattern. While leaving it empty allows for future localization, consider adding the English text as a temporary fallback to ensure a good user experience until translations are provided.

-    "Add a personal note": "",
+    "Add a personal note": "Add a personal note",
ghost/i18n/locales/af/portal.json (1)

18-18: LGTM! Consider adding an Afrikaans translation.

The key has been added consistently. Since Afrikaans is similar to Dutch and English, a suggested translation would be "Voeg 'n persoonlike nota by".

-    "Add a personal note": "",
+    "Add a personal note": "Voeg 'n persoonlike nota by",
ghost/i18n/locales/pl/portal.json (1)

18-18: LGTM! Consider adding a Polish translation.

The key has been added consistently. A suggested Polish translation would be "Dodaj osobistą notatkę".

-    "Add a personal note": "",
+    "Add a personal note": "Dodaj osobistą notatkę",
ghost/i18n/locales/hu/portal.json (1)

18-18: LGTM! Consider adding a Hungarian translation.

The key has been added consistently. A suggested Hungarian translation would be "Személyes megjegyzés hozzáadása".

-    "Add a personal note": "",
+    "Add a personal note": "Személyes megjegyzés hozzáadása",
ghost/i18n/locales/bs/portal.json (1)

18-18: LGTM! Consider adding a Bosnian translation.

The key has been added consistently. A suggested Bosnian translation would be "Dodaj ličnu bilješku".

-    "Add a personal note": "",
+    "Add a personal note": "Dodaj ličnu bilješku",
ghost/i18n/locales/hi/portal.json (1)

1-216: Consider implementing a translation management system.

All localization files show a consistent pattern of missing translations for newly added strings. This suggests a need for a more streamlined translation process.

Consider implementing a translation management system that can:

  1. Automatically identify missing translations
  2. Notify translators when new strings are added
  3. Track translation progress across all languages
  4. Ensure consistency in translations

This would help maintain a high-quality localized experience across all supported languages.

ghost/i18n/locales/pt/portal.json (1)

18-18: LGTM! Key added consistently.

The new key "Add a personal note" has been added with an empty string value, ready for translation.

Would you like me to help provide the Portuguese translation for this string?

ghost/i18n/locales/el/portal.json (1)

18-18: LGTM! Key added consistently.

The new key "Add a personal note" has been added with an empty string value, ready for translation.

Would you like me to help provide the Greek translation for this string?

ghost/i18n/locales/no/portal.json (1)

18-18: LGTM! Key added consistently.

The new key "Add a personal note" has been added with an empty string value, ready for translation.

Would you like me to help provide the Norwegian translation for this string?

ghost/i18n/locales/ar/portal.json (1)

18-18: LGTM! Key added consistently.

The new key "Add a personal note" has been added with an empty string value, ready for translation. Since Arabic is a right-to-left (RTL) language, ensure the translation maintains proper RTL formatting when implemented.

Would you like me to help provide the Arabic translation for this string?

ghost/i18n/locales/vi/portal.json (1)

18-18: LGTM! Key added consistently.

The new key "Add a personal note" has been added with an empty string value, ready for translation.

Would you like me to help provide the Vietnamese translation for this string?

ghost/i18n/locales/it/portal.json (1)

1-216: Coordinate translations for the new donation personalization feature.

The new "Add a personal note" feature is missing translations in all localization files (ru, nl, da, bg, it). This will affect all non-English users trying to add personal notes to their donations.

Consider:

  1. Coordinating with translators to provide translations for all supported languages before releasing the feature
  2. Adding a translation tracking system to ensure new features maintain localization coverage
  3. Setting up a process to prevent merging new features without corresponding translations
ghost/i18n/locales/uk/portal.json (1)

18-18: Track translations for the new personal note feature.

The key "Add a personal note" has been added across all localization files but currently lacks translations in multiple languages. Consider creating a tracking issue to ensure all translations are provided before the feature is released.

Would you like me to create a tracking issue for gathering translations for the new personal note feature?

ghost/i18n/locales/sk/portal.json (1)

18-18: Add Slovak translation for the personal note field.

The new key "Add a personal note" is missing its Slovak translation. This could affect the user experience for Slovak users when making donations.

Would you like me to help create an issue to track the missing translations? This would help ensure all localization strings are properly translated before release.

ghost/i18n/locales/sr/portal.json (1)

18-18: Add Serbian translation for the personal note field.

The new key "Add a personal note" is missing its Serbian translation. This could affect the user experience for Serbian users when making donations.

Would you like me to help create an issue to track the missing translations? This would help ensure all localization strings are properly translated before release.

ghost/i18n/locales/ko/portal.json (1)

18-18: Add Korean translation for the personal note field.

The new key "Add a personal note" is missing its Korean translation. This could affect the user experience for Korean users when making donations.

Would you like me to help create an issue to track the missing translations? This would help ensure all localization strings are properly translated before release.

ghost/i18n/locales/fi/portal.json (1)

18-18: Add Finnish translation for the personal note field.

The new key "Add a personal note" is missing its Finnish translation. This could affect the user experience for Finnish users when making donations.

Would you like me to help create an issue to track the missing translations? This would help ensure all localization strings are properly translated before release.

ghost/i18n/locales/nn/portal.json (2)

18-18: Add Norwegian Nynorsk translation for the personal note field.

The new key "Add a personal note" is missing its Norwegian Nynorsk translation. This could affect the user experience for Norwegian users when making donations.

Would you like me to help create an issue to track the missing translations? This would help ensure all localization strings are properly translated before release.


1-216: Consider a coordinated localization update for the donation feature.

The addition of the "Add a personal note" feature across all localization files is currently missing translations. To ensure a consistent user experience across all supported languages, consider:

  1. Coordinating with translators to provide translations for all languages simultaneously
  2. Adding a default English fallback for missing translations
  3. Implementing string sanitization as mentioned in the PR objectives

To help track the progress of translations and ensure consistency, would you like me to help create a tracking issue that:

  1. Lists all affected language files
  2. Provides context about the donation feature
  3. Includes sanitization requirements
  4. Sets up a checklist for translation status
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 931ae33 and d9e7ac2.

📒 Files selected for processing (66)
  • apps/portal/src/components/pages/SupportPage.js (1 hunks)
  • apps/portal/src/utils/api.js (2 hunks)
  • ghost/i18n/locales/af/portal.json (1 hunks)
  • ghost/i18n/locales/ar/portal.json (1 hunks)
  • ghost/i18n/locales/bg/portal.json (1 hunks)
  • ghost/i18n/locales/bn/portal.json (1 hunks)
  • ghost/i18n/locales/bs/portal.json (1 hunks)
  • ghost/i18n/locales/ca/portal.json (1 hunks)
  • ghost/i18n/locales/context.json (1 hunks)
  • ghost/i18n/locales/cs/portal.json (1 hunks)
  • ghost/i18n/locales/da/portal.json (1 hunks)
  • ghost/i18n/locales/de-CH/portal.json (1 hunks)
  • ghost/i18n/locales/de/portal.json (1 hunks)
  • ghost/i18n/locales/el/portal.json (1 hunks)
  • ghost/i18n/locales/en/portal.json (1 hunks)
  • ghost/i18n/locales/eo/portal.json (1 hunks)
  • ghost/i18n/locales/es/portal.json (2 hunks)
  • ghost/i18n/locales/et/portal.json (1 hunks)
  • ghost/i18n/locales/fa/portal.json (1 hunks)
  • ghost/i18n/locales/fi/portal.json (1 hunks)
  • ghost/i18n/locales/fr/portal.json (1 hunks)
  • ghost/i18n/locales/gd/portal.json (2 hunks)
  • ghost/i18n/locales/he/portal.json (1 hunks)
  • ghost/i18n/locales/hi/portal.json (1 hunks)
  • ghost/i18n/locales/hr/portal.json (1 hunks)
  • ghost/i18n/locales/hu/portal.json (1 hunks)
  • ghost/i18n/locales/id/portal.json (1 hunks)
  • ghost/i18n/locales/is/portal.json (1 hunks)
  • ghost/i18n/locales/it/portal.json (1 hunks)
  • ghost/i18n/locales/ja/portal.json (1 hunks)
  • ghost/i18n/locales/ko/portal.json (1 hunks)
  • ghost/i18n/locales/kz/portal.json (1 hunks)
  • ghost/i18n/locales/lt/portal.json (1 hunks)
  • ghost/i18n/locales/lv/portal.json (1 hunks)
  • ghost/i18n/locales/mk/portal.json (1 hunks)
  • ghost/i18n/locales/mn/portal.json (1 hunks)
  • ghost/i18n/locales/ms/portal.json (1 hunks)
  • ghost/i18n/locales/ne/portal.json (1 hunks)
  • ghost/i18n/locales/nl/portal.json (1 hunks)
  • ghost/i18n/locales/nn/portal.json (1 hunks)
  • ghost/i18n/locales/no/portal.json (1 hunks)
  • ghost/i18n/locales/pl/portal.json (1 hunks)
  • ghost/i18n/locales/pt-BR/portal.json (1 hunks)
  • ghost/i18n/locales/pt/portal.json (1 hunks)
  • ghost/i18n/locales/ro/portal.json (1 hunks)
  • ghost/i18n/locales/ru/portal.json (1 hunks)
  • ghost/i18n/locales/si/portal.json (1 hunks)
  • ghost/i18n/locales/sk/portal.json (1 hunks)
  • ghost/i18n/locales/sl/portal.json (1 hunks)
  • ghost/i18n/locales/sq/portal.json (1 hunks)
  • ghost/i18n/locales/sr-Cyrl/portal.json (1 hunks)
  • ghost/i18n/locales/sr/portal.json (1 hunks)
  • ghost/i18n/locales/sv/portal.json (1 hunks)
  • ghost/i18n/locales/sw/portal.json (1 hunks)
  • ghost/i18n/locales/ta/portal.json (1 hunks)
  • ghost/i18n/locales/th/portal.json (1 hunks)
  • ghost/i18n/locales/tr/portal.json (1 hunks)
  • ghost/i18n/locales/uk/portal.json (1 hunks)
  • ghost/i18n/locales/ur/portal.json (1 hunks)
  • ghost/i18n/locales/uz/portal.json (1 hunks)
  • ghost/i18n/locales/vi/portal.json (1 hunks)
  • ghost/i18n/locales/zh-Hant/portal.json (1 hunks)
  • ghost/i18n/locales/zh/portal.json (1 hunks)
  • ghost/members-api/lib/controllers/RouterController.js (1 hunks)
  • ghost/payments/lib/PaymentsService.js (1 hunks)
  • ghost/stripe/lib/StripeAPI.js (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
ghost/i18n/locales/pt-BR/portal.json (1)
Learnt from: cathysarisky
PR: TryGhost/Ghost#22075
File: ghost/i18n/locales/pt-BR/portal.json:0-0
Timestamp: 2025-01-30T15:13:48.222Z
Learning: When reviewing translation files in i18n/locales/*, the keys (left side) must never be changed. If a translator has modified any keys, this should be flagged as a potential error requiring review or correction. Only the translation values (right side) should be modified.
ghost/i18n/locales/pt/portal.json (1)
Learnt from: cathysarisky
PR: TryGhost/Ghost#22075
File: ghost/i18n/locales/pt-BR/portal.json:0-0
Timestamp: 2025-01-30T15:13:48.222Z
Learning: When reviewing translation files in i18n/locales/*, the keys (left side) must never be changed. If a translator has modified any keys, this should be flagged as a potential error requiring review or correction. Only the translation values (right side) should be modified.
🪛 Biome (1.9.4)
ghost/i18n/locales/sl/portal.json

[error] 19-19: The key After a free trial ends, you will be charged the regular price for the tier you've chosen. You can always cancel before then. was already declared.

This where a duplicated key was declared again.

If a key is defined multiple times, only the last definition takes effect. Previous definitions are ignored.

(lint/suspicious/noDuplicateObjectKeys)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
🔇 Additional comments (23)
ghost/i18n/locales/ro/portal.json (2)

18-18: Add Romanian translations for new entries.

The following new entries have been added but are missing their Romanian translations:

  • "Add a personal note"
  • "Invalid email address"
  • "Jamie Larson"
  • "month"
  • "Thank you for your support"

Since these are user-facing strings, please verify the translations with a native Romanian speaker to ensure they convey the correct meaning and context.

Also applies to: 100-101, 108-108, 160-160


16-16: Add Romanian translations for error and success messages.

The following system messages are missing their Romanian translations:

  • "Account details updated successfully"
  • "Email newsletter settings updated"
  • "Subscription plan updated successfully"

Since these are important system feedback messages, please verify the translations with a native Romanian speaker to ensure they convey the correct meaning and context.

Also applies to: 61-61, 153-153

ghost/i18n/locales/lt/portal.json (2)

18-18: Verify the empty translation for the new donation-related string.

The new key "Add a personal note" has been added with an empty translation. This aligns with the PR objectives but needs Lithuanian translation.

Would you like me to help create an issue to track the missing translation for this key?


31-31: Add translations for new portal features.

New portal features have been added without Lithuanian translations:

  • "Change plan"
  • "Thank you for your support"

Would you like me to help create an issue to track these missing translations?

Also applies to: 160-160

ghost/i18n/locales/ca/portal.json (2)

142-142: Verify the status of error message translations.

The following strings appear with empty translations but were mentioned as removed in the summary:

  • "Signups from this email domain are currently restricted"
  • "This site only accepts paid members"
  • "Too many sign-up attempts, try again later"

Please clarify if these strings should be removed or translated.

#!/bin/bash
# Check if these strings exist in other language files
rg -l "Signups from this email domain are currently restricted" "ghost/i18n/locales/"
rg -l "This site only accepts paid members" "ghost/i18n/locales/"
rg -l "Too many sign-up attempts, try again later" "ghost/i18n/locales/"

Also applies to: 172-172, 181-181

Likely an incorrect or invalid review comment.


1-215: LGTM! Translation consistency is well maintained.

The file demonstrates good translation practices:

  • Consistent handling of placeholders
  • Proper Catalan language conventions
  • Clear and contextual translations
ghost/i18n/locales/sr-Cyrl/portal.json (1)

18-18: Add Serbian (Cyrillic) translation for the new "Add a personal note" string.

The translation is currently empty. This string is crucial for the donation feature as mentioned in the PR objectives.

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Check if other Cyrillic locale files have translations for this string
fd -e json -p 'locales/*-Cyrl' --exec rg -l '"Add a personal note":'

Length of output: 70


Provide Serbian (Cyrillic) translation for "Add a personal note"

The key "Add a personal note" in ghost/i18n/locales/sr-Cyrl/portal.json is currently an empty string. Our search in other Cyrillic locale files did not return any instance of this key with a non-empty translation, suggesting that a necessary translation may have been overlooked. Please update this entry with the appropriate Serbian (Cyrillic) translation to ensure consistency and proper functionality for the donation feature.

ghost/stripe/lib/StripeAPI.js (1)

519-523: LGTM! Parameter addition is well documented.

The new personalNoteText parameter is properly added to the method signature with appropriate JSDoc documentation.

ghost/i18n/locales/en/portal.json (1)

18-18: LGTM! Localization string added correctly.

The new string follows the file's format and maintains alphabetical ordering.

ghost/i18n/locales/ne/portal.json (1)

18-18: LGTM! Localization string added correctly.

The new string follows the file's format and maintains alphabetical ordering.

ghost/i18n/locales/eo/portal.json (1)

18-18: LGTM! Localization string added correctly.

The new string follows the file's format and maintains alphabetical ordering.

ghost/i18n/locales/mn/portal.json (1)

18-18: Translation needed for the new donation field string.

The new entry "Add a personal note" has been added correctly, but requires translation to Mongolian to maintain consistency with other localized strings.

ghost/i18n/locales/uz/portal.json (1)

18-18: Translation needed for the new donation field string.

The new entry "Add a personal note" has been added correctly, but requires translation to Uzbek to maintain consistency with other localized strings.

ghost/i18n/locales/zh/portal.json (1)

18-18: Translation needed for the new donation field string.

The new entry "Add a personal note" has been added correctly, but requires translation to Chinese to maintain consistency with other localized strings.

ghost/i18n/locales/zh-Hant/portal.json (1)

18-18: Translation needed for the new donation field string.

The new entry "Add a personal note" has been added correctly, but requires translation to Traditional Chinese to maintain consistency with other localized strings.

ghost/i18n/locales/ja/portal.json (1)

18-18: Translation needed for the new donation field string.

The new entry "Add a personal note" has been added correctly, but requires translation to Japanese to maintain consistency with other localized strings.

ghost/i18n/locales/th/portal.json (1)

18-18: Track missing translations for new feature.

The new key "Add a personal note" and several others are missing translations. Consider creating a tracking issue to ensure translations are added before the feature is released.

Run this script to find all missing translations:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Find all empty translations in the Thai localization file
jq -r 'to_entries | .[] | select(.value == "") | .key' ghost/i18n/locales/th/portal.json

Length of output: 2305


Missing Translations Identified in Thai Locale

The script output confirms that the new key "Add a personal note"—along with numerous other keys—has an empty translation in the file ghost/i18n/locales/th/portal.json. It’s advisable to create a tracking issue to monitor these missing translations and ensure they are updated before release.

  • Affected file: ghost/i18n/locales/th/portal.json
  • Example key: "Add a personal note" (and others as listed)
ghost/i18n/locales/id/portal.json (1)

18-18: Add translations for new UI strings.

The following keys are missing Indonesian translations:

  • "Add a personal note"
  • "Comment preferences updated."
  • "Email preferences updated."
  • "Signups from this email domain are currently restricted."
  • "Sorry, no recommendations are available right now."
  • "This site only accepts paid members."

Please provide translations to ensure a complete Indonesian localization.

Also applies to: 41-41, 63-63, 142-142, 144-144, 172-172

ghost/i18n/locales/tr/portal.json (1)

18-18: Add Turkish translation for personal note string.

The key "Add a personal note" is missing its Turkish translation. Please provide a translation to maintain consistency in the Turkish localization.

ghost/i18n/locales/gd/portal.json (1)

18-18: Add translations for new UI strings.

The following keys are missing Scottish Gaelic translations:

  • "Add a personal note"
  • "Signups from this email domain are currently restricted."
  • "Sorry, no recommendations are available right now."
  • "Too many sign-up attempts, try again later"

Please provide translations to ensure a complete Scottish Gaelic localization.

Also applies to: 142-142, 144-144, 181-181

ghost/i18n/locales/uk/portal.json (1)

18-18: Add translations for new UI strings.

The following keys are missing Ukrainian translations:

  • "Add a personal note"
  • "Comment preferences updated."
  • "Email preferences updated."
  • "Signups from this email domain are currently restricted."
  • "Sorry, no recommendations are available right now."
  • "This site only accepts paid members."
  • "Too many sign-up attempts, try again later"

Please provide translations to ensure a complete Ukrainian localization.

Also applies to: 41-41, 63-63, 142-142, 144-144, 172-172, 181-181

ghost/i18n/locales/fr/portal.json (1)

18-18: LGTM! French translation for "Add a personal note" is accurate.

The translation "Ajouter une note personnelle" correctly captures the meaning and maintains a natural French phrasing.

ghost/i18n/locales/context.json (1)

9-9: LGTM! Consider adding translations for other languages.

The new entry is well-formatted and correctly placed in alphabetical order. The context description clearly indicates its usage as a field label for donations in Stripe.

To ensure comprehensive internationalization support, please check if translations for this string need to be added to other language files. You can run this script to find all language files:

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Find all locale files to ensure translations are added
fd -e json . ghost/i18n/locales

Length of output: 13001


Locale Update: Verify Translations for “Add a personal note”

The new entry in ghost/i18n/locales/context.json is correctly formatted and placed. However, our search shows that the key “Add a personal note” has not yet been added to the other locale files. Please confirm whether translations for this new string should be added to the corresponding language files (e.g., in en, de, fr, etc.) to ensure comprehensive internationalization.

  • File Updated: ghost/i18n/locales/context.json
  • Remaining Task: Add or update the translated strings in the other locale files as needed.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d9e7ac2 and cefac3d.

📒 Files selected for processing (3)
  • ghost/i18n/locales/sl/portal.json (1 hunks)
  • ghost/members-api/lib/controllers/RouterController.js (1 hunks)
  • ghost/payments/lib/PaymentsService.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • ghost/payments/lib/PaymentsService.js
  • ghost/i18n/locales/sl/portal.json
🧰 Additional context used
🪛 ESLint
ghost/members-api/lib/controllers/RouterController.js

[error] 485-486: Missing semicolon.

(semi)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Lint

Comment on lines 481 to 488
const rawText = req.body.personalNoteText;
if (typeof rawText !== 'string' || rawText.length > 255) {
throw new BadRequestError({
message: 'Invalid personalNoteText, possibly an i18n error.'
})
}
options.personalNoteText = rawText ?? 'Add a personal note';
response = await this._createDonationCheckoutSession(options);
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 12, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance validation and sanitization for personalNoteText.

The current validation is a good start, but we should enhance it to prevent potential security issues and ensure proper i18n handling:

  1. Add HTML sanitization to prevent XSS attacks
  2. Add proper i18n support for the default text
  3. Fix the missing semicolon

Apply this diff to improve the implementation:

-            const rawText = req.body.personalNoteText;
-            if (typeof rawText !== 'string' || rawText.length > 255) {
-                throw new BadRequestError({
-                    message: 'Invalid personalNoteText, possibly an i18n error.'
-                })
-            }
-            options.personalNoteText = rawText ?? 'Add a personal note';
+            const rawText = req.body.personalNoteText ?? tpl('Add a personal note');
+            if (typeof rawText !== 'string') {
+                throw new BadRequestError({
+                    message: tpl(messages.badRequest),
+                    context: 'Personal note must be a string'
+                });
+            }
+            if (rawText.length > 255) {
+                throw new BadRequestError({
+                    message: tpl(messages.badRequest),
+                    context: 'Personal note cannot be longer than 255 characters'
+                });
+            }
+            // Sanitize HTML to prevent XSS attacks
+            const sanitizedText = sanitizeHtml(rawText, {
+                allowedTags: [],
+                allowedAttributes: {}
+            });
+            options.personalNoteText = sanitizedText;

Don't forget to add the import at the top of the file:

const sanitizeHtml = require('sanitize-html');
🧰 Tools
🪛 ESLint

[error] 485-486: Missing semicolon.

(semi)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This text should not be html. It's just plaintext, possibly with non-Latin characters.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cathysarisky Understood, I apologize for the confusion. You're right - since this is plaintext, we only need the basic string validation. Here's a simpler fix:

             const rawText = req.body.personalNoteText;
             if (typeof rawText !== 'string' || rawText.length > 255) {
                 throw new BadRequestError({
                     message: 'Invalid personalNoteText, possibly an i18n error.'
-                })
+                });
             }
-            options.personalNoteText = rawText ?? 'Add a personal note';
+            options.personalNoteText = rawText ?? tpl('Add a personal note');

✏️ Learnings added
Learnt from: cathysarisky
PR: TryGhost/Ghost#22175
File: ghost/members-api/lib/controllers/RouterController.js:0-0
Timestamp: 2025-02-12T20:38:55.802Z
Learning: The personalNoteText field in donation checkout is a plaintext field that may contain non-Latin characters, used as a field label in Stripe.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@cathysarisky cathysarisky changed the title fix untranslatable donation field string 🌐fix untranslatable donation field string Feb 21, 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.

Translation Request for Stripe Checkout (Tips & Donations): pt-BR
1 participant