feat(i18n): add current debug getter
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
7e827ab3ce
commit
9502bef6da
2 changed files with 22 additions and 0 deletions
|
|
@ -33,6 +33,20 @@ func TestSetDebug_Good_ServiceLevel(t *testing.T) {
|
|||
assert.False(t, svc.Debug())
|
||||
}
|
||||
|
||||
func TestCurrentDebug_Good_PackageLevel(t *testing.T) {
|
||||
svc, err := New()
|
||||
require.NoError(t, err)
|
||||
|
||||
_ = Init()
|
||||
SetDefault(svc)
|
||||
|
||||
SetDebug(true)
|
||||
assert.True(t, CurrentDebug())
|
||||
|
||||
SetDebug(false)
|
||||
assert.False(t, CurrentDebug())
|
||||
}
|
||||
|
||||
func TestDebugFormat_Good(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
|
|||
8
i18n.go
8
i18n.go
|
|
@ -69,6 +69,14 @@ func CurrentFormality() Formality {
|
|||
return FormalityNeutral
|
||||
}
|
||||
|
||||
// CurrentDebug reports whether debug mode is enabled on the default service.
|
||||
func CurrentDebug() bool {
|
||||
if svc := Default(); svc != nil {
|
||||
return svc.Debug()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// N formats a number using the i18n.numeric.* namespace.
|
||||
//
|
||||
// N("number", 1234567) // "1,234,567"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue