Skip to content

Conversation

@biggamesmallworld
Copy link
Collaborator

@biggamesmallworld biggamesmallworld commented Jan 28, 2026

Description

Makes the Asset entity translatable, allowing asset names to be localized per language.

Changes

Core (packages/core)

New Entity:

  • AssetTranslation - Translation entity with name and customFields columns

Entity Updates:

  • Asset - Now implements Translatable interface with translations relation
  • custom-entity-fields.ts - Added CustomAssetFieldsTranslation class

Service Updates:

  • AssetService - Updated to use TranslatableSaver for handling translation persistence
  • TranslationDiffer - Fixed to set baseId directly on new translations for proper foreign key persistence

GraphQL Schema:

  • Added languageCode and translations fields to Asset type
  • Added AssetTranslation type
  • Added AssetTranslationInput input type
  • Added translations field to CreateAssetInput and UpdateAssetInput

Dashboard (packages/dashboard)

  • assets.graphql.ts - Updated mutation to return full Asset fragment including translations
  • translatable-form-field.tsx - Fixed to use useFormContext().watch() for reactive form values and added key prop for proper Controller remounting on language change

Breaking changes

None - This is backwards compatible. Assets without translations will use the default channel language.

Screenshots

N/A

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

@vercel
Copy link

vercel bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
vendure-storybook Ready Ready Preview, Comment Jan 29, 2026 1:47pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@biggamesmallworld biggamesmallworld force-pushed the fix/asset-translation-persistence branch from 0f22f9c to a0c1477 Compare January 28, 2026 16:30
@biggamesmallworld biggamesmallworld changed the title fix(core,dashboard): Fix asset translation persistence and language switching feat(core): Make Asset entity translatable Jan 28, 2026
@biggamesmallworld biggamesmallworld force-pushed the fix/asset-translation-persistence branch from a0c1477 to 9553682 Compare January 29, 2026 08:36
This commit makes the Asset entity translatable by:

1. Adding AssetTranslation entity with name and customFields
2. Updating Asset entity to implement Translatable interface
3. Updating AssetService to use TranslatableSaver for translation handling
4. Adding translations input to CreateAssetInput and UpdateAssetInput
5. Updating GraphQL schema to expose translations on Asset type
6. Fixing TranslationDiffer to set baseId for proper foreign key persistence
7. Fixing dashboard TranslatableFormField to properly handle language switching

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit fixes several issues with the translatable Asset entity:

- Fix translateLeaf to wrap translateEntity calls in try-catch, preventing
  errors when nested translatable relations have no translations
- Fix createAssetInternal to save the Asset first, then create translations
  with the proper base relationship set
- Fix entity-hydrator to automatically include .translations relations
  for translatable entities during hydration
- Fix importer to pass RequestContext when creating variant assets
- Add 'assets.asset' relation to hydration test plugin

Relates to commit 6beed3e (feat(core): Make Asset entity translatable)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add asset.translations join in getEntityAssets query to ensure
  translations are loaded when querying assets through Products
- Update custom-fields tests to include languageCode in expected
  Asset scalarFields (Asset is now translatable)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…tibility

The test was asserting array elements in a specific order, but
PostgreSQL returns channels in a different order than SQLite.
Added .sort() to ensure consistent comparison across databases.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sonarqubecloud
Copy link

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.

2 participants