Asset manager reports assets used only in a translation as not used

Open Beginner friendly
#2,376 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
angular, typescript
Domain
frontend

Research direction

Start in ProjectAssetService.calculateAssetUsage, which builds the text it searches from JSON.stringify(this.projectService.project) plus the thumbnail name and used text files. Look at how translation files (translations.<locale>.json) are loaded in the project service, and at ComponentAuthoringComponent.setComponent to see how translations are applied to a copy of the content. Done when an asset referenced only in a translation is no longer reported as unused, which you can check with a unit test on calculateAssetUsage that includes a translation file.

Written by the indexing model from the issue text.

Description

ProjectAssetService.calculateAssetUsage decides whether an asset is used by searching JSON.stringify(this.projectService.project) (plus the thumbnail name and used text files). Translations are stored separately in translations.<locale>.json, and the authoring tool applies them only to a copy of each component's content (ComponentAuthoringComponent.setComponent), so the project object never contains translated text.

As a result, an asset referenced only in a translation, for example an image with labels in another language inserted through the translation editor, is marked "(Not Used)" in the asset manager, next to its delete button, and counted in the unused total. Deleting it breaks the translated unit.

This is from reading the code; I have not reproduced it in a running instance.

A fix would add the content of each of the project's translation files to the text searched in calculateAssetUsage.

Dominant language
TypeScript
Stars
4
Forks
8
Avg merge
3d 8h
Merged PRs (30d)
12

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WISE-Community/WISE-Client

All issues in WISE-Community/WISE-Client

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.