Skip to content
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

Remove warning "No translation for appId "${appId}" have been registered" #572

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

ShGKme
Copy link
Contributor

@ShGKme ShGKme commented Jan 26, 2023

In 1.x translations registry was initialized in OC.L10N. The initialization includes defining global variables on script load: https://github.com/nextcloud/server/blob/352bd7ecea488201e4162e4e31a0cf9770cf20a0/core/src/OC/l10n-registry.js#L24-L26

// server/core/src/OC/l10n-registry.js 
window._oc_l10n_registry_translations = window._oc_l10n_registry_translations || {}
window._oc_l10n_registry_plural_functions = window._oc_l10n_registry_plural_functions || {}

After an update @nextcloud/l10n@2.0.0, the lib becomes independent from the server's OC.L10N. But it still required window._oc_l10n_registry_translations to be initialized and warned No OC L10N registry found.

In #556 it was fixed by defining window._oc_l10n_registry_translations on the first registration. But it also added a warning if there is no translation for an app No translation for appId "${appId}" have been registered.

The problem is that English translations often are not supposed to be registered. Instead, the translation keys are used. It results in tons of useless warnings in the console and impacts DX.

image

This PR:

  • Removes the warning at all and updates tests
  • Add console.warn mock in gettext tests to make testing silent

Signed-off-by: Grigorii Shartsev <grigorii.shartsev@nextcloud.com>
Signed-off-by: Grigorii Shartsev <grigorii.shartsev@nextcloud.com>
@ShGKme ShGKme added the bug Something isn't working label Jan 26, 2023
Copy link
Contributor

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

🧹 ✨

@ChristophWurst ChristophWurst merged commit 360326b into master Jan 26, 2023
@delete-merged-branch delete-merged-branch bot deleted the fix-registry-warnings branch January 26, 2023 12:43
@susnux susnux mentioned this pull request Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants