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

fix(directive): prevent infinite update for missing translation #1282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Grolleau
Copy link

@Grolleau Grolleau commented Jan 8, 2021

No description provided.

@Grolleau
Copy link
Author

Grolleau commented Jan 8, 2021

Fixes #1281

@Grolleau Grolleau changed the title fix(core): prevent infinite update for missing translation (#1281) fix(core): prevent infinite update for missing translation Jan 8, 2021
@Grolleau Grolleau changed the title fix(core): prevent infinite update for missing translation fix(directive): prevent infinite update for missing translation Jan 19, 2021
Copy link

@zubSero zubSero left a comment

Choose a reason for hiding this comment

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

This should work. I tested it locally and it stopped the endless loop.

@hthetiot
Copy link

This solve major performance issues we have, since we use Gettext approach and our english key are the same has our translation, the missing translation was triggered causing this infinit render.

@korjikk
Copy link

korjikk commented Oct 5, 2022

Hi! Is there any specific reason this hasn't been merged yet?

@hthetiot
Copy link

hthetiot commented Oct 5, 2022

We used patch-package to fix this issue on our side, until this PR get merge.

  1. npm i patch-package --dev
  2. Add "postinstall": "patch-package" to "scripts" in package.json
  3. Create "patches/@ngx-translate+core+14.0.0.patch" file with following content:
diff --git a/node_modules/@ngx-translate/core/esm2020/lib/translate.directive.mjs b/node_modules/@ngx-translate/core/esm2020/lib/translate.directive.mjs
index 869a40f..56a12e1 100644
--- a/node_modules/@ngx-translate/core/esm2020/lib/translate.directive.mjs
+++ b/node_modules/@ngx-translate/core/esm2020/lib/translate.directive.mjs
@@ -99,9 +99,9 @@ export class TranslateDirective {
             }
             this.lastParams = this.currentParams;
             let onTranslation = (res) => {
-                if (res !== key) {
+                //if (res !== key) {
                     node.lastKey = key;
-                }
+                //}
                 if (!node.originalContent) {
                     node.originalContent = this.getContent(node);
                 }
diff --git a/node_modules/@ngx-translate/core/fesm2015/ngx-translate-core.mjs b/node_modules/@ngx-translate/core/fesm2015/ngx-translate-core.mjs
index eda8ca6..fdc69da 100644
--- a/node_modules/@ngx-translate/core/fesm2015/ngx-translate-core.mjs
+++ b/node_modules/@ngx-translate/core/fesm2015/ngx-translate-core.mjs
@@ -780,9 +780,9 @@ class TranslateDirective {
             }
             this.lastParams = this.currentParams;
             let onTranslation = (res) => {
-                if (res !== key) {
+                //if (res !== key) {
                     node.lastKey = key;
-                }
+                //}
                 if (!node.originalContent) {
                     node.originalContent = this.getContent(node);
                 }
diff --git a/node_modules/@ngx-translate/core/fesm2020/ngx-translate-core.mjs b/node_modules/@ngx-translate/core/fesm2020/ngx-translate-core.mjs
index b8e86ec..a85f71c 100644
--- a/node_modules/@ngx-translate/core/fesm2020/ngx-translate-core.mjs
+++ b/node_modules/@ngx-translate/core/fesm2020/ngx-translate-core.mjs
@@ -778,9 +778,9 @@ class TranslateDirective {
             }
             this.lastParams = this.currentParams;
             let onTranslation = (res) => {
-                if (res !== key) {
+                //if (res !== key) {
                     node.lastKey = key;
-                }
+                //}
                 if (!node.originalContent) {
                     node.originalContent = this.getContent(node);
                 }

Enjoy English to English and missing translation without redraw.

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.

None yet

4 participants