{"id":17914223,"url":"https://github.com/knadh/go-i18n","last_synced_at":"2025-03-23T23:30:47.448Z","repository":{"id":176687750,"uuid":"649027164","full_name":"knadh/go-i18n","owner":"knadh","description":"Tiny i18n library for loading and using simple JSON language translation files in Go programs.","archived":false,"fork":false,"pushed_at":"2023-06-03T14:47:04.000Z","size":3,"stargazers_count":17,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T00:17:59.798Z","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/knadh.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}},"created_at":"2023-06-03T14:44:05.000Z","updated_at":"2024-10-25T10:19:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"d38321b0-01cf-4284-84b3-13707bf1aff5","html_url":"https://github.com/knadh/go-i18n","commit_stats":null,"previous_names":["knadh/go-i18n"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fgo-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fgo-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fgo-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knadh%2Fgo-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knadh","download_url":"https://codeload.github.com/knadh/go-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245186440,"owners_count":20574551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-28T19:56:55.275Z","updated_at":"2025-03-23T23:30:47.435Z","avatar_url":"https://github.com/knadh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-i18n\n\ngo-i18n is a tiny i18n library that enables `{langKey: langValue}` style JSON language maps to be loaded and used in Go programs. It is modeled after [vue-i18n](https://kazupon.github.io/vue-i18n/), optionally enabling interoperability of the same language files in Go backends a Vue frontends. It is used by [listmonk](https://github.com/knadh/listmonk) and [dictpress](https://github.com/knadh/dictpress).\n\n\n## Usage\n\n### Sample JSON language file\n\nA JSON language file looks is a simple map of `key: value` pairs. Singular/plural terms are represented as `Singular|Plural`. `_.code` and `_.name` are mandatory special keys. Check [listmonk translations](https://github.com/knadh/listmonk/tree/master/i18n) for complex examples.\n\n```json\n{\n\t\"_.code\": \"en\",\n\t\"_.name\": \"English\",\n\n\t\"pageTitle\": \"Welcome to the page\",\n\t\"page\": \"Single page|Many pages\",\n\t\"pageVars\": \"The page is named {name} and has {count} items\"\n}\n```\n\n```go\n\n\ti := i18n.NewFromFile(\"en.json\")\n\n\ti.T(\"pageTitle\") // Welcome to the page\n\ti.T(\"page\") // Single Page\n\ti.S(\"page\") // Single Page\n\ti.P(\"page\") // Many pages\n\ti.Tc(\"page\", 1) // Single Page (second param is a number. 1 is singular)\n\ti.Tc(\"page\", 2) // Many pages (\u003e= 1 is plural)\n\ti.Ts(\"pageVars\", \"name\", \"Foo\", \"count\", \"123\") // The page is named Foo and has 123 items\n```\n\nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknadh%2Fgo-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknadh%2Fgo-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknadh%2Fgo-i18n/lists"}