@@ -5,22 +5,22 @@ import { ReplacementsInterface } from './interfaces/replacements'
5
5
import { choose } from './pluralization'
6
6
7
7
/**
8
- * The Default language will be used if there is no lang provided .
8
+ * The default options, for the plugin .
9
9
*/
10
- const DEFAULT_LANG : string = document . documentElement . lang || 'en'
10
+ const DEFAULT_OPTIONS : OptionsInterface = {
11
+ lang : document . documentElement . lang || 'en' ,
12
+ resolve : ( lang : string ) => new Promise ( ( resolve ) => resolve ( { default : { } } ) )
13
+ }
11
14
12
15
/**
13
16
* Stores the current options.
14
17
*/
15
- let options : OptionsInterface = {
16
- lang : DEFAULT_LANG ,
17
- resolve : ( lang : string ) => new Promise ( ( resolve ) => resolve ( { default : { } } ) )
18
- }
18
+ let options : OptionsInterface = DEFAULT_OPTIONS ;
19
19
20
20
/**
21
21
* Stores the loaded languages.
22
22
*/
23
- const loaded : LanguageInterface [ ] = [ ]
23
+ let loaded : LanguageInterface [ ] = [ ]
24
24
25
25
/**
26
26
* The active messages to use.
@@ -106,6 +106,18 @@ function makeReplacements(message: string, replacements?: ReplacementsInterface)
106
106
return message
107
107
}
108
108
109
+ /**
110
+ * Resets all the data stored in memory.
111
+ */
112
+ export const reset = ( ) : void => {
113
+ loaded = [ ] ;
114
+ options = DEFAULT_OPTIONS ;
115
+
116
+ for ( const [ key ] of Object . entries ( activeMessages ) ) {
117
+ activeMessages [ key ] = null ;
118
+ }
119
+ }
120
+
109
121
/**
110
122
* The Vue Plugin. to be used on your Vue app like this: `app.use(i18nVue)`
111
123
*/
0 commit comments