pre-dev: add lang helper
This commit is contained in:
+1
-1
@@ -30,4 +30,4 @@ config.yml
|
||||
|
||||
# Editor/IDE
|
||||
# .idea/
|
||||
.vscode/
|
||||
.vscode/*
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"request-ok": "request is done succesfully",
|
||||
"request-methodNotAllowed": "request has been rejected, method is not allowed",
|
||||
"request-toomany": "too many request",
|
||||
"payload-bad": "invalid data structure",
|
||||
|
||||
"auth-required": "authentication required",
|
||||
"auth-missingHeader": "authentication header is missing",
|
||||
"auth-forbidden": "forbidden",
|
||||
"auth-login-success": "login success",
|
||||
"auth-login-incorrect": "login failed, icorrect username or password",
|
||||
"auth-login-tooMany": "login failed, too many login attempts",
|
||||
"auth-login-blocked": "login failed, account is blocked",
|
||||
"auth-login-unverified": "login failed, account is not verified",
|
||||
"auth-logout-success": "logout success",
|
||||
"auth-reject-suspend": "restricted for suspended account",
|
||||
|
||||
"balance-exceed-notAllowed": "must not exceeds balance",
|
||||
|
||||
"emailConfirm-success": "email confirmation success",
|
||||
"emailConfirm-fail": "failed to confirm email",
|
||||
"emailConfirm-resend-fail": "failed to resend email confirmation",
|
||||
|
||||
"data-create-done": "data has been created",
|
||||
"data-notFound": "data or resource can not be found",
|
||||
"data-notFound-condition": "\"%v\" with %v \"%v\" can not be found",
|
||||
"data-get-fail": "get data failed, %v",
|
||||
"data-send-fail": "send data failed, %v",
|
||||
"data-create-fail": "failed to create data",
|
||||
"data-update-fail": "failed to update data",
|
||||
"data-delete-fail": "failed to delete data",
|
||||
"data-delete-success": "data has been deleted",
|
||||
"data-fetch-fail": "failed to fetch data",
|
||||
"data-copy-fail": "failed to copy data",
|
||||
"data-process-fail": "failed to process data",
|
||||
"data-confirm-fail": "failed to confirm data",
|
||||
"data-generate-fail": "failed to generate data",
|
||||
"data-registered": "is already registered",
|
||||
"data-state-mismatch": "\"%v\" is not in \"%v\" state",
|
||||
"data-duplicate": "duplicate data",
|
||||
"data-payment-fail": "failed to create payment",
|
||||
|
||||
"expired": "is expired",
|
||||
"registered": "is already registered",
|
||||
"mustUuid": "must be a valid uuid",
|
||||
"invalid": "invalid value",
|
||||
"equalToField": "must equal to",
|
||||
"constraint-vioalate": "must not violate constraint",
|
||||
|
||||
"config-fetch-done": "app config is fetched successfully",
|
||||
"userToken-incorrect": "incorrect email, token, or token type",
|
||||
|
||||
"token-missing": "missing required token",
|
||||
"token-invalid": "invalid token",
|
||||
"token-invalidType": "invalid token type",
|
||||
"token-sign-unexcpeted": "unexpected signing method: %v",
|
||||
"token-sign-err": "token signing failed, %v",
|
||||
"token-parse-fail": "token parsing failed, %v",
|
||||
"token-expired": "token is expired",
|
||||
"token-unidentified": "token is could not be identified",
|
||||
|
||||
"file-detect-fail": "file type detection failed",
|
||||
"file-type-mismatch": "file type mismatch",
|
||||
"file-create-fail": "failed to create file, %v",
|
||||
"file-open-fail": "failed to open file, %v",
|
||||
"file-copy-fail": "failed to copy file, %v",
|
||||
|
||||
"uuid-gen-fail" : "failed to generate uuid, %v",
|
||||
"nanoid-gen-fail" : "failed to generate nanoid, %v",
|
||||
|
||||
"redis-store-fail": "redis storing value failed, %v",
|
||||
|
||||
"gte": "greater than or equal to %v",
|
||||
"lte": "less than or equal to %v"
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"request-ok": "'request' berhasil diproses",
|
||||
"request-methodNotAllowed": "'request' ditolak, method tidak diijinkan",
|
||||
"request-toomany": "terlalu banyak 'request'",
|
||||
"payload-bad": "struktur data tidak sesuai standar",
|
||||
|
||||
"auth-required": "butuh autentikasi",
|
||||
"auth-missingHeader": "Header autentikasi tidak ditemukan",
|
||||
"auth-forbidden": "tidak diijinkan",
|
||||
"auth-login-success": "login berhasil",
|
||||
"auth-login-incorrect": "Username atau Password Tidak Sesuai",
|
||||
"auth-login-tooMany": "login gagal, terlalu banyak percobaan",
|
||||
"auth-login-blocked": "login gagal, akun diblokir",
|
||||
"auth-login-unverified": "login gagal, akun belum terverifikasi",
|
||||
"auth-logout-success": "logout berhasil",
|
||||
"auth-reject-suspend": "dibatasi untuk akun dibekukan",
|
||||
|
||||
"balance-exceed-notAllowed": "tidak boleh melebihi saldo",
|
||||
|
||||
"emailConfirm-success": "konfimrasi email berhasil",
|
||||
"emailConfirm-fail": "gagal mengkonfirmasi email",
|
||||
"emailConfirm-resend-fail": "gagal mengirim konfirmasi email",
|
||||
|
||||
"data-create-done": "data telah dibuat",
|
||||
"data-notFound": "data atau sumber tidak daoat ditemukan",
|
||||
"data-notFound-condition": "\"%v\" dengan %v \"%v\" tidak dapat ditemukan",
|
||||
"data-get-fail": "gagal mengambil data, %v",
|
||||
"data-create-fail": "gagal membuat data",
|
||||
"data-update-fail": "gagal memperbarui data",
|
||||
"data-delete-fail": "gagal menghapus data",
|
||||
"data-delete-success": "data telah dihapus",
|
||||
"data-fetch-fail": "gagal mengambil data",
|
||||
"data-copy-fail": "gagal menyalin data",
|
||||
"data-process-fail": "gagal memproses data",
|
||||
"data-confirm-fail": "gagal mengirim data",
|
||||
"data-generate-fail": "gagal membuat data",
|
||||
"data-registered": "sudah pernah dibuat",
|
||||
"data-state-mismatch": "\"%v\" tidak dalam kondisi \"%v\"",
|
||||
|
||||
"expired": "expired",
|
||||
"registered": "sudah terdaftar",
|
||||
"mustUuid": "harus UUID yang valid",
|
||||
"invalid": "nilai tidak sesuai",
|
||||
"equalToField": "harus sama dengan",
|
||||
"constraint-vioalate": "tidak boleh melanggar batasan",
|
||||
|
||||
"config-fetch-done": "konfigurasi app berhasil diterapkan",
|
||||
"userToken-incorrect": "salah email, token, atau jenis token",
|
||||
|
||||
"token-missing": "token tidak dapat ditemukan",
|
||||
"token-invalid": "token tidak berlaku",
|
||||
"token-invalidType": "jenis token tidak berlaku",
|
||||
"token-sign-unexcpeted": "metode penanda tidak beralku: %v",
|
||||
"token-sign-err": "penanda token tidak sesuai, %v",
|
||||
"token-parse-fail": "%v",
|
||||
"token-expired": "Token Expired",
|
||||
"token-unidentified": "token tidak dapat diidentifikasi",
|
||||
|
||||
"file-detect-fail": "gagal mendeteksi tipe file",
|
||||
"file-type-mismatch": "tipe file tidak sesuai",
|
||||
"file-create-fail": "gagal membuat file, %v",
|
||||
"file-open-fail": "gagal membuka file, %v",
|
||||
"file-copy-fail": "gagal menyalin file, %v",
|
||||
|
||||
"uuid-gen-fail" : "gagal membuat UUID, %v",
|
||||
"nanoid-gen-fail" : "gagal membuat NANOID, %v",
|
||||
|
||||
"redis-store-fail": "gagal mengimpan data pada redis, %v",
|
||||
|
||||
"gte": "lebih besar atau sama dengan %v",
|
||||
"lte": "lebih kecil atau sama dengan %v",
|
||||
"jknData-required": "%v Belum Diisi",
|
||||
"jknData-length": "Format %v Tidak Sesuai",
|
||||
"jknData-numeric": "Format %v Tidak Sesuai",
|
||||
"jknData-notFound": "%v Tidak Ditemukan"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# convention
|
||||
Key - value data indexed. Key prefered to be be consisting of 3 part: [feature]-[action]-[status]. Special case for validation that is intended to point error on an input (field), the key can be stated directly to the validation index, for example: min is for minimum value needed.
|
||||
@@ -6,7 +6,7 @@ toolchain go1.23.11
|
||||
|
||||
require (
|
||||
github.com/karincake/apem v0.0.16-e
|
||||
github.com/karincake/dodol v0.1.0-d
|
||||
github.com/karincake/lepet v0.0.1
|
||||
gorm.io/gorm v1.25.10
|
||||
)
|
||||
|
||||
@@ -18,13 +18,13 @@ require (
|
||||
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/karincake/getuk v0.1.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/nxadm/tail v1.4.11 // indirect
|
||||
github.com/rs/zerolog v1.33.0 // indirect
|
||||
golang.org/x/crypto v0.40.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
|
||||
golang.org/x/net v0.42.0 // indirect
|
||||
golang.org/x/sys v0.34.0 // indirect
|
||||
golang.org/x/text v0.27.0 // indirect
|
||||
|
||||
@@ -22,10 +22,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/karincake/apem v0.0.16-e h1:KGeQYmgNw8luidSWkZyGcMbW1PP3KMRCHMTEHQ7twU8=
|
||||
github.com/karincake/apem v0.0.16-e/go.mod h1:cQP2sJfDrLRIiwWoaLWw/z8uAya+DWu/FpmYeinMQXM=
|
||||
github.com/karincake/dodol v0.1.0-d h1:f5p35a2el+9XbiCCZKT7Gf/hXs8m2p5iD1C20RZ/aKI=
|
||||
github.com/karincake/dodol v0.1.0-d/go.mod h1:2f1NcvkvY0J3GMUkwILNDYVvRUpz0W3lpPp/Ha/Ld24=
|
||||
github.com/karincake/getuk v0.1.0 h1:jcIsASrr0UDE528GN7Ua6n9UFyRgUypsWh8Or8wzCO0=
|
||||
github.com/karincake/getuk v0.1.0/go.mod h1:NVnvxSGAkQ/xuq99FzWACvY5efyKPLFla1cKB8czm7c=
|
||||
github.com/karincake/lepet v0.0.1 h1:eq/cwn5BBg0jWZ1c/MmvhFIBma0zBpVs2LwkfDOncy4=
|
||||
github.com/karincake/lepet v0.0.1/go.mod h1:U84w7olXO3BPJw2Hu6MBonFmJmPKaFjtyAj1HTu3z1A=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
@@ -56,6 +54,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
||||
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
|
||||
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
|
||||
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Package langhelper provides helper functions for language
|
||||
package langhelper
|
||||
|
||||
import (
|
||||
a "github.com/karincake/apem"
|
||||
l "github.com/karincake/lepet"
|
||||
)
|
||||
|
||||
type Cfg struct {
|
||||
LangCfg *l.LangCfg `yaml:"langCfg"`
|
||||
}
|
||||
|
||||
func Populate() {
|
||||
cfg := &Cfg{
|
||||
LangCfg: &l.LangCfg{},
|
||||
}
|
||||
a.ParseCfg(&cfg)
|
||||
l.Init(cfg.LangCfg)
|
||||
}
|
||||
Reference in New Issue
Block a user