This repository was archived by the owner on Apr 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " vue-i18n-composable" ,
3- "version" : " 0.1.1 " ,
3+ "version" : " 0.2.0 " ,
44 "main" : " dist/index.js" ,
55 "module" : " dist/index.m.js" ,
66 "types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 11import Vue from 'vue'
22import VueI18n from 'vue-i18n'
3- import { computed , getCurrentInstance } from '@vue/composition-api'
3+ import { computed , getCurrentInstance , WritableComputedRef } from '@vue/composition-api'
4+ import { VueConstructor } from 'vue/types/umd'
45
56let i18nInstance : VueI18n | undefined
67
7- export function createI18n ( options ?: VueI18n . I18nOptions ) {
8- Vue . use ( VueI18n )
8+ export function createI18n ( options ?: VueI18n . I18nOptions , vue : VueConstructor = Vue ) : VueI18n {
9+ vue . use ( VueI18n )
910 i18nInstance = new VueI18n ( options )
1011
1112 return i18nInstance
1213}
1314
14- export function useI18n ( ) {
15+ export interface Composer {
16+ locale : WritableComputedRef < string >
17+ t : typeof VueI18n . prototype . t
18+ tc : typeof VueI18n . prototype . tc
19+ te : typeof VueI18n . prototype . te
20+ d : typeof VueI18n . prototype . d
21+ n : typeof VueI18n . prototype . n
22+ }
23+
24+ export function useI18n ( ) : Composer {
1525 if ( ! i18nInstance )
1626 throw new Error ( 'vue-i18n not initialized' )
1727
You can’t perform that action at this time.
0 commit comments