{"id":37112065,"url":"https://github.com/spectatornan/go-zero-i18n","last_synced_at":"2026-01-14T13:16:02.558Z","repository":{"id":57693746,"uuid":"485702093","full_name":"SpectatorNan/go-zero-i18n","owner":"SpectatorNan","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-27T16:06:16.000Z","size":58,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-29T12:55:16.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpectatorNan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-04-26T08:39:49.000Z","updated_at":"2025-12-27T16:06:13.000Z","dependencies_parsed_at":"2023-11-09T11:56:07.686Z","dependency_job_id":"94d26bb6-1d87-4231-a9a6-b9626f5502a0","html_url":"https://github.com/SpectatorNan/go-zero-i18n","commit_stats":null,"previous_names":["spectatornan/goi18nx"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/SpectatorNan/go-zero-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectatorNan%2Fgo-zero-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectatorNan%2Fgo-zero-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectatorNan%2Fgo-zero-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectatorNan%2Fgo-zero-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpectatorNan","download_url":"https://codeload.github.com/SpectatorNan/go-zero-i18n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectatorNan%2Fgo-zero-i18n/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T13:16:01.897Z","updated_at":"2026-01-14T13:16:02.544Z","avatar_url":"https://github.com/SpectatorNan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goi18nx\n \n## Usage\n\n### Interceptor\n \n#### Go zero api server\n \n\n```go\n\nimport \"github.com/SpectatorNan/go-zero-i18n/goi18nx\"\n\n    ......\n\tvar c config.Config\n\tconf.MustLoad(*configFile, \u0026c)\n\n\tctx := svc.NewServiceContext(c)\n\tserver := rest.MustNewServer(c.RestConf, errorx.RouteMethodNotAllow())\n \n    // LocalizationFiles is a slice of toml files path\n\t// register i18n\n\tserver.Use(goi18nx.NewI18nMiddleware([]language.Tag{\n        language.English,\n        language.Chinese,\n    }, []string{\".../active.en.toml\",\".../active.zh.toml\"}).Handle)\n\t\n\t......\n\n```\n\n#### Go zero rpc server\n \n```go\nimport \"github.com/SpectatorNan/go-zero-i18n/goi18nx\"\n\n    ......\n\n    i18n := goi18nx.NewI18nGrpcInterceptor([]language.Tag{\n            language.English,\n            language.Chinese,\n        }, c.LocalizationFiles)\n    s.AddUnaryInterceptors(i18n.Interceptor)\n\t\n    ......\n\t\n```\n\n#### Format string\n\n```go\n\n    // check context has i18n translator\n    goi18nx.IsHasI18n(ctx)\n\n    // context.Context\n\t// msgKey: localization string's key\n\t// defaultMsg: default string (if not found in localization file)\n    goi18nx.FormatText(ctx, serr.MsgKey, serr.DefaultMsg)\n\n    \n    \n```\n\n### Support From DB\n```go\n// Shop is a struct from db\nfunc (s *Shop) Name(ctx context.Context) string {\n\tlangMap := map[language.Tag]string{\n\t\tlanguage.English: s.NameEn,\n\t\tlanguage.Chinese: s.NameCn,\n\t\t// more language mapping\n\t}\n\treturn goi18nx.LocalizedString(ctx, s.NameCn, langMap)\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectatornan%2Fgo-zero-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspectatornan%2Fgo-zero-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectatornan%2Fgo-zero-i18n/lists"}