diff --git a/i18n.go b/i18n.go
index cfe982f..dd8d59e 100644
--- a/i18n.go
+++ b/i18n.go
@@ -174,6 +174,11 @@ func SetMessageWithDesc(lang, langDesc string, localeFile interface{}, otherLoca
return err
}
+// Flush reset locale store
+func Flush() {
+ locales = &localeStore{store: make(map[string]*locale)}
+}
+
// SetMessage sets the message file for localization.
func SetMessage(lang string, localeFile interface{}, otherLocaleFiles ...interface{}) error {
return SetMessageWithDesc(lang, lang, localeFile, otherLocaleFiles...)
diff --git a/i18n_test.go b/i18n_test.go
index ef6bd9d..83d31c5 100644
--- a/i18n_test.go
+++ b/i18n_test.go
@@ -44,6 +44,20 @@ func Test_Tr(t *testing.T) {
if result != `test value more text` {
t.Errorf(`expect 'test value more text', got '%s'`, result)
}
+
+ langs := ListLangs()
+ if len(langs) != 1 {
+ t.Errorf("expect '1', got '%d'", len(langs))
+ } else if langs[0] != "en-US" {
+ t.Errorf("expect 'en-US', got '%s'", langs[0])
+ }
+
+ Flush()
+
+ langs = ListLangs()
+ if len(langs) != 0 {
+ t.Errorf("expect '0', got '%d'", len(langs))
+ }
}
func Benchmark_Tr(b *testing.B) {