refactor(i18n): align helper formatting with core primitives
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
d8355d241f
commit
852b11fda5
3 changed files with 7 additions and 7 deletions
4
debug.go
4
debug.go
|
|
@ -1,5 +1,7 @@
|
|||
package i18n
|
||||
|
||||
import "dappco.re/go/core"
|
||||
|
||||
// SetDebug enables or disables debug mode on the default service.
|
||||
func SetDebug(enabled bool) {
|
||||
withDefaultService(func(svc *Service) { svc.SetDebug(enabled) })
|
||||
|
|
@ -18,5 +20,5 @@ func (s *Service) Debug() bool {
|
|||
}
|
||||
|
||||
func debugFormat(key, text string) string {
|
||||
return "[" + key + "] " + text
|
||||
return core.Sprintf("[%s] %s", key, text)
|
||||
}
|
||||
|
|
|
|||
3
i18n.go
3
i18n.go
|
|
@ -3,7 +3,6 @@ package i18n
|
|||
import (
|
||||
"bytes"
|
||||
"io/fs"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"dappco.re/go/core"
|
||||
|
|
@ -308,7 +307,7 @@ func namespaceLookupKey(namespace, key string) string {
|
|||
if namespace != "" && key == namespace {
|
||||
return key
|
||||
}
|
||||
if namespace != "" && strings.HasPrefix(key, namespace+".") {
|
||||
if namespace != "" && core.HasPrefix(key, namespace+".") {
|
||||
return key
|
||||
}
|
||||
if namespace == "" {
|
||||
|
|
|
|||
7
state.go
7
state.go
|
|
@ -1,8 +1,7 @@
|
|||
package i18n
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"dappco.re/go/core"
|
||||
)
|
||||
|
||||
// ServiceState captures the current configuration of a service in one
|
||||
|
|
@ -24,9 +23,9 @@ type ServiceState struct {
|
|||
func (s ServiceState) String() string {
|
||||
langs := "[]"
|
||||
if len(s.AvailableLanguages) > 0 {
|
||||
langs = "[" + strings.Join(s.AvailableLanguages, ", ") + "]"
|
||||
langs = "[" + core.Join(", ", s.AvailableLanguages...) + "]"
|
||||
}
|
||||
return fmt.Sprintf(
|
||||
return core.Sprintf(
|
||||
"ServiceState{language=%q fallback=%q mode=%s formality=%s location=%q direction=%s rtl=%t debug=%t available=%s handlers=%d}",
|
||||
s.Language,
|
||||
s.Fallback,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue