Our.Umbraco.DictionaryBuilder.VueI18N 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Our.Umbraco.DictionaryBuilder.VueI18N --version 1.0.5                
NuGet\Install-Package Our.Umbraco.DictionaryBuilder.VueI18N -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Our.Umbraco.DictionaryBuilder.VueI18N" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Our.Umbraco.DictionaryBuilder.VueI18N --version 1.0.5                
#r "nuget: Our.Umbraco.DictionaryBuilder.VueI18N, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Our.Umbraco.DictionaryBuilder.VueI18N as a Cake Addin
#addin nuget:?package=Our.Umbraco.DictionaryBuilder.VueI18N&version=1.0.5

// Install Our.Umbraco.DictionaryBuilder.VueI18N as a Cake Tool
#tool nuget:?package=Our.Umbraco.DictionaryBuilder.VueI18N&version=1.0.5                

Umbraco.DictionaryBuilder.VueI18N

Nuget

Exposes a url (/umbraco/dictionaries.json) to get the dictionaries in a format that matches Vue I18n locale structure. This will return all dictionaries in every language.

There are 2 querystring paramaters that can be added:

  • locale or l, to speficy the requested language translation.
  • prefix or p, to specify a prefix, that all return dictionaries have in thier key.

Example of how to wire up the dictionaries into Vue I18n:

import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueI18n from 'vue-i18n'

// Initialize Vue
Vue.use(VueAxios, axios)
Vue.use(VueI18n)

// Initialize Vue I18n
const lang = document.querySelector('html').getAttribute('lang')
export const i18n = new VueI18n({
    locale: lang, // set locale
    messages: {}
});

var app = new Vue({
    el: '#app',
    i18n,
    created() {
        axios.get("/umbraco/dictionaries.json?l=" + lang).then(function (response) {
            i18n.setLocaleMessage(lang, response.data)
        });
    }
});

To use dictionaries in Vue, just use the $t/$tc syntax in Vue I18n.


Naming convensions

To get a dictionary with a specifc key, prefix the key with $. So lets say, that we need the value of a dictionary item with the key ItemKey, use $itemKey

Note: Remember to use Camel Casing, when specifing a key

If we need the value of a dictionary item with the key ItemKey, that is a child node to the key Parent, use parent.$itemKey. So use $ prefix, when we want the value, otherwise we will get the child object containing child dictionary items.

Format

See Vue I18n Formatting

Note: Remember to use Camel Casing, when specifing a key

Example dictionary value: "Apple"

$t('$apple')
// Returns: "Apple"

Example dictionary value: "{0} apple"

$t('$apple', ['green'])
// Returns: "green apple"
Pluralization

See Vue I18n Pluralization

Note: Remember to use Camel Casing, when specifing a key

Example dictionary value "no apples | one apple | {count} apples"

$tc('$apple', 0)
// Returns: "no apples"
$tc('$apple', 1)
// Returns: "one apple"
$tc('$apple', 2)
// Returns: "2 apples"
$tc('$apple', 33)
// Returns: "33 apples"

Example dictionary value: "no {0} apples | one {0} apple | {count} {0} apples"

$tc('$apple', 0, ['red'])
// Returns: "no red apples"
$tc('$apple', 1, ['red'])
// Returns: "one red apple"
$tc('$apple', 2, ['red'])
// Returns: "2 red apples"
$tc('$apple', 33, ['red'])
// Returns: "33 red apples"
Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.10 1,460 2/10/2022
1.0.9 7,671 1/20/2021
1.0.8 707 11/24/2020
1.0.7 409 11/24/2020
1.0.6 916 10/2/2020
1.0.5 2,608 8/22/2020
1.0.4 477 8/22/2020
1.0.3 693 8/11/2020
1.0.2 474 8/10/2020
1.0.1 455 8/7/2020
1.0.0 487 8/6/2020