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

Why the way of 'this.$t() used in data ' binding can't auto change when click the switch btn #271

Closed
lilywang711 opened this Issue Jan 9, 2018 · 9 comments

Comments

Projects
None yet
7 participants
@lilywang711
Copy link

lilywang711 commented Jan 9, 2018

vue & vue-i18n version

ex: ^2.5.2, ^7.3.4

Reproduction Link

问题描述: 在data中通过this.$t()绑定的方式,切换语言时不会主动变化
在data中绑定vue-i18n的值
image
中英文的key
image

Steps to reproduce

What is Expected?

期待的是,切换英文时,下面表格的表头会切换成英文
image

What is actually happening?

实际上,通过这种方式绑定的,切换时,不会实时更新成英文,必须得刷新页面才可以
请问,有什么办法可以让这种方式也可以 自实时更新吗

@lilywang711 lilywang711 changed the title This.$t() binding is used in data to change the language without active change. Why the way of 'this.$t() used in data ' binding can't auto change when click the switch btn Jan 11, 2018

@kazupon

This comment has been minimized.

Copy link
Owner

kazupon commented Jan 23, 2018

Thank you for your feedback.
Sorry, i cannot speak chinese.
I hope you'll speak in english. 🙏

@GreedyPirate

This comment has been minimized.

Copy link

GreedyPirate commented Feb 1, 2018

I hava the same problem, too, when I define a variable in Vue data funciton like this
data() { return { text: this.$t('lang.name') } }
then I change the locale by a button click event
this.$i18n.locale = 'zh'
however the 'text' did not change it's value

@ding-js

This comment has been minimized.

Copy link

ding-js commented Feb 5, 2018

same problem.
this.$t in data not work when changed this.$i18n.locale
Here is problem demo

@WillieYang

This comment has been minimized.

Copy link

WillieYang commented Feb 23, 2018

I do have same problem too.

If I use this.$("data") in data property and then assign it to a value which would be used in the corresponding template, it would not be changed automatically when I click the switch locale button (this button is used to change the value of locale by this.$i18n.locale).

And the most weird part is that, when I change the value of locale manually, the data on the webpage would be changed automatically, such weird...

@GreedyPirate

This comment has been minimized.

Copy link

GreedyPirate commented Feb 28, 2018

@kazupon need your help

@kazupon

This comment has been minimized.

Copy link
Owner

kazupon commented Mar 1, 2018

sorry, my job work is very busy. 🙇
Please wait 🙏

@vBandiTv

This comment has been minimized.

Copy link

vBandiTv commented Mar 14, 2018

Here is an example of the problem:
https://codesandbox.io/s/z2nwwnw9px

@kazupon kazupon closed this in d007ac8 Mar 16, 2018

@kazupon kazupon added tips and removed need more repro labels Mar 16, 2018

@kazupon

This comment has been minimized.

Copy link
Owner

kazupon commented Mar 16, 2018

this is not problem of vue-i18n.
see the d007ac8

@LeonWuV

This comment has been minimized.

Copy link

LeonWuV commented Dec 18, 2018

I have same problem too, and i solved it with this way.

wrong way:

1545126803 1
1545126878 1

right way:

1545126929 1
1545126846 1

Hope I can help you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment