Skip to content

Commit 49e64ff

Browse files
committed
Revert "guard" in Tr function
otherwise the unit-tests will fail: === RUN TestBoardOptions --- FAIL: TestBoardOptions (0.00s) panic: i18n.Tr called before i18n.Init() [recovered] panic: i18n.Tr called before i18n.Init() goroutine 9 [running]: testing.tRunner.func1.2(0xc56e00, 0xeaee20) /opt/hostedtoolcache/go/1.16.7/x64/src/testing/testing.go:1143 +0x332 testing.tRunner.func1(0xc0002a2f00) /opt/hostedtoolcache/go/1.16.7/x64/src/testing/testing.go:1146 +0x4b6 panic(0xc56e00, 0xeaee20) /opt/hostedtoolcache/go/1.16.7/x64/src/runtime/panic.go:965 +0x1b9 github.com/arduino/arduino-cli/i18n.Tr(0xdceacd, 0x28, 0x0, 0x0, 0x0, 0x0, 0x1) /home/runner/work/arduino-cli/arduino-cli/i18n/i18n.go:54 +0xd9 github.com/arduino/arduino-cli/arduino/cores.(*Board).GetBuildProperties(0x13bf060, 0xc0003b6150, 0xc000339400, 0x0, 0x0) /home/runner/work/arduino-cli/arduino-cli/arduino/cores/board.go:109 +0x69d github.com/arduino/arduino-cli/arduino/cores.(*Board).GeneratePropertiesForConfiguration(0x13bf060, 0xdb5f54, 0xe, 0xc000309ef0, 0xc911e0, 0xc0003b6000) /home/runner/work/arduino-cli/arduino-cli/arduino/cores/board.go:141 +0x28f github.com/arduino/arduino-cli/arduino/cores.TestBoardOptions(0xc0002a2f00) /home/runner/work/arduino-cli/arduino-cli/arduino/cores/board_test.go:298 +0x4bd testing.tRunner(0xc0002a2f00, 0xe052a8) /opt/hostedtoolcache/go/1.16.7/x64/src/testing/testing.go:1193 +0xef created by testing.(*T).Run /opt/hostedtoolcache/go/1.16.7/x64/src/testing/testing.go:1238 +0x2b3 FAIL github.com/arduino/arduino-cli/arduino/cores 0.021s === RUN TestIndexParsing --- FAIL: TestIndexParsing (0.00s) panic: i18n.Tr called before i18n.Init() [recovered] panic: i18n.Tr called before i18n.Init()
1 parent 84842ed commit 49e64ff

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

Diff for: i18n/i18n.go

-7
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515

1616
package i18n
1717

18-
var initialized = false
19-
2018
// Init initializes the i18n module, setting the locale according to this order of preference:
2119
// 1. Locale specified via the function call
2220
// 2. OS Locale
2321
// 3. en (default)
2422
func Init(configLocale ...string) {
25-
defer func() { initialized = true }()
26-
2723
initRiceBox()
2824
locales := supportedLocales()
2925
if len(configLocale) > 1 {
@@ -50,8 +46,5 @@ func Init(configLocale ...string) {
5046
// Tr returns msg translated to the selected locale
5147
// the msg argument must be a literal string
5248
func Tr(msg string, args ...interface{}) string {
53-
if !initialized {
54-
panic("i18n.Tr called before i18n.Init()")
55-
}
5649
return po.Get(msg, args...)
5750
}

0 commit comments

Comments
 (0)