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

i18n via t.bind fails to clear translated string when key becomes undefined #313

Open
peitschie opened this issue Feb 18, 2020 · 2 comments

Comments

@peitschie
Copy link

I'm submitting a bug report

  • Library Version:
    aurelia-i18n 3.0.0-beta.7

  • Webpack AND Version
    webpack 4.27.0
    webpack-cli 3.3.5

  • Browser:
    all

  • Language:
    TypeScript 3.1.2

Current behavior:
When using the t.bind syntax, translations will not be correctly cleared when bound value becomes undefined. Reproduction at: https://github.com/peitschie/bug-repro-aurelia-i18n-bind.

On initial load, model A is populated, which contains a valid i18n key for both line 1 and 2:
image

Clicking the Load model B button then causes the bound values to be replaced with a new model that only has the line 1 property defined:
image

Note that when using the t.bind syntax, the Model A line 2 translation cell is left bound.

This behaviour differs when the key is fed via the t value converter (see the last column in the table), which does correctly clear the translation of line 2 when the second model is loaded.

Expected/desired behavior:
I am expecting the behaviour of t.bind to match the behaviour seen for ${ key & t}. It seems logical to me that if the bound value is set to undefined or cleared, the translation should also be cleared to reflect the new model.

@zewa666
Copy link
Member

zewa666 commented Feb 18, 2020

The reason why it happens is simple, the problem is I can't recall why that was added ;) I'll need to dig up a bit

zewa666 added a commit that referenced this issue Feb 18, 2020
if the provided value is bound to a null or undefined property
the resulting value for translation should be an empty string

fixes issue #313
@zewa666
Copy link
Member

zewa666 commented Feb 18, 2020

PR is the works lets see this shouldn't hopefully take long to fix @peitschie. Love your nickname btw ;)

zewa666 added a commit that referenced this issue Feb 19, 2020
if the provided value is bound to a null or undefined property
the resulting value for translation should be an empty string

fixes issue #313
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

No branches or pull requests

2 participants