{"id":21939190,"url":"https://github.com/grottopress/rex","last_synced_at":"2026-01-27T18:40:15.278Z","repository":{"id":85788214,"uuid":"434288898","full_name":"GrottoPress/rex","owner":"GrottoPress","description":"A simple i18n adapter interface for Crystal","archived":false,"fork":false,"pushed_at":"2025-06-06T13:35:46.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-06T14:31:26.706Z","etag":null,"topics":["crystal","i18n","l10n"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/GrottoPress.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2021-12-02T16:08:58.000Z","updated_at":"2025-06-06T13:35:48.000Z","dependencies_parsed_at":"2024-11-29T02:17:29.431Z","dependency_job_id":"fea0adc7-1f11-482e-abbb-2f5efda1f6bd","html_url":"https://github.com/GrottoPress/rex","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/GrottoPress/rex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Frex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Frex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Frex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Frex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrottoPress","download_url":"https://codeload.github.com/GrottoPress/rex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Frex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28818494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T18:01:38.485Z","status":"ssl_error","status_checked_at":"2026-01-27T18:01:27.499Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["crystal","i18n","l10n"],"created_at":"2024-11-29T02:17:19.030Z","updated_at":"2026-01-27T18:40:15.249Z","avatar_url":"https://github.com/GrottoPress.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rex\n\n**Rex** is a simple *i18n* adapter interface for *Crystal*. It allows a shard to define translatable text, enabling apps that `require` the shard to use any *i18n* shard of choice as backend.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     rex:\n       github: GrottoPress/rex\n   ```\n\n1. Run `shards update`\n\n1. Require *Rex*:\n\n   ```crystal\n   # ...\n   require \"rex\"\n   # ...\n   ```\n\n## Usage\n\n1. Call the *i18n* helpers in your shard as required:\n\n   ```crystal\n   # Translation\n   Rex.t(:some_key, name: \"Ama\")\n   Rex.t(\"some_key\", {name: \"John\"})\n   Rex.t(\"some.key\", 45, \"Judith\")\n   Rex.t(:another_key)\n\n   # Localization\n   Rex.l(Time.utc)\n   Rex.l(123_456, :arg)\n   ```\n\n1. The consumer application defines their adapter:\n\n   ```crystal\n   # -\u003e\u003e\u003e src/config/i18n.cr\n\n   require \"some_i18n_shard\"\n\n   struct SomeAppI18nAdapter\n     include Rex::Adapter\n\n     def translate(key : String | Symbol, *args) : String\n       # You may use any i18n shard as backend\n       Somei18nShard.translate(key, *args)\n     end\n\n     def localize(value, *args) : String\n       # You may use any i18n shard as backend\n       Somei18nShard.localize(value, *args)\n     end\n\n     # You may add more `#translate` and `#localize` overloads\n     # as needed\n   end\n   ```\n\n1. The consumer application configures *Rex* to use this adapter:\n\n   ```crystal\n   # -\u003e\u003e\u003e src/config/i18n.cr\n\n   Rex.configure do |settings|\n     settings.adapter = SomeAppI18nAdapter.new\n   end\n   ```\n\n   If the i18n backend evaluates translations at compile time (eg: [Rosetta](https://github.com/wout/rosetta)), the application should define a `Rex.t` macro instead:\n\n   ```crystal\n   # -\u003e\u003e\u003e src/config/i18n.cr\n\n   module Rex\n     macro t(text, **named_args)\n       Rosetta.find({{ text.id.stringify }})\n         .t({{ named_args unless named_args.empty? }})\n     end\n   end\n   ```\n\n1. The consumer application sets up translations according to whatever backend they are using.\n\n### Testing\n\n*Rex* comes with `Rex::DevAdapter` which may be used for tests:\n\n```crystal\n# -\u003e\u003e\u003e spec/my_app/spec_helper.cr\n\nRex.configure do |settings|\n  settings.adapter = Rex::DevAdapter.new\nend\n```\n\n```crystal\n# -\u003e\u003e\u003e spec/my_app/some_spec.cr\n\n# `Rex::DevAdapter` returns the key passed to `Rex.t` unchanged\nRex.t(:some_key, {name: \"Kwame\"}).should(eq \"some_key\")\n```\n\n## Development\n\nRun tests with `crystal spec`.\n\n## Contributing\n\n1. [Fork it](https://github.com/GrottoPress/rex/fork)\n1. Switch to the `master` branch: `git checkout master`\n1. Create your feature branch: `git checkout -b my-new-feature`\n1. Make your changes, updating changelog and documentation as appropriate.\n1. Commit your changes: `git commit`\n1. Push to the branch: `git push origin my-new-feature`\n1. Submit a new *Pull Request* against the `GrottoPress:master` branch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrottopress%2Frex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrottopress%2Frex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrottopress%2Frex/lists"}