File tree 1 file changed +23
-23
lines changed 1 file changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -83,33 +83,33 @@ export function getLanguage(): string {
83
83
export function t ( path : string , args ?: { [ key : string ] : string } ) : string {
84
84
const translationKeys : string [ ] = path . split ( '.' )
85
85
let translation : string = ''
86
- let translationObj : ITranslation = translations [ language ]
87
-
88
- translationKeys . forEach (
89
- ( key : string ) => {
90
- const temp : string | ITranslation = translationObj [ key ]
91
- if ( typeof translationObj [ key ] === 'object' ) {
92
- translationObj = translationObj [ key ] as ITranslation
86
+ if ( translations [ language ] ) {
87
+ let translationObj : ITranslation = translations [ language ]
88
+
89
+ translationKeys . forEach (
90
+ ( key : string ) => {
91
+ const temp : string | ITranslation = translationObj [ key ]
92
+ if ( typeof translationObj [ key ] === 'object' ) {
93
+ translationObj = translationObj [ key ] as ITranslation
94
+ }
95
+ if ( typeof temp === 'string' ) {
96
+ translation = temp
97
+ }
93
98
}
94
- if ( typeof temp === 'string' ) {
95
- translation = temp
99
+ )
100
+
101
+ if ( translation ) {
102
+ if ( args ) {
103
+ Object . keys ( args ) . forEach (
104
+ ( key ) => {
105
+ translation = translation . replace ( `{${ key } }` , args ? args [ key ] : '' )
106
+ }
107
+ )
96
108
}
109
+ return translation
97
110
}
98
- )
99
-
100
- if ( translation ) {
101
- if ( args ) {
102
- Object . keys ( args ) . forEach (
103
- ( key ) => {
104
- translation = translation . replace ( `{${ key } }` , args ? args [ key ] : '' )
105
- }
106
- )
107
- }
108
- } else {
109
- return path
110
111
}
111
-
112
- return translation
112
+ return path
113
113
}
114
114
115
115
export function useTranslation ( basePath ?: string ) {
You can’t perform that action at this time.
0 commit comments