Skip to content

Conversation

@ciiay
Copy link
Member

@ciiay ciiay commented Sep 15, 2025

Hey, I just made a Pull Request!

For RHIDP-8763.

PR Summary: I18n Scripts Enhancement and Translation Sync Fix

  1. Added scripts to collect and upload translation reference JSON files to TMS project

    • New two-step workflow: generate JSON files, then push to TMS
    • Legacy single-step upload maintained for backward compatibility
  2. Added scripts to download and sync translations with received translation files

    • Download with human-readable filenames instead of job IDs
    • Automatic deployment to correct plugin directories
    • Robust sync from JSON to TypeScript with syntax validation
  3. Added utility scripts for translation workflow management

    • Backup file cleanup and management
    • Translation file deployment automation
    • Enhanced caching to prevent duplicate downloads
  4. Fixed critical path resolution issue in i18n configuration

    • Resolved "No such file or directory" errors when running scripts
    • Improved script sourcing reliability across different execution contexts
  5. Enhanced translation sync algorithm to prevent file corruption

    • Fixed duplicate key errors in TypeScript translation files
    • Improved string escaping for special characters and template variables
    • Added syntax validation to catch corruption early
  6. Added comprehensive documentation for i18n scripts

    • Complete workflow guide with setup instructions
    • Quick reference guide for daily use
    • Troubleshooting section with common issues and solutions
  7. Updated package.json with new i18n commands

    • Added yarn scripts for all new workflow steps
    • Included help commands for each script
  8. Updated French translation TypeScript files in global-header plugin

    • Fixed corrupted translation file with duplicate keys
    • Applied proper translations from TMS
  9. Added .gitignore entries for translation backup files

    • Prevents temporary .bak files from being committed

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

Testing Guide: I18n Scripts Workflow

Prerequisites

  • Set up TMS credentials per team guide
  • Confirm the TMS project ID, and update i18n.config.sh coordinately
image
  • Run from repo root

Quick Test Steps

1. Generate and upload JSON files

yarn i18n-generate
ls ui-i18n/1.8/  # Verify JSON files created

yarn i18n-push   # Upload to TMS

⚠️ Note: If testing creates duplicate files in TMS, please delete them after testing

2. Download and sync translations

yarn i18n-download  # Downloads with human-readable names
yarn i18n-deploy    # Deploy to plugin directories
yarn i18n-sync      # Sync JSON → TypeScript

3. Verify quality

# Check syntax and no duplicates
node -c workspaces/global-header/plugins/global-header/src/translations/fr.ts
grep -c "'" workspaces/global-header/plugins/global-header/src/translations/fr.ts | grep -v "duplicate"

4. Test cleanup

yarn i18n-cleanup --dry-run --translations-only

5. Verify app runs

cd workspaces/global-header && yarn start

Success Criteria

  • ✅ JSON files generate without path errors
  • ✅ Translation sync creates valid TypeScript with no duplicate keys
  • ✅ App starts without translation errors
  • ✅ Cleanup utilities work safely

Key Fixes Validated

  • Path resolution works from any directory
  • No duplicate keys in synced translation files
  • Special characters and {{variables}} preserved correctly

@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Sep 15, 2025

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-adoption-insights-common
  • @red-hat-developer-hub/backstage-plugin-quickstart

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
backend workspaces/adoption-insights/packages/backend none v0.0.0
@red-hat-developer-hub/backstage-plugin-adoption-insights-common workspaces/adoption-insights/plugins/adoption-insights-common none v0.4.0
@red-hat-developer-hub/backstage-plugin-quickstart workspaces/quickstart/plugins/quickstart none v1.6.2

@ciiay
Copy link
Member Author

ciiay commented Sep 17, 2025

/retest

@ciiay ciiay closed this Sep 17, 2025
@ciiay ciiay reopened this Sep 17, 2025
@jrichter1
Copy link
Contributor

The tests are getting stuck when running a template. Instead of showing the run summary it ends up on a 404 page
image

This doesn't seem to happen on main, we tried #1460. I'm guessing it's the new dependencies somehow messing up backstage for the tests.

@HusneShabbir HusneShabbir mentioned this pull request Sep 17, 2025
3 tasks
# --- Helper functions from original script -----------------------------------
source_ts_files() {
local repo_dir="$1"
find "$repo_dir" -path "*/src/translations/ref.ts" -type f
Copy link
Member

Choose a reason for hiding this comment

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

In this rhdh-plugins repo four plugins uses ref.tsand lightspeed plugin uses translationRef, since we own this repo we can rename that file to ref.ts in lightspeed plugin but in backstageconsistently usestranslation.ts as the filename and community-plugins may have different naming as well (especially this is contributed from the community), we need to come up with a strategy to cover all the scenarios to avoid missing some plugins.

@ciiay ciiay force-pushed the rhidp-8763-add-i18n-scripts branch 2 times, most recently from 3d70a1f to aaaf49c Compare September 18, 2025 01:33
Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @jrichter1 @HusneShabbir , I have verified when I remove changes in this file the e2e tests will pass. But when I remove these two dependencies, I got another CI failure as following

✘  https://google.com/#q=%40backstage%2Fno-undeclared-imports

     @backstage/backend-plugin-api must be declared in dependencies of packages/backend/package.json, run 'yarn --cwd packages/backend add @backstage/backend-plugin-api' from the project root                         


     src/extensions/PermissionPolicyExtension.ts:16:1
     14 |  * limitations under the License.
     15 |  */
   > 16 | import { createBackendModule } from '@backstage/backend-plugin-api';
        | ^
     17 | import {
     18 |   PolicyDecision,
     19 |   isPermission,

  ✘  https://google.com/#q=%40backstage%2Fno-undeclared-imports

     @backstage/plugin-scaffolder-backend-module-github must be declared in dependencies of packages/backend/package.json, run 'yarn --cwd packages/backend add @backstage/plugin-scaffolder-backend-module-github' from the project root                                                                                           


     src/index.ts:24:13
     22 | backend.add(import('@backstage/plugin-proxy-backend'));
     23 | backend.add(import('@backstage/plugin-scaffolder-backend'));
   > 24 | backend.add(import('@backstage/plugin-scaffolder-backend-module-github'));
        |             ^
     25 | backend.add(import('@backstage/plugin-techdocs-backend'));
     26 | 
     27 | // auth plugin

✘ 2 problems (2 errors, 0 warnings)

When the PermissionPolicyExtension.ts got introduced, there were these two dependencies in the backend package.json, and the PR got merged. But now these two dependencies got removed from the package.json somehow and that's why it won't fail the e2e tests in main branch. Not sure why the PR didn't get the lint error when removing these two dependencies required in PermissionPolicyExtension.ts.

@karthikjeeyar I see you added this PermissionPolicyExtension.ts, do you see a workaround to avoid both ci failures?

Copy link
Member

@karthikjeeyar karthikjeeyar Sep 18, 2025

Choose a reason for hiding this comment

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

Try removing the typescript dependancy in the root level package.json or match it with the typescript version used elsewhere in the project to see if that fixes this issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've found that if you simply add all the mentioned dependencies, everything works fine. The moment you do a yarn dedupe, the problem starts to appear. In other words, it's the yarn.lock file, rather than the new dependencies causing this. Essentially, the choice is which CI check is going to fail (tests or the lockfile check).

Now the question is, will this have any implications outside just running this plugin using yarn start?
If not, then the tests don't even need to wait for the template result screen, as long as the insights event triggers.

"prettier": "^3.4.2",
"semver": "^7.7.2"
"semver": "^7.7.2",
"typescript": "^5.9.2"
Copy link
Member

@karthikjeeyar karthikjeeyar Sep 18, 2025

Choose a reason for hiding this comment

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

I doubt if this mismatched typescript version in the root level is causing some ci failures in this PR, in main-branch there no e2e-tests and lint errors are observed.

@ciiay ciiay force-pushed the rhidp-8763-add-i18n-scripts branch 2 times, most recently from 65f5c59 to 96617ca Compare September 30, 2025 20:03
@ciiay ciiay force-pushed the rhidp-8763-add-i18n-scripts branch from 664e527 to dfefb7b Compare October 2, 2025 03:39
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions bot added the stale label Oct 16, 2025
@ciiay ciiay force-pushed the rhidp-8763-add-i18n-scripts branch from dfefb7b to d2d416b Compare October 22, 2025 17:18
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
6.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-actions github-actions bot removed the stale label Oct 22, 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