{"id":20760523,"url":"https://github.com/modernice/go-regionlang","last_synced_at":"2025-10-11T16:06:57.984Z","repository":{"id":57643096,"uuid":"437610545","full_name":"modernice/go-regionlang","owner":"modernice","description":"Detect languages from countries / regions in Go.","archived":false,"fork":false,"pushed_at":"2023-05-29T18:58:49.000Z","size":9,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T16:51:17.452Z","etag":null,"topics":["country","go","golang","i18n","language","map","region"],"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/modernice.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":"2021-12-12T17:25:26.000Z","updated_at":"2024-09-03T13:56:10.000Z","dependencies_parsed_at":"2024-06-20T17:22:07.731Z","dependency_job_id":"5bce37bd-396c-439a-af7c-14151f17bed7","html_url":"https://github.com/modernice/go-regionlang","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/modernice/go-regionlang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernice%2Fgo-regionlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernice%2Fgo-regionlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernice%2Fgo-regionlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernice%2Fgo-regionlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modernice","download_url":"https://codeload.github.com/modernice/go-regionlang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernice%2Fgo-regionlang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007770,"owners_count":26084364,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["country","go","golang","i18n","language","map","region"],"created_at":"2024-11-17T10:14:07.960Z","updated_at":"2025-10-11T16:06:57.959Z","avatar_url":"https://github.com/modernice.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# regionlang - Country/Region to Language Mapper\n\n`regionlang` is a Go library that aids in determining the language associated with a given country or region. It comes in handy when you need to localize messages for users whose language preference is unknown.\n\n## Install\n\n```bash\ngo get github.com/modernice/go-regionlang\n```\n\n## Usage\n\nThe library's primary feature is the `Find` function which takes a region code as an argument and returns the corresponding language.\n\nHere's a basic example:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/modernice/go-regionlang\"\n\t\"golang.org/x/text/language\"\n)\n\nfunc main() {\n\tregion := \"be\" // Belgium\n\tbase, conf := regionlang.Find(region)\n\n\tfmt.Println(base.String()) // Output: \"fr\" (for French)\n\tfmt.Println(conf == language.Exact) // Output: true\n}\n```\n\nIn the above example, `regionlang.Find(\"be\")` returns French (\"fr\") as the most likely language for Belgium.\n\n### Custom Language Tags\n\nBy default, `go-regionlang` matches against all built-in language tags. However, your application might not support every single built-in language. To specify which language tags to match against, pass the allowed tags to the `Find` function as follows:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/modernice/go-regionlang\"\n\t\"golang.org/x/text/language\"\n)\n\nfunc main() {\n\tallowedTags := []language.Tag{language.English, language.Spanish, language.French}\n\tbase, conf := regionlang.Find(\"some-region-code\", allowedTags...)\n\n\tfmt.Println(base.String())\n\tfmt.Println(conf == language.Exact)\n}\n```\n\nIn this example, `Find` will only consider English, Spanish, and French when determining the language for the given region.\n\n## License\n\nThis project is licensed under the [MIT](./LICENSE) License. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernice%2Fgo-regionlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodernice%2Fgo-regionlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernice%2Fgo-regionlang/lists"}