Code Monkey home page Code Monkey logo

Comments (2)

tikiatua avatar tikiatua commented on July 18, 2024 1

Hi @GeniaT

Thank you for your feedback. There should be three options to make it work

  1. Make the casing of your assertion and your translation match (i.e. New Message / New message). Please keep in mind, that you are actually passing the string "New Message" to the translation method and not referencing the key navbar.newmessage with your current code. Therefore, the translate method will return the string that you passed to the translate method and not the fallback translation of the key.

  2. Set the current language and add only the key of the translation to the translate method. Vuex-i18n should figure out the correct fallback message by itself.

// set the default locale
Vue.i18n.set('zx');
// set the fallback locale
Vue.i18n.fallback('en');
// .. add the translations
...
// get the translated string
const translated = Vue.i18n.translate('navbar.newmessage');
expect(translated).to.equal('New Message');
  1. Use the translateIn method to specify in which language the translation should occur initially.
// get the translated string
const translated = Vue.i18n.translateIn('zx', 'navbar.newmessage');
expect(translated).to.equal('New Message');

Proper testing of the plugin is in our pipeline. Unfortunately, we are currently super-busy finalizing the first validated version of a huge project with a custom vue-based collaborative rich-text and flowchart editor which is consuming all our resources.

However, we will also use vuex-i18n at a later stage in this project and good testing coverage for the library as well as documentation on how to implement testing will definitely be part of the project.

from vuex-i18n.

GeniaT avatar GeniaT commented on July 18, 2024

@tikiatua Thanks for your quick answer and nice catch on casing. Works perfect now.

from vuex-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.