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

translate tag not properly updating #27

Closed
fyyyyy opened this issue Jun 22, 2017 · 9 comments
Closed

translate tag not properly updating #27

fyyyyy opened this issue Jun 22, 2017 · 9 comments

Comments

@fyyyyy
Copy link

fyyyyy commented Jun 22, 2017

I have an issue where the translate tag isnt updated when the transcluded content changes in a child component.


// doesn't work
<translate>
  <slot></slot>
</translate>

// works fine
<slot v-translate></slot>
@kemar
Copy link
Contributor

kemar commented Jun 22, 2017

I think that could be a slot misuse, see the Vue.js documentation.

Instead you should try something like this:

<slot>
  <translate>This will only be displayed if there is no content to be distributed.</translate>
</slot>

@kemar kemar closed this as completed Jun 22, 2017
@fyyyyy
Copy link
Author

fyyyyy commented Jun 22, 2017

Hmm from what i read, i can place the slot element anywhere in my child component ?
This is pretty much straight from the example.
Oh you mean a misuse of the translate component, as i am transducing a slot element and not plain text. 👍

@fyyyyy
Copy link
Author

fyyyyy commented Jun 22, 2017

<translate>Delete {{selected.count}} Users</translate>
This also will not update, i guess its a general issue that the content isnt watched, or is this intended ?

@kemar
Copy link
Contributor

kemar commented Jun 22, 2017

This can't work because instead of the "Mustache" syntax (double curly braces), you have to use %{ and } as noted in the documentation.

So instead of:

<translate>Delete {{selected.count}} Users</translate>

Use:

<translate>Delete %{ selected.count } Users</translate>

@fyyyyy
Copy link
Author

fyyyyy commented Jun 22, 2017

I tried this, it didnt update either

@fyyyyy
Copy link
Author

fyyyyy commented Jun 22, 2017

E.g. i have a feeling this should work in any child component. The variable is defined, and it renders the text but it does not translate it. Also when switching languages, it will always display the plain text.
<translate>%{ $slots.default[0].text }</translate>

this however works most of the time (not always though, it fails when many child instances change)
<translate>{{ $slots.default[0].text }}</translate>

Versions
"vue": "^2.3.3",
"vue-gettext": "^2.0.15",
"vue-router": "^2.3.1",
"vuex": "^2.3.1"

@fyyyyy
Copy link
Author

fyyyyy commented Jun 22, 2017

Ok i think i found the source of the first issue. If the translation is not found, the text never updates regardless of variable or tag content changes. Maybe this should throw a warning or something :)

@kemar
Copy link
Contributor

kemar commented Jun 22, 2017

There is a silent option that you can use in the configuration which enable or disable logs/warnings for missing translations and untranslated keys. The default default value is the same as Vue.config.silent.

Again, this is written in the documentation :)

@fyyyyy
Copy link
Author

fyyyyy commented Jun 22, 2017

oh crap, i had silent: true 🙈
Thanks for the help, I will send you some free miles for car2go 🚗

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