{"id":37194635,"url":"https://github.com/oblq/i18n","last_synced_at":"2026-01-14T22:38:05.057Z","repository":{"id":57493242,"uuid":"147001507","full_name":"oblq/i18n","owner":"oblq","description":"Minimal, flexible, simple to use/embed localization package.","archived":false,"fork":false,"pushed_at":"2022-04-07T12:22:21.000Z","size":432,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"v2","last_synced_at":"2025-08-14T01:37:39.809Z","etag":null,"topics":["go","golang","i18n","internationalization","localization","sprbox","translation"],"latest_commit_sha":null,"homepage":"","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/oblq.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}},"created_at":"2018-09-01T13:40:54.000Z","updated_at":"2024-01-10T15:43:28.000Z","dependencies_parsed_at":"2022-08-28T13:30:53.258Z","dependency_job_id":null,"html_url":"https://github.com/oblq/i18n","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/oblq/i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblq%2Fi18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblq%2Fi18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblq%2Fi18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblq%2Fi18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oblq","download_url":"https://codeload.github.com/oblq/i18n/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblq%2Fi18n/sbom","scorecard":{"id":701082,"data":{"date":"2025-08-11","repo":{"name":"github.com/oblq/i18n","commit":"7eaa216404f56b0da767d41f605f333a598dc9d6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'v2'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp","Warn: Project is vulnerable to: GO-2022-0603 / GHSA-hp87-p4gw-j4gq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T05:13:49.541Z","repository_id":57493242,"created_at":"2025-08-22T05:13:49.542Z","updated_at":"2025-08-22T05:13:49.542Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","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":["go","golang","i18n","internationalization","localization","sprbox","translation"],"created_at":"2026-01-14T22:38:04.272Z","updated_at":"2026-01-14T22:38:05.045Z","avatar_url":"https://github.com/oblq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i18n\n\n[![GitHub tag](https://img.shields.io/github/tag/oblq/i18n.svg)](https://github.com/oblq/i18n)\n[![Build Status](https://travis-ci.org/oblq/i18n.svg?branch=master)](https://travis-ci.org/oblq/i18n)\n[![codecov](https://codecov.io/gh/oblq/i18n/branch/master/graph/badge.svg)](https://codecov.io/gh/oblq/i18n)\n[![Go Report Card](https://goreportcard.com/badge/github.com/oblq/i18n)](https://goreportcard.com/report/github.com/oblq/i18n)\n[![GoDoc](https://godoc.org/github.com/oblq/i18n?status.svg)](https://godoc.org/github.com/oblq/i18n)\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)\n\n**i18n** is a minimal, flexible, simple to use and simple to embed (in your own packages) localizations package.  \nIt accept yaml, json or toml for both config and localizations files.\n\n## Installation\n\n```sh\ngo get -u github.com/oblq/i18n/v2\n```\n\n## Quickstart\n\nCreate a new instance:\n```go\npackage main\n\nimport (\n\t\"github.com/oblq/i18n/v2\"\n\t\"golang.org/x/text/language\"\n)\n\nfunc init() {\n\t// Optionally pass the config file path and nil config.\n\t// The config file can be in yaml, json or toml format.\n\tlocalizer, err := i18n.NewWithConfig(\u0026i18n.Config{\n            Locales: []string{\n                language.English.String(), // \"en\"\n                language.Italian.String(), // \"it\"\n            },\n            Path: \"./example/localizations\",\n        })\t\n}\n```\n\n\nLocalize a key:\n```go\nlocalizer.T(\"en\", \"MY_KEY\")\n```\n\n\nLocalize a key using plural and multiple parameters:  \n```yaml\n# ./example/localizations/en.yaml file\n\nWHOAMI: \"I'm %s!\"\n```\n\n```go\nlocalizer.TP(\"en\", \"WHOAMI\", \"i18n\") // -\u003e \"I'm i18n!\"\n```\n\n\nAutomatically localize a key based on the http request, i18n will first look for the locale by the GetLocaleOverride func, then in cookies (`language` and/or `lang` keys), then in `Accept-Language` header:\n\n```go\nfunc(w http.ResponseWriter, r *http.Request) {\n\tresponse := localizer.AutoT(r, \"MY_KEY\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(response))\n}\n```\n\n\nOptionally override the GetLocale func to automatically determine the locale to be used from http requests (using i18n.AutoT func), if an empty string is returned the default methods will be used anyway:\n```go\nlocalizer.GetLocaleOverride = func(r *http.Request) string {\n    user := MyCustomAuthLib.UserFromRequest(r)\n    return user.Locale\n}\n```          \n\n## Localized file server:\n\n```go\nlocalizer.SetFileServer(\n    map[string]http.Handler{\n        language.English.String(): http.FileServer(http.Dir(\"./landing_en\")),\n        language.Italian.String(): http.FileServer(http.Dir(\"./landing_it\")),\n    }, \n)\n\nmux.Handle(\"/\", localizer)\n```\n\n## Embed i18n in your package:\n\nUse hardcoded localizations, they can be a json, yaml or toml string:\n```go\npackage main\n\nimport (\n\t\"github.com/oblq/i18n/v2\"\n\t\"golang.org/x/text/language\"\n)\n\n// keys\nconst (\n\tGEM = \"GEM\" // generic_error_message\n)\n\nvar hardcodedLocs = map[string]map[string]string{\n\tlanguage.English.String(): {\n\t\tGEM: \"Something went wrong, please try again later %s\",\n\t},\n\tlanguage.Italian.String(): {\n\t\tGEM: \"Qualcosa è andato storto, riprova più tardi %s\",\n\t},\n}\n\nvar localizer *i18n.I18n\n\nfunc init() {\n\tlocalizer, err := i18n.NewWithConfig(\u0026i18n.Config{\n\t\tLocales: []string{\n\t\t\tlanguage.English.String(), // \"en\"\n\t\t\tlanguage.Italian.String(), // \"it\"\n\t\t},\n\t\tLocs: hardcodedLocs,\n\t})\n}\n```\n\n## Middleware\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\n\t\"github.com/oblq/i18n/v2\"\n\t\"golang.org/x/text/language\"\n)\n\nfunc init() {\n\tconfig := \u0026i18n.Config{\n\t\tHTTPLookUpStrategy: []i18n.HTTPLocalePosition{\n\t\t\t{i18n.HTTPLocalePositionIDHeader, \"Accept-Language\"},\n\t\t\t{i18n.HTTPLocalePositionIDCookie, \"locale\"},\n\t\t\t{i18n.HTTPLocalePositionIDQuery, \"lang\"},\n\t\t},\n\t\tLocales: []string{\n\t\t\tlanguage.Italian.String(), \n\t\t\tlanguage.English.String(),\n\t\t},\n\t}\n\n\tlocalizer, err := i18n.NewWithConfig(config)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thttp.Handle(\"/this-is-my-locale\", localizer.Middleware(http.HandlerFunc(getLocale)))\n\thttp.ListenAndServe(\":8080\", nil)\n}\n\nfunc getLocale(w http.ResponseWriter, r *http.Request) {\n\tlocale := r.Context().Value(i18n.MiddlewareContextLocaleKey)\n\t_, _ = w.Write([]byte(locale.(string)))\n}\n```\n\n## Vendored packages\n\n- [`golang.org/x/text/language`](golang.org/x/text/language)\n- [`gopkg.in/yaml.v2`](https://github.com/go-yaml/yaml)  \n- [`github.com/BurntSushi/toml`](https://github.com/BurntSushi/toml)\n\n## Author\n\n- [Marco Muratori](mailto:marcomrtr@gmail.com) \n\n## License\n\ni18n is available under the MIT license. See the [LICENSE](./LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foblq%2Fi18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foblq%2Fi18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foblq%2Fi18n/lists"}