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

List of available locales #66

Closed
arthurvasconcelos opened this issue Jan 25, 2018 · 2 comments
Closed

List of available locales #66

arthurvasconcelos opened this issue Jan 25, 2018 · 2 comments
Labels

Comments

@arthurvasconcelos
Copy link

This is more a suggestion/request than a issue.

Would be nice to have a method that allow me to get all available locales.

$i18n.locales(); | $i18n.getLocales(); | $i18n.list();
> ['en', 'en-US', 'pt-BR']
@tikiatua
Copy link
Member

tikiatua commented Jan 26, 2018

Hi @arthurvasconcelos,

Thank you for your feedback. I added the method as $i18n.locales() in the version 1.10.5. An example is given in the test repository.

Please keep in mind that this is a method that will be invoked on every render cycle. To make use of vue's caching system I would recommend to create a getter method or computed property like this.

locales() {
  return Object.keys(this.$store.state.i18n.translations);
}

The translate method ($t) is also run in every render cycle, not sure if we can find a better solution in the future that will make use of the caching functionality.

@tikiatua tikiatua added the fixed label Jan 26, 2018
@arthurvasconcelos
Copy link
Author

Thanks @tikiatua! Great lib you have here!

@tikiatua tikiatua closed this as completed Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants