{"id":21036477,"url":"https://github.com/moemoe89/go-localization","last_synced_at":"2025-05-15T14:31:47.038Z","repository":{"id":57514754,"uuid":"221412337","full_name":"moemoe89/go-localization","owner":"moemoe89","description":"🇮🇩 🇯🇵 🇺🇸 go-localization is a Go package that provides tool for showing message based on language code.","archived":false,"fork":false,"pushed_at":"2020-07-15T23:29:25.000Z","size":12,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T10:37:48.042Z","etag":null,"topics":["go","golang","language","localization"],"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/moemoe89.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":"2019-11-13T08:43:04.000Z","updated_at":"2023-05-07T07:49:43.000Z","dependencies_parsed_at":"2022-09-26T18:00:54.818Z","dependency_job_id":null,"html_url":"https://github.com/moemoe89/go-localization","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moemoe89%2Fgo-localization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moemoe89%2Fgo-localization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moemoe89%2Fgo-localization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moemoe89%2Fgo-localization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moemoe89","download_url":"https://codeload.github.com/moemoe89/go-localization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254358805,"owners_count":22057982,"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":["go","golang","language","localization"],"created_at":"2024-11-19T13:20:11.887Z","updated_at":"2025-05-15T14:31:46.720Z","avatar_url":"https://github.com/moemoe89.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/moemoe89/go-localization.svg?branch=master)](https://travis-ci.org/moemoe89/go-localization)\n[![Coverage Status](https://coveralls.io/repos/github/moemoe89/go-localization/badge.svg?branch=master)](https://coveralls.io/github/moemoe89/go-localization?branch=master)\n[![GoDoc](https://godoc.org/github.com/moemoe89/go-localization?status.svg)](https://godoc.org/github.com/moemoe89/go-localization)\n[![Go Report Card](https://goreportcard.com/badge/github.com/moemoe89/go-localization)](https://goreportcard.com/report/github.com/moemoe89/go-localization)\n\n# go-localization\n\n## Description\n\ngo-localization is a Go package that provides tool for showing message based on language code.\nIt has the following rules:\n\n* configuration message written in JSON with specific format.\n* if the message is found but the language code is not, will return by the default language code that was set up previously.\n* if the message is not found, will return the message.\n\n## Requirements\n\nGo programming language\n\n## JSON Format\n```\n{\n  \"en\": {\n    \"Good morning\": \"Good morning\"\n  },\n  \"id\": {\n    \"Good morning\": \"Selamat pagi\"\n  },\n  \"jp\": {\n    \"Good morning\": \"おはようございます\"\n  }\n}\n\n```\n\n## Getting Started\n\nThe go-localization package mainly includes a set of methods for managing the data. You use \nmethod `language.New()` to init the data, and you can call some method to bind config\n\n```\ncfg := language.New()\n// path to look for the language file in\ncfg.BindPath(\"./language.json\")\n// call multiple times to add many search paths\ncfg.BindPath(\"/home/appname/language.json\")\ncfg.BindMainLocale(\"en\")\n```\n \nIf you want to user the message convert function, start with the init function\n\n````\nlang, err := cfg.Init()\nif err != nil {\n\tpanic(err)\n}\n\n// print some message in different languages\nfmt.Println(lang.Lookup(\"en\", \"Good morning\"))\nfmt.Println(lang.Lookup(\"id\", \"Good morning\"))\nfmt.Println(lang.Lookup(\"jp\", \"Good morning\"))\n// if language not found, will return default language\nfmt.Println(lang.Lookup(\"fr\", \"Good morning\"))\n// print unlisted message\nfmt.Println(lang.Lookup(\"en\", \"Good night\"))\n````\n\n### Installation\n\nRun the following command to install the package:\n\n```\ngo get github.com/moemoe89/go-localization\n```\n\n### Example\n\nYou can find a example for the implementation at [example](https://github.com/moemoe89/go-localization/blob/master/example/main.go) repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoemoe89%2Fgo-localization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoemoe89%2Fgo-localization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoemoe89%2Fgo-localization/lists"}