-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(core): Make Asset entity translatable #4171
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
base: minor
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
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. Comment |
0f22f9c to
a0c1477
Compare
a0c1477 to
9553682
Compare
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]>
9553682 to
6beed3e
Compare
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]>
|



Description
Makes the Asset entity translatable, allowing asset names to be localized per language.
Changes
Core (
packages/core)New Entity:
AssetTranslation- Translation entity withnameandcustomFieldscolumnsEntity Updates:
Asset- Now implementsTranslatableinterface withtranslationsrelationcustom-entity-fields.ts- AddedCustomAssetFieldsTranslationclassService Updates:
AssetService- Updated to useTranslatableSaverfor handling translation persistenceTranslationDiffer- Fixed to setbaseIddirectly on new translations for proper foreign key persistenceGraphQL Schema:
languageCodeandtranslationsfields toAssettypeAssetTranslationtypeAssetTranslationInputinput typetranslationsfield toCreateAssetInputandUpdateAssetInputDashboard (
packages/dashboard)assets.graphql.ts- Updated mutation to return full Asset fragment including translationstranslatable-form-field.tsx- Fixed to useuseFormContext().watch()for reactive form values and added key prop for proper Controller remounting on language changeBreaking changes
None - This is backwards compatible. Assets without translations will use the default channel language.
Screenshots
N/A
Checklist
📌 Always:
👍 Most of the time: