{"id":21161568,"url":"https://github.com/loctools/go-l10n","last_synced_at":"2025-07-30T13:05:57.707Z","repository":{"id":57544461,"uuid":"105502749","full_name":"loctools/go-l10n","owner":"loctools","description":"Lightweight yet powerful continuous localization solution for Go, based on Serge and Plurr.","archived":false,"fork":false,"pushed_at":"2019-10-31T18:53:33.000Z","size":15,"stargazers_count":32,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-18T23:10:08.191Z","etag":null,"topics":["continuous-localization","golang","i18n","l10n","localization","plurr","serge"],"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/loctools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-02T06:04:04.000Z","updated_at":"2022-11-25T16:31:14.000Z","dependencies_parsed_at":"2022-09-16T23:12:08.993Z","dependency_job_id":null,"html_url":"https://github.com/loctools/go-l10n","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loctools%2Fgo-l10n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loctools%2Fgo-l10n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loctools%2Fgo-l10n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loctools%2Fgo-l10n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loctools","download_url":"https://codeload.github.com/loctools/go-l10n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225562097,"owners_count":17488566,"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":["continuous-localization","golang","i18n","l10n","localization","plurr","serge"],"created_at":"2024-11-20T13:15:05.449Z","updated_at":"2024-11-20T13:15:06.049Z","avatar_url":"https://github.com/loctools.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"About go-l10n\r\n=============\r\n\r\nLightweight yet powerful continuous localization solution for Go, based on\r\n[Serge](https://serge.io/) and [Plurr](https://github.com/iafan/Plurr).\r\n\r\nAdvantages\r\n----------\r\n\r\n 1. Provides solution for both web-based and desktop applications.\r\n 2. Can be used with different resource file formats, thanks to Serge.\r\n    Currently offers the support for JSON resource files and\r\n    string maps in the native .go format. Both formats support\r\n    developer comments for translators to get extra context.\r\n 3. Supports named placeholders, plurals and conditionals via\r\n    Plurr-formatted strings (see the\r\n    [interactive demo](http://iafan.github.io/plurr-demo/)).\r\n 4. Support for translation and formatting functions in `html/template`\r\n    and `text/template`.\r\n 5. For web applications, an ability to auto-detect the best language\r\n    from the browser, and to force the language using a cookie or\r\n    a query string parameter.\r\n 6. Comes with ready-to-use Serge configuration files to allow for\r\n    seamless continuous localization process (see\r\n    [examples](https://github.com/iafan/go-l10n/tree/master/examples/)).\r\n 7. Supports pseudotranslations out of the box. Pseudotranslation is a way\r\n    to \"translate\" your application by applying some algorithm to each\r\n    source string; it is useful to test if your application looks good\r\n    with other locales without waiting for actual translations.\r\n\r\n 7. The code is split into small packages to minimize external dependencies.\r\n\r\nExample Code\r\n------------\r\n\r\nThere are two example projects that showcase approaches to localizing\r\n[web applications](https://github.com/iafan/go-l10n/tree/master/examples/web/) and\r\n[desktop applications](https://github.com/iafan/go-l10n/tree/master/examples/desktop/).\r\nBelow is a condensed example to illustrate the typical usage.\r\n\r\n`strings.go` (master resource file):\r\n```go\r\npackage main\r\n\r\nfunc init() {\r\n    locpool.Resources[\"en\"] = map[string]string{\r\n        // Page title\r\n        \"Hello\": \"Hello!\",\r\n\r\n        // {N} is the number of messages\r\n        \"YouHaveNMessages\": \"You have {N} {N_PLURAL:message|messages}\",\r\n    }\r\n}\r\n```\r\n\r\n`strings-ru.go` (localized resource file):\r\n```go\r\npackage main\r\n\r\nfunc init() {\r\n    locpool.Resources[\"ru\"] = map[string]string{\r\n        // Page title\r\n        \"Hello\": \"Здравствуйте!\",\r\n\r\n        // {N} is the number of messages\r\n        \"YouHaveNMessages\": \"У вас {N} {N_PLURAL:сообщение|сообщения|сообщений}\",\r\n    }\r\n}\r\n```\r\n\r\nCode:\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"github.com/iafan/Plurr/go/plurr\"\r\n    \"github.com/iafan/go-l10n/loc\"\r\n)\r\n\r\n// Create a global localization pool which will be populated\r\n// by resource files; use English as a default (fallback) language\r\nvar locpool = loc.NewPool(\"en\")\r\n\r\nfunc main() {\r\n  // Get Russian localization context\r\n  lc := locpool.GetContext(\"ru\")\r\n\r\n  // Get translation by key name:\r\n  name := lc.Tr(\"Hello\")\r\n\r\n  // get translation by key name, then format it using Plurr:\r\n  hello := lc.Format(\"YouHaveNMessages\", plurr.Params{\"N\": 5})\r\n\r\n  ...\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floctools%2Fgo-l10n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floctools%2Fgo-l10n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floctools%2Fgo-l10n/lists"}