Skip to content

Prevent community mods from warning on unused translations in the common assets#21503

Merged
PunkPun merged 1 commit intoOpenRA:bleedfrom
RoosterDragon:lang-lint-bypass
Jul 28, 2024
Merged

Prevent community mods from warning on unused translations in the common assets#21503
PunkPun merged 1 commit intoOpenRA:bleedfrom
RoosterDragon:lang-lint-bypass

Conversation

@RoosterDragon
Copy link
Member

Currently when linting translations, we check for any unused translation keys. This works fine for the default mods, which own the entire sets of translation files. For community mods, they often import the translation files from the common mod assets, but they may only use some of the translations provided. Currently, they would get warnings about not using translations from the common files they have imported.

Since the community mods don't own those translations, getting warnings about it is annoying. To solve this issue, introduce a AllowUnusedTranslationsInExternalPackages in the mod.yaml which defaults to true. This will prevent reporting of unused translation keys from external assets. Keys that are used for external assets will still be validated, and keys from the mod assets will be both validated and unused keys will be reported.

We default the new flag to true and don't provide an update rule. This means community mods will get the new behaviour. For the default mods, we do want to check the "external" assets, since we control those assets. So the default mods have their mod.yaml updated to disable the flag and retain the existing behaviour of checking everything.


Fixes #20693

To test, add an unused translation key into e.g. mods\ra\languages\rules\en.ftl and another into mods\common\languages\rules\en.ftl.

When running the utility command ra --check-yaml, you will see two warnings reported - because for the default mods we still want to report on unused keys in common.

If you then update the mods\ra\mod.yaml to disable or remove the AllowUnusedTranslationsInExternalPackages entry and rerun the utility, you will see only the one warning reported from the ra file. This is the behaviour that community mods would get by default.

…mon assets

Currently when linting translations, we check for any unused translation keys. This works fine for the default mods, which own the entire sets of translation files. For community mods, they often import the translation files from the common mod assets, but they may only use some of the translations provided. Currently, they would get warnings about not using translations from the common files they have imported.

Since the community mods don't own those translations, getting warnings about it is annoying. To solve this issue, introduce a AllowUnusedTranslationsInExternalPackages in the mod.yaml which defaults to true. This will prevent reporting of unused translation keys from external assets. Keys that are used for external assets will still be validated, and keys from the mod assets will be both validated and unused keys will be reported.

We default the new flag to true and don't provide an update rule. This means community mods will get the new behaviour. For the default mods, we do want to check the "external" assets, since we control those assets. So the default mods have their mod.yaml updated to disable the flag and retain the existing behaviour of checking everything.
@pchote
Copy link
Member

pchote commented Jul 27, 2024

Approach looks sensible to me in the short-mid term.

In the longer term we need to move the Packages definition into mod code so that mods (specifically TDHD) can customise package loading. At this point we can replace FileSystem.IsExternalFile with more specific and per-package annotations (e.g. ApplyUpgradeRules, IgnoreUnusedTranslations).

Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

LGTM, should be tested with an SDK mod

@PunkPun PunkPun merged commit bd809e5 into OpenRA:bleed Jul 28, 2024
@PunkPun
Copy link
Member

PunkPun commented Jul 28, 2024

changelog

@RoosterDragon RoosterDragon deleted the lang-lint-bypass branch July 29, 2024 17:19
@PunkPun PunkPun mentioned this pull request Oct 3, 2024
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.

Fix unused translation strings in community mods producing warnings

3 participants