Skip to content

Commit 1fb2b79

Browse files
committed
Make i18n live-reload work for default language
1 parent cdd6371 commit 1fb2b79

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

modules/translation/i18n/i18n.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ func (l *locale) Tr(trKey string, trArgs ...interface{}) string {
138138
if l.store.reloadMu != nil {
139139
l.store.reloadMu.Lock()
140140
defer l.store.reloadMu.Unlock()
141+
}
142+
msg, _ := l.tryTr(trKey, trArgs...)
143+
return msg
144+
}
145+
146+
func (l *locale) tryTr(trKey string, trArgs ...interface{}) (msg string, found bool) {
147+
if l.store.reloadMu != nil {
141148
now := time.Now()
142149
if now.Sub(l.lastReloadCheckTime) >= time.Second && l.sourceFileInfo != nil && l.sourceFileName != "" {
143150
l.lastReloadCheckTime = now
@@ -150,11 +157,6 @@ func (l *locale) Tr(trKey string, trArgs ...interface{}) string {
150157
}
151158
}
152159
}
153-
msg, _ := l.tryTr(trKey, trArgs...)
154-
return msg
155-
}
156-
157-
func (l *locale) tryTr(trKey string, trArgs ...interface{}) (msg string, found bool) {
158160
trMsg := trKey
159161
textIdx, ok := l.store.textIdxMap[trKey]
160162
if ok {

0 commit comments

Comments
 (0)