diff --git a/docs/docs/guide/deploy.md b/docs/docs/guide/deploy.md index 7bd3a47d..2650ab02 100644 --- a/docs/docs/guide/deploy.md +++ b/docs/docs/guide/deploy.md @@ -9,8 +9,9 @@ docker run -d \ --name artalk \ -p 8080:23366 \ -v $(pwd)/data:/data \ - -e ATK_TRUSTED_DOMAINS="https://your_domain" \ + -e ATK_LOCALE="zh-CN" \ -e ATK_SITE_DEFAULT="Artalk 的博客" \ + -e ATK_TRUSTED_DOMAINS="https://your_domain" \ artalk/artalk-go ``` @@ -87,8 +88,9 @@ services: - ./data:/data environment: - TZ=Asia/Shanghai - - ATK_TRUSTED_DOMAINS="https://your_domain" + - ATK_LOCALE="zh-CN" - ATK_SITE_DEFAULT="Artalk 的博客" + - ATK_TRUSTED_DOMAINS="https://your_domain" ``` 创建容器: diff --git a/docs/docs/guide/env.md b/docs/docs/guide/env.md index cefe2b50..85e04f52 100644 --- a/docs/docs/guide/env.md +++ b/docs/docs/guide/env.md @@ -24,6 +24,7 @@ services: volumes: - ./data:/data environment: + - ATK_LOCALE="zh-CN" - ATK_TRUSTED_DOMAINS="https://your_domain https://your_domain2" - ATK_ADMIN_USERS_0_NAME=admin - ATK_ADMIN_USERS_0_EMAIL=admin@example.org diff --git a/internal/core/gen.go b/internal/core/gen.go index bcf93add..12e766e6 100644 --- a/internal/core/gen.go +++ b/internal/core/gen.go @@ -1,6 +1,7 @@ package core import ( + "cmp" "fmt" "io" "os" @@ -15,6 +16,8 @@ import ( ) func Gen(genType string, specificPath string, overwrite bool) { + locale := cmp.Or(os.Getenv("ATK_LOCALE"), "en") + // check if generate config file isGenConf := false if genType == "config" || genType == "conf" || genType == "artalk.yml" { @@ -25,8 +28,7 @@ func Gen(genType string, specificPath string, overwrite bool) { // get generation content var fileStr string if isGenConf { - // TODO detect the user env language - fileStr = config.Template("en") + fileStr = config.Template(locale) // gen random `app_key` appKey := utils.RandomStringWithAlphabet(16, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*1234567890") fileStr = strings.Replace(fileStr, `app_key: ""`, fmt.Sprintf(`app_key: "%s"`, appKey), 1)