code refactor

This commit is contained in:
MaysWind
2024-08-05 00:50:45 +08:00
parent 8f8a94cd66
commit c137156c97
8 changed files with 87 additions and 78 deletions
+7 -5
View File
@@ -1,6 +1,8 @@
package locales
import "github.com/mayswind/ezbookkeeping/pkg/models"
import (
"github.com/mayswind/ezbookkeeping/pkg/core"
)
// DefaultLanguage represents the default language
var DefaultLanguage = en
@@ -26,8 +28,8 @@ 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 {
func IsDecimalSeparatorEqualsDigitGroupingSymbol(decimalSeparator core.DecimalSeparator, digitGroupingSymbol core.DigitGroupingSymbol, locale string) bool {
if decimalSeparator == core.DECIMAL_SEPARATOR_DEFAULT && digitGroupingSymbol == core.DIGIT_GROUPING_SYMBOL_DEFAULT {
return false
}
@@ -37,11 +39,11 @@ func IsDecimalSeparatorEqualsDigitGroupingSymbol(decimalSeparator models.Decimal
localeTextItems := GetLocaleTextItems(locale)
if decimalSeparator == models.DECIMAL_SEPARATOR_DEFAULT {
if decimalSeparator == core.DECIMAL_SEPARATOR_DEFAULT {
decimalSeparator = localeTextItems.DefaultTypes.DecimalSeparator
}
if digitGroupingSymbol == models.DIGIT_GROUPING_SYMBOL_DEFAULT {
if digitGroupingSymbol == core.DIGIT_GROUPING_SYMBOL_DEFAULT {
digitGroupingSymbol = localeTextItems.DefaultTypes.DigitGroupingSymbol
}
+5 -3
View File
@@ -1,6 +1,8 @@
package locales
import "github.com/mayswind/ezbookkeeping/pkg/models"
import (
"github.com/mayswind/ezbookkeeping/pkg/core"
)
// LocaleTextItems represents all text items need to be translated
type LocaleTextItems struct {
@@ -10,8 +12,8 @@ type LocaleTextItems struct {
}
type DefaultTypes struct {
DecimalSeparator models.DecimalSeparator
DigitGroupingSymbol models.DigitGroupingSymbol
DecimalSeparator core.DecimalSeparator
DigitGroupingSymbol core.DigitGroupingSymbol
}
// VerifyEmailTextItems represents text items need to be translated in verify mail
+5 -3
View File
@@ -1,11 +1,13 @@
package locales
import "github.com/mayswind/ezbookkeeping/pkg/models"
import (
"github.com/mayswind/ezbookkeeping/pkg/core"
)
var en = &LocaleTextItems{
DefaultTypes: &DefaultTypes{
DecimalSeparator: models.DECIMAL_SEPARATOR_DOT,
DigitGroupingSymbol: models.DIGIT_GROUPING_SYMBOL_COMMA,
DecimalSeparator: core.DECIMAL_SEPARATOR_DOT,
DigitGroupingSymbol: core.DIGIT_GROUPING_SYMBOL_COMMA,
},
VerifyEmailTextItems: &VerifyEmailTextItems{
Title: "Verify Email",
+5 -3
View File
@@ -1,11 +1,13 @@
package locales
import "github.com/mayswind/ezbookkeeping/pkg/models"
import (
"github.com/mayswind/ezbookkeeping/pkg/core"
)
var zhHans = &LocaleTextItems{
DefaultTypes: &DefaultTypes{
DecimalSeparator: models.DECIMAL_SEPARATOR_DOT,
DigitGroupingSymbol: models.DIGIT_GROUPING_SYMBOL_COMMA,
DecimalSeparator: core.DECIMAL_SEPARATOR_DOT,
DigitGroupingSymbol: core.DIGIT_GROUPING_SYMBOL_COMMA,
},
VerifyEmailTextItems: &VerifyEmailTextItems{
Title: "验证邮箱",