What are the most effective strategies for multilingual support in Vue using i18N with

Just starting out with VueJS and I'm venturing into creating a SAP website that supports multiple languages. The helper plugin Vue-I18n seems to be helping me out:

Vue-I18n

I've been following this example:

vue-i18n/example/locale/src/App.vue

Everything is working fine, but I'm now wondering how I can make the language available across multiple components or pages. Is using a store like Vuex necessary for this?

Answer ā„–1

Following these steps proved to be successful.

Main.js:

import Vue from 'vue';
import router from '@/router';
import { store } from '@vue/store/index.js';
import i18n from '@vue/i18n.js'
import App from '@vue/components/App.vue';
Vue.config.productionTip = false;


new Vue({
    store,
    i18n,
    router,
    render: h => h(App),
}).$mount(`#app`);

@vue/i18n.js:

import Vue from 'vue'
import VueI18n from 'vue-i18n'
import fr from '../json/fr.json';
import en from '../json/en.json';

Vue.use(VueI18n);

const conf = {
    locale: 'fr',
    fallbackLocale: 'fr',
    messages : {   
        fr: fr,
        en: en
    }
}

const i18n = new VueI18n(conf)

export default i18n

You may not have the same JSON files, so there is no need for format and populateTexts.

Answer ā„–2

Even if the hour is advanced: 1- Incorporating this package into a project ensures its accessibility across all components and pages. 2- While utilizing the store is optional, it serves as a data hub that simplifies data organization and management.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The functionality of aggregation is currently experiencing issues when used in conjunction with the $geoNear

I encountered a strange issue while using the aggregate function with this pipeline: [ { $geoNear: { near: [6.0950994999999999, 49.8914114000000026], distanceField: 'distance', }, }, ] When I call the aggregate function, ...

Tabulator: the process of loading an extensive amount of data requires a significant amount of time

Currently, I am encountering an issue with loading data using a tabulator on my webpage. There are 38 tables that need to be populated, each containing approximately 2000 rows of data. The problem lies in the fact that it is taking an excessive amount of t ...

Handling AJAX requests using jQuery

I'm currently in the process of learning how to utilize jQuery Ajax. Could you explain to me the significance of function(response), as well as what exactly is meant by response == 1 and response == 2? jQuery.post(ajaxurl, data, function(response) { ...

Toggle between bold and original font styles with Javascript buttons

I am looking to create a button that toggles the text in a text area between bold and its previous state. This button should be able to switch back and forth with one click. function toggleTextBold() { var isBold = false; if (isBold) { // Code t ...

Tips on concealing the loading image once the d3 chart has finished loading

$(document).on('click', '.tbtn', function(e) { $('#loading-image').show(); if(error){ $('loading-image').hide(); else{ val = $('.barbtn input:checked').val(); draw_summary($.parseJS ...

Convert js.executeAsyncScript result into a Map with key-value pairs of strings

Trying to convert the output of the script below into a Map<string,string>, but encountering an error that says "java.lang.String cannot be cast to java.util.Map". How can I successfully cast it as a map? final JavascriptExecutor js = (Ja ...

Occasional issue with the drop down menu not appearing correctly

I'm experiencing some difficulties with displaying a dropdown menu. Check out the fiddler link for reference: http://jsfiddle.net/GxrSk/ Below is the simplified HTML code: <nav> <ul id="top-menu"> <li class="parent"> ...

Bringing node.js variables into a database

I need help with the code I have written. It seems to be working but instead of updating the database with the actual result from a Node.js variable, it is inputting the string "$var". Can someone assist me with this issue? Thank you. var TOTP = require( ...

Angular Application for Attaching Files to SOAP Service

I am currently utilizing soap services to pass XML data along with file attachments. While SoapUI tool works perfectly for this purpose, I want to achieve the same functionality through Angular6 in my project. Below is a snippet of my Xml code. <soap ...

Creating a serialized version of a string to be transmitted

Here is the code snippet I am working with: var serializeValues =$(this).find("input[type='hidden']).not('.table-element').serialize(); The Value: martial_status=%D0%B6%D0%B5%D0%BD%D0%B0%D1%82+(%D0%B7%D0%B0%D0%BC%D1%83%D0%B6%D0%B5%D0 ...

Discovering Route modifications with Nuxt and asyncData: a step-by-step guide

Hey everyone, Iā€™m currently working on tracking route changes in my Nuxt.js app. Here is the middleware I have: export default function ({ route }) { return route; //but I'm not sure what to write here } index.vue File middleware: [route ...

What is the best way to conceal an element within my specific situation?

Attempting to utilize Angular JS to control the data-toggle = 'collapse'. The setup looks like this: <a href="#" ng-click="clickMe()" <div id="wrapper" data-toggle="collapse" data-target="#test"> texts and elements... & ...

Formatting the Return Values of Ionic Select

Having an issue with Ionic 3. Using an <ion-select> element with ngModel="x". When attempting to display the value in the console, it shows with extra spaces and line breaks. I tried replacing line breaks with 'e' and spaces with 'a&ap ...

Improving code efficiency for checkboxes in upcoming TypeScript versions

Is it possible to create a single checkbox component and dynamically pass different values to it without repeating code? I have set up these checkboxes to help me check the maximum and minimum values of some API data. const[checkValMax, setCheckValMax]= u ...

Ways to bring GIFs into NextJS

I am currently working on my portfolio website using Nextjs and I would like to incorporate gifs into the site. However, I have been struggling to figure out how to do so. Below is the code that I have been working with: https://i.stack.imgur.com/zjoiD.pn ...

Flattening an array of Map in Typescript involves combining all the

I am working with an array containing entries of type Map<string, number> Is there a way to flatten this array into a single map? Map<string, number>[] converted to Map<string, number> Appreciate any help on this matter. ...

The dropdown feature in Safari fails to collapse when an option is selected

I've encountered an issue with my code using Bootstrap 4 and it's functioning correctly on IE 11 and Firefox, but not on Safari for Mac. The content remains hidden when selecting an option from the dropdown menu in Safari. My intention is to hid ...

How can I modify the base color of a cone in Three.js?

My cone in the jsfiddle link is currently all blue, but I want to change the color of the square base to red. To do that, I need to alter the color of the two faces that make up the square base. How can this be achieved? View my cone on JsFiddle: http://j ...

Navigating to a different page by clicking on a Table Row in react-table

Whenever I click on a table row, I am unable to navigate to another page. Although I have successfully implemented the getTdProps function to retrieve properties from the table row upon clicking on it, I'm facing difficulty in using 'react-route ...

Creating a seamless rotation effect on an SVG shape at its center across all browsers, even Internet Explorer

Is there a way to make an SVG figure rotate around its center? I have been trying to calculate the rotation center and scale it based on the viewBox. It seems to work perfectly fine in Chrome, Firefox, and Safari, but I just can't seem to get it to wo ...