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

Translating plural statements, lack of documentation #64

Open
jonasgroendahl opened this issue Jan 18, 2018 · 3 comments
Open

Translating plural statements, lack of documentation #64

jonasgroendahl opened this issue Jan 18, 2018 · 3 comments

Comments

@jonasgroendahl
Copy link

jonasgroendahl commented Jan 18, 2018

Hello!

So far I have not been able to translate plural statements like for example:
$t('{count} car ::: {count} cars', {count: count},count)

How should my key-value pair look in the translation variable? I can't seem to find any information on this in the documentation. This is how my translation variable from English to Danish would initially look by looking at the docs, but nothing is being translated:

const da = {
  "{count} cars" : "{count} biler",
  "{count} car" : "{count} bil",
}
@jonasgroendahl
Copy link
Author

OK after a few hours at trying different stuff, i tried the following which worked:

const da = {
 "{count} car ::: {count} cars" : "{count} bil ::: {count} biler"
}

Hope this is useful to anyone

@tikiatua
Copy link
Member

Hi @jonasgroendahl

Apparently the description in the readme is not very clear. I will update the description in the coming days.

// using the translation directly (as specified in the current readme)
{{ $t('You have {count} new message ::: You have {count} new messages', {count: 5}, 5) }}

// using a key to lookup the translations
{{ $t('mykey', {count: 5}, 5) }}

const translations {
  'mykey': 'You have {count} new message ::: You have {count} new messages'
}

// alternative specification with array for translations
const translations {
  'mykey': [
    'You have {count} new message',
    'You have {count} new messages'
  ]
}

Hope this clarifies things for now.

@The-BlackWidow
Copy link

Hi @tikiatua

Is it possible to add the 0 option ? Meaning having apple: [ 'no apples', 'one apple', '{count} apples' ] ?

Thank you

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

No branches or pull requests

3 participants