{"id":21475154,"url":"https://github.com/snapp-incubator/barat","last_synced_at":"2026-01-11T03:04:20.790Z","repository":{"id":65544884,"uuid":"590415584","full_name":"snapp-incubator/barat","owner":"snapp-incubator","description":"Linter for localization","archived":false,"fork":false,"pushed_at":"2023-01-29T13:34:30.000Z","size":39,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-30T15:29:42.327Z","etag":null,"topics":["go-i18n","golang","i18n","localization","toml"],"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/snapp-incubator.png","metadata":{"files":{"readme":".github/README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2023-01-18T11:13:24.000Z","updated_at":"2023-01-29T20:34:25.000Z","dependencies_parsed_at":"2023-02-15T16:45:25.105Z","dependency_job_id":null,"html_url":"https://github.com/snapp-incubator/barat","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/snapp-incubator/barat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fbarat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fbarat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fbarat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fbarat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snapp-incubator","download_url":"https://codeload.github.com/snapp-incubator/barat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snapp-incubator%2Fbarat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28274292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T02:08:32.518Z","status":"ssl_error","status_checked_at":"2026-01-11T02:08:32.093Z","response_time":60,"last_error":"SSL_read: 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-i18n","golang","i18n","localization","toml"],"created_at":"2024-11-23T10:37:58.284Z","updated_at":"2026-01-11T03:04:20.784Z","avatar_url":"https://github.com/snapp-incubator.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](https://user-images.githubusercontent.com/49960770/214579375-0a8e1cee-d9cd-4cc5-9453-42aff2c26357.png)\n\n# Barat\nBarat is a linter for [localization in Golang](https://github.com/nicksnyder/go-i18n) projects. Barat check \nyour Toml files for missing keys and duplicate keys. Also, Barat can check your code for missing localization keys.\n\n## Installation\n\n```bash\ngo install github.com/snapp-incubator/barat@latest\n```\n\nYou can check all flags and helps by using this command:\n\n```bash\n$ barat lint --help \n\nUsage: barat lint\n\nCheck all toml file for validation and find message keys in code.\n\nFlags:\n  -h, --help                                          Show context-sensitive help.\n\n      --config-path=STRING                            Path to config file.\n      --toml-paths=TOML-PATHS,...                     paths to load toml files.\n  -e, --exclude-regex-keys=EXCLUDE-REGEX-KEYS,...     exclude keys that match the given regex.\n      --map-function-names-to-arg-no=KEY=VALUE;...    it's map of the function's name that returns the message by i18n To number of MessageID in arguments.\n      --project-path=STRING                           paths to project for check all files.\n      --exclude-folders=EXCLUDE-FOLDERS,...           list of exclude folders for check localization.\n```\n\n## How to use Barat\n\n### Check your toml files\nFor check your toml files, you should specify the path to your toml files by `--toml-paths` flag.\n\n```bash\nbarat lint --toml-paths \u003cpath to toml files\u003e, \u003cpath to toml files\u003e, ...\n```\n\nYou can exclude some keys from checking by adding them to the `--exclude-regex-keys` flag in your command.\n```bash \nbarat lint --toml-paths \u003cpath to toml files\u003e, \u003cpath to toml files\u003e, ... \\\n      --exclude-regex-keys=\"ExcludeKey\",\"key*\"\n```\n\nBarat support simple regex for exclude keys. When you use `*` in part of your regex, it will be replaced with `(.*?)`.\n\n### Check your code\nIf you want to check your code for missing localization keys, you can use this command:\n\n```bash\nbarat lint --toml-paths \u003cpath to toml files\u003e, \u003cpath to toml files\u003e, ... \\\n      --exclude-regex-keys=\"ExcludeKey\",\"key*\" \\ \n      --project-path \u003cpath to your project\u003e \\\n      --exclude-folders \u003cfolder name\u003e, \u003cfolder name\u003e, ... \\\n      --map-function-names-to-arg-no \"GetMessages=1;getMessage=0\"\n```\n\nWe describe the flags in the following table:\n\n| Flag                             | Description                                                   |\n|----------------------------------|---------------------------------------------------------------|\n| `--project-path`                 | Path to your project. Barat search recursive for `.go` files. |\n| `--exclude-folders`              | Folders that you want to exclude from checking.               |\n| `--map-function-names-to-arg-no` | Map function names to argument number of MessageID.           |\n\n### More details about `--map-function-names-to-arg-no`\n\nIn this flag, you can map function names to argument number of MessageID. For example, if you have a function like this:\n\n```go\n// GetMessages is function for getting internationalized messages.\nfunc GetMessages(lang string, messageID string, templateData interface{}) (string, error) {\n    loc := i18n.NewLocalizer(Bundle, lang)\n    return loc.Localize(\u0026i18n.LocalizeConfig{MessageID: messageID, TemplateData: templateData})\n}\n```\n\nYou can map this function to argument number 1 by adding this to your command:\n\n```bash\n--map-function-names-to-arg-no \"GetMessages=1\"\n```\n\nIt's imported to mention that the number of arguments in your function starts from 0.\n\n### Run Barat With Config File\n\nYou can run Barat with config file. You can create a file named `barat.yaml` in your project and add your config to it.\nAfter creating your config file, you can run Barat with this command:\n\n```bash\nbarat lint --config-path \u003cpath to your config file\u003e\n```\n\n#### Config File\n\nYou can use `barat.yml` in [Barat source code](https://github.com/snapp-incubator/barat/blob/master/barat.yml) as your\nconfig file template.\n\n```yaml\nproject-path: \"./project-path\"\n\ntoml-path:\n  - \"./project-path/toml/en\"\n  - \"./project-path/toml/fa\"\n  - \"./project-path/toml/ru\"\n\nexclude:\n  folders:\n    - \"vendor\"\n    - \"assets\"\n  regex-keys:\n    - \"ToBeExcludedKey1\"\n    - \"KeyToBe*\"\n\nmessage-functions:\n  - name: \"GetMessage\"\n    message-id-no: 1\n\noptions:\n  enable:\n    toml-check: true\n    description-check: true\n    other-key-check: true\n    code-check: true\n```\n\nMost part of the config file was described before. But we describe the `options.enable` part in the following:\n* toml-check\n    * if you set this to `false`, Barat will not check your toml files.\n* description-check\n    * if you set this to `false`, Barat will not check your toml files for missing descriptions.\n* other-key-check\n    * if you set this to `false`, Barat will not check your toml files for missing other keys.\n* code-check\n    * if you set this to `false`, Barat will not check your code for missing localization keys.\n\n#### Note: If you use config file, you can't use other flags. If you use other flags, Barat will ignore them.\n\n\n## Help Us\nYou can contribute to improving this tool by sending pull requests or issues on GitHub.  \nPlease send us your feedback. Thanks!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnapp-incubator%2Fbarat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnapp-incubator%2Fbarat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnapp-incubator%2Fbarat/lists"}