mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
support setting decimal separator and digit grouping symbol
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package locales
|
||||
|
||||
import "github.com/mayswind/ezbookkeeping/pkg/models"
|
||||
|
||||
// DefaultLanguage represents the default language
|
||||
var DefaultLanguage = en
|
||||
|
||||
@@ -22,3 +24,25 @@ func GetLocaleTextItems(locale string) *LocaleTextItems {
|
||||
|
||||
return DefaultLanguage
|
||||
}
|
||||
|
||||
func IsDecimalSeparatorEqualsDigitGroupingSymbol(decimalSeparator models.DecimalSeparator, digitGroupingSymbol models.DigitGroupingSymbol, locale string) bool {
|
||||
if decimalSeparator == models.DECIMAL_SEPARATOR_DEFAULT && digitGroupingSymbol == models.DIGIT_GROUPING_SYMBOL_DEFAULT {
|
||||
return false
|
||||
}
|
||||
|
||||
if byte(decimalSeparator) == byte(digitGroupingSymbol) {
|
||||
return true
|
||||
}
|
||||
|
||||
localeTextItems := GetLocaleTextItems(locale)
|
||||
|
||||
if decimalSeparator == models.DECIMAL_SEPARATOR_DEFAULT {
|
||||
decimalSeparator = localeTextItems.DefaultTypes.DecimalSeparator
|
||||
}
|
||||
|
||||
if digitGroupingSymbol == models.DIGIT_GROUPING_SYMBOL_DEFAULT {
|
||||
digitGroupingSymbol = localeTextItems.DefaultTypes.DigitGroupingSymbol
|
||||
}
|
||||
|
||||
return byte(decimalSeparator) == byte(digitGroupingSymbol)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package locales
|
||||
|
||||
import "github.com/mayswind/ezbookkeeping/pkg/models"
|
||||
|
||||
// LocaleTextItems represents all text items need to be translated
|
||||
type LocaleTextItems struct {
|
||||
DefaultTypes *DefaultTypes
|
||||
VerifyEmailTextItems *VerifyEmailTextItems
|
||||
ForgetPasswordMailTextItems *ForgetPasswordMailTextItems
|
||||
}
|
||||
|
||||
type DefaultTypes struct {
|
||||
DecimalSeparator models.DecimalSeparator
|
||||
DigitGroupingSymbol models.DigitGroupingSymbol
|
||||
}
|
||||
|
||||
// VerifyEmailTextItems represents text items need to be translated in verify mail
|
||||
type VerifyEmailTextItems struct {
|
||||
Title string
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package locales
|
||||
|
||||
import "github.com/mayswind/ezbookkeeping/pkg/models"
|
||||
|
||||
var en = &LocaleTextItems{
|
||||
DefaultTypes: &DefaultTypes{
|
||||
DecimalSeparator: models.DECIMAL_SEPARATOR_DOT,
|
||||
DigitGroupingSymbol: models.DIGIT_GROUPING_SYMBOL_COMMA,
|
||||
},
|
||||
VerifyEmailTextItems: &VerifyEmailTextItems{
|
||||
Title: "Verify Email",
|
||||
SalutationFormat: "Hi %s,",
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package locales
|
||||
|
||||
import "github.com/mayswind/ezbookkeeping/pkg/models"
|
||||
|
||||
var zhHans = &LocaleTextItems{
|
||||
DefaultTypes: &DefaultTypes{
|
||||
DecimalSeparator: models.DECIMAL_SEPARATOR_DOT,
|
||||
DigitGroupingSymbol: models.DIGIT_GROUPING_SYMBOL_COMMA,
|
||||
},
|
||||
VerifyEmailTextItems: &VerifyEmailTextItems{
|
||||
Title: "验证邮箱",
|
||||
SalutationFormat: "%s 您好,",
|
||||
|
||||
Reference in New Issue
Block a user