question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding translations directly to store

See original GitHub issue

I’d like to use a single file to handle all of my translations similarly to below but I found that I need to import and use Vue.i18n.add('en', english) on my root Vue instance instead of just being able to add them to the store. Is there a way around this?

I’d like to have something like below.

import Vue from 'vue';
import Vuex from 'vuex';

import english from './translations/english.json';
import german from './translations/german.json';
import french from './translations/french.json';

const debug = process.env.NODE_ENV !== 'production';

const store = new Vuex.Store({
    strict: debug
});

// Add translations directly to the application
Vue.i18n.add('en', english);
Vue.i18n.add('ge', german);
Vue.i18n.add('fr', french);

// Set the start locale to use
Vue.i18n.set('en');

export default store;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tikiatuacommented, Jun 22, 2017

Hi @OmgImAlexis,

I finally got around to look into this issue.

We actually apply some transformations to the locale data to flatten the information. This is done in the function flattenTranslations in vuex-i18n-store.js. We could export this function from the package to let you flatten the translation data on your own and then just set it on the store directly.

1reaction
tikiatuacommented, May 24, 2017

Aha. Now I understand. I will look into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Translating and localizing your store - Shopify Help Center
You can translate the content of your online store by adding your own translations using CSV files, or by using a compatible third-party...
Read more >
Translate and localize your app - Play Console Help
Open Play Console and go to Main store listing page (Grow > Store presence > Main store listing). At the top of the...
Read more >
How to Translate Your Shopify Store in 4 Easy Steps - OneSky
Shopify makes it pretty easy to integrate your translations. Under Settings > Languages, you just choose the languages you want to add, and...
Read more >
How to add multiple languages to Shopify - Weglot
The easiest and most complete way to translate your Shopify store is to use a multi-language translation app. You won't need to duplicate...
Read more >
Creating a Multilingual WooCommerce Store [Ultimate Guide]
TranslatePress lets you translate your entire WordPress multilingual site, directly from the front-end, using a super intuitive visual ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found