"use strict";(self.webpackChunkdashy=self.webpackChunkdashy||[]).push([[118],{3905:function(e,t,n){n.d(t,{Zo:function(){return u},kt:function(){return g}});var a=n(7294);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function r(e){for(var t=1;t
I am some text, that will be seen by the user
")),(0,o.kt)("p",null,"If you need to display text programmatically, from within the components JavaScript (e.g. in a toast popup), then use ",(0,o.kt)("inlineCode",{parentName:"p"},"this.$t"),".\nFor example: ",(0,o.kt)("inlineCode",{parentName:"p"},"alert(this.$t('my-widget.awesome-text'))"),"."),(0,o.kt)("p",null,"You may also need to pass a variable to be displayed within a translation. Vue I18n supports ",(0,o.kt)("a",{parentName:"p",href:"https://vue-i18n.intlify.dev/guide/essentials/syntax.html#interpolations"},"Interpolations")," using mustache-like syntax."),(0,o.kt)("p",null,"For example, you would set your translation to:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-json"},'{\n "welcome-message": "Hello {name}!"\n}\n')),(0,o.kt)("p",null,"And then pass that variable (",(0,o.kt)("inlineCode",{parentName:"p"},"name"),") within a JSON object as the second parameter on ",(0,o.kt)("inlineCode",{parentName:"p"},"$t"),", like:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"$t('welcome-message', { name: 'Alicia' })\n")),(0,o.kt)("p",null,"Which will render:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-text"},"Hello Alicia!\n")),(0,o.kt)("p",null,"There are many other advanced features, including Pluralization, Datetime & Number Formatting, Message Support and more, all of which are outlined in the ",(0,o.kt)("a",{parentName:"p",href:"https://vue-i18n.intlify.dev/guide/"},"Vue-i18n Docs"),"."),(0,o.kt)("h4",{id:"basic-example"},"Basic Example"),(0,o.kt)("p",null,"Using the search bar as an example, this would look something like:"),(0,o.kt)("p",null,"In ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/master/src/components/Settings/SearchBar.vue"},(0,o.kt)("inlineCode",{parentName:"a"},"./src/components/Settings/SearchBar.vue")),":"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-vue"},'\n \n\n')),(0,o.kt)("p",null,"Then in ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/master/src/assets/locales/en.json"},(0,o.kt)("inlineCode",{parentName:"a"},"./src/assets/locales/en.json")),":"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-json"},'{\n"search": {\n "search-label": "Search",\n "search-placeholder": "Start typing to filter",\n },\n ...\n}\n')))}c.isMDXComponent=!0}}]);