summaryrefslogtreecommitdiff
path: root/locale/localization.go
diff options
from:
to:
context:
space:
mode:
authorGravatar SayaAndy <montferrat@tuta.io> 2025-08-11 16:52:48 +0700
committerGravatar SayaAndy <montferrat@tuta.io> 2025-08-11 16:52:48 +0700
commitea1f83df820baa14dcd904d581ab2bb0976b172d (patch)
tree61322010ecdd59534cc1d02ff1c29d815d07152c /locale/localization.go
parent15356da2c3e3544d757591a2f6e68367bf2d137f (diff)
downloadweb-ea1f83df820baa14dcd904d581ab2bb0976b172d.tar.gz
web-ea1f83df820baa14dcd904d581ab2bb0976b172d.zip
feat: redo blog catalogue with same layout as blog-pagev0.5.0
feat: implement localization feat: filters and sort in blog catalogue feat: one-page search feat: ram theme refactor: generate blog catalogue and blog page out of one layout refactor: have one layout for both mobile & desktop (aspect ratio dependable) refactor: use own template manager to use templates separately
Diffstat (limited to 'locale/localization.go')
-rw-r--r--locale/localization.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/locale/localization.go b/locale/localization.go
new file mode 100644
index 0000000..d5c6b48
--- /dev/null
+++ b/locale/localization.go
@@ -0,0 +1,50 @@
+package locale
+
+import (
+ "os"
+
+ "github.com/go-playground/validator/v10"
+ "gopkg.in/yaml.v3"
+)
+
+type LocaleConfig struct {
+ TagsLabel string `yaml:"TagsLabel" json:"TagsLabel"`
+ BlogSearch BlogSearchConfig `yaml:"BlogSearch" json:"BlogSearch"`
+}
+
+type BlogSearchConfig struct {
+ Header string `yaml:"Header" json:"Header"`
+ TagsHeader string `yaml:"TagsHeader" json:"TagsHeader"`
+ OrderByHeader string `yaml:"OrderByHeader" json:"OrderByHeader"`
+ TitleOrdered string `yaml:"TitleOrdered" json:"TitleOrdered"`
+ ActionDateOrdered string `yaml:"ActionDateOrdered" json:"ActionDateOrdered"`
+ PublicationDateOrdered string `yaml:"PublicationDateOrdered" json:"PublicationDateOrdered"`
+ ChooseAllTags string `yaml:"ChooseAllTags" json:"ChooseAllTags"`
+}
+
+func LoadConfig(path string, config *LocaleConfig) error {
+ fileBytes, err := os.ReadFile(path)
+ if err != nil {
+ return err
+ }
+
+ if err = yaml.Unmarshal(fileBytes, config); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func InitConfig(path string) (*LocaleConfig, error) {
+ config := &LocaleConfig{}
+ if err := LoadConfig(path, config); err != nil {
+ return nil, err
+ }
+
+ validate := validator.New(validator.WithRequiredStructEnabled())
+ if err := validate.Struct(config); err != nil {
+ return nil, err
+ }
+
+ return config, nil
+}