From 9502bef6dabe982f996781281e43217573770eef Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 23:59:26 +0000 Subject: [PATCH] feat(i18n): add current debug getter Co-Authored-By: Virgil --- debug_test.go | 14 ++++++++++++++ i18n.go | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/debug_test.go b/debug_test.go index c89ee5c..7dce60f 100644 --- a/debug_test.go +++ b/debug_test.go @@ -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 diff --git a/i18n.go b/i18n.go index a045223..bbd3e8b 100644 --- a/i18n.go +++ b/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" -- 2.45.3