@juit/vue-i18n 0.2.34 → 0.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +20 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,6 +16,7 @@ required translation languages and translation keys.
16
16
  - [Installation](#installation)
17
17
  - [Configuration](#configuration)
18
18
  - [Usage](#usage)
19
+ - [Switching language](#switching-language)
19
20
  - [Translating messages](#translating-messages)
20
21
  - [Parameterizing translations](#parameterizing-translations)
21
22
  - [Pluralization](#pluralization)
@@ -157,6 +158,25 @@ import { useTranslator } from '@juit/vue-i18n'
157
158
  const translator = useTranslator()
158
159
  ```
159
160
 
161
+ ### Switching language
162
+
163
+ To switch language, simply set the `language`, `region` or `locale` properties
164
+ on the translator instance:
165
+
166
+ ```typescript
167
+ import { useTranslator } from '@juit/vue-i18n'
168
+
169
+ const translator = useTranslator() // assuming the default locale is "en-US"
170
+
171
+ translator.region = 'CA' // we have switched to Canada, and locale is now "en-CA"
172
+ translator.language = 'fr' // we have switched to French, and locale is now "fr-CA"
173
+
174
+ // or set the full `locale`
175
+ translator.locale = new Intl.Locale('de-AT')
176
+ ```
177
+
178
+ Because of reactivity, all translations will be updated to the new locale.
179
+
160
180
 
161
181
  ## Translating messages
162
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juit/vue-i18n",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {