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

How can I add $t inside the js-code #287

Closed
voroncv opened this issue Jan 25, 2018 · 4 comments
Closed

How can I add $t inside the js-code #287

voroncv opened this issue Jan 25, 2018 · 4 comments

Comments

@voroncv
Copy link

voroncv commented Jan 25, 2018

I try to do it like this.$t('pages.datetime.today'), but it turns into a string and in the warning console Value of key 'pages.datetime.today' is not a string!

@lmiller1990
Copy link
Contributor

What is the type of today? a Date? You will probably need to make it into a string first, by using toISOString, etc.

Can you post the code?

@voroncv
Copy link
Author

voroncv commented Jan 26, 2018

Today is a simple string. Can you send an example of JavaScript code, how do I write this correctly?

@kazupon
Copy link
Owner

kazupon commented Mar 9, 2018

You can import VueI18n instance.

e.g. app generated with vue-cli:

src/i18n.js:

import VueI18n from 'vue-i18n'
import Vue from 'vue'

Vue.use(VueI18n)

export default new VueI18n({
  // ...
})

src/foo.js:

import i18n from './i18n'

console.log(i18n.t('foo.bar')

@kazupon kazupon closed this as completed Mar 9, 2018
@shailee-m
Copy link

How to pluralize here?

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

4 participants