{"id":16415425,"url":"https://github.com/elixir-gettext/gettext","last_synced_at":"2025-05-14T16:02:35.356Z","repository":{"id":28404368,"uuid":"31918746","full_name":"elixir-gettext/gettext","owner":"elixir-gettext","description":"Internationalization and localization support for Elixir.","archived":false,"fork":false,"pushed_at":"2024-12-22T17:29:27.000Z","size":1079,"stargazers_count":478,"open_issues_count":7,"forks_count":90,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-11T05:13:28.745Z","etag":null,"topics":["elixir","elixir-lang","elixir-library","gettext","i18n","internationalization","l10n","localization","translation"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/gettext","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elixir-gettext.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2015-03-09T19:41:44.000Z","updated_at":"2025-02-14T10:40:33.000Z","dependencies_parsed_at":"2023-02-12T11:16:37.749Z","dependency_job_id":"e24a5a3d-df19-4e8a-8502-c85271b631c9","html_url":"https://github.com/elixir-gettext/gettext","commit_stats":{"total_commits":661,"total_committers":63,"mean_commits":"10.492063492063492","dds":0.313161875945537,"last_synced_commit":"b41445ea04da137c62fb7ebc822fd8f05f2353fa"},"previous_names":["elixir-lang/gettext"],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-gettext%2Fgettext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-gettext%2Fgettext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-gettext%2Fgettext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-gettext%2Fgettext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-gettext","download_url":"https://codeload.github.com/elixir-gettext/gettext/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345268,"owners_count":21088245,"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":["elixir","elixir-lang","elixir-library","gettext","i18n","internationalization","l10n","localization","translation"],"created_at":"2024-10-11T07:05:40.969Z","updated_at":"2025-04-11T05:13:34.076Z","avatar_url":"https://github.com/elixir-gettext.png","language":"Elixir","readme":"# Gettext\n\n[![hex.pm badge](https://img.shields.io/badge/Package%20on%20hex.pm-informational)](https://hex.pm/packages/gettext)\n[![Documentation badge](https://img.shields.io/badge/Documentation-ff69b4)][docs-gettext]\n![CI badge](https://github.com/elixir-gettext/gettext/workflows/CI/badge.svg)\n\nGettext is an **internationalization** (i18n) and **localization** (l10n) system commonly used for writing multilingual programs. Gettext is a standard for i18n in different communities, meaning there is a great set of tooling for developers and translators. This project is an implementation of the Gettext system in Elixir.\n\n## Installation\n\nAdd `:gettext` to your list of dependencies in `mix.exs` (use `$ mix hex.info gettext` to find the latest version):\n\n```elixir\ndefp deps do\n  [\n    {:gettext, \"\u003e= 0.0.0\"}\n  ]\nend\n```\n\nDocumentation for `Gettext` is [available on Hex][docs-gettext].\n\n## Usage\n\nTo use Gettext, define a **Gettext backend**:\n\n```elixir\ndefmodule MyApp.Gettext do\n  use Gettext.Backend, otp_app: :my_app\nend\n```\n\nand invoke the Gettext API, which consists of the `*gettext` macros that get imported if you `use Gettext`:\n\n```elixir\nuse Gettext, backend: MyApp.Gettext\n\n# Simple message\ngettext(\"Here is one string to translate\")\n\n# Plural message\nnumber_of_apples = 4\nngettext(\"The apple is ripe\", \"The apples are ripe\", number_of_apples)\n\n# Domain-based message\ndgettext(\"errors\", \"Here is an error message to translate\")\n```\n\nMessages in Gettext are stored in Portable Object files (`.po`). Such files must be placed at `priv/gettext/LOCALE/LC_MESSAGES/DOMAIN.po`, where `LOCALE` is the locale and `DOMAIN` is the domain (the default domain is called `default`).\n\nFor example, the messages for `pt_BR` from the first two `*gettext` calls in the snippet above must be placed in the `priv/gettext/pt_BR/LC_MESSAGES/default.po` file with the following contents:\n\n```pot\nmsgid \"Here is one string to translate\"\nmsgstr \"Aqui está um texto para traduzir\"\n\nmsgid \"Here is the string to translate\"\nmsgid_plural \"Here are the strings to translate\"\nmsgstr[0] \"Aqui está o texto para traduzir\"\nmsgstr[1] \"Aqui estão os textos para traduzir\"\n```\n\n`.po` files are text-based and can be edited directly by translators. Some may even use existing tools for managing them, such as [Poedit][poedit] or [poeditor.com][poeditor.com].\n\nFinally, because messages are based on strings, your source code does not lose readability as you still see literal strings, like `gettext(\"here is an example\")`, instead of paths like `translate(\"some.path.convention\")`.\n\nRead the [documentation for the `Gettext` module][docs-gettext-module] for more information on locales, interpolation, pluralization, and other features.\n\n## Workflow\n\nGettext is able to automatically extract messages from your source code, alleviating developers and translators from the repetitive and error-prone work of maintaining message files.\n\nWhen extracted from source, Gettext places messages into `.pot` files, which are template files. You can then merge those templates files into message files for each specific locale your application is being currently translated to.\n\nIn other words, the typical workflow looks like this:\n\n  1. Add `gettext` calls to your source code. No need to touch message files\n     at this point as Gettext will return the given string if no message is\n     available:\n\n     ```elixir\n     gettext(\"Welcome back!\")\n     ```\n\n  2. Once changes to the source are complete, automatically sync all existing entries to `.pot` (template files) in `priv/gettext` by running:\n\n     ```bash\n     mix gettext.extract\n     ```\n\n  3. You can then merge `.pot` files into locale-specific `.po` files:\n\n     ```bash\n     # Merge .pot into all locales\n     mix gettext.merge priv/gettext\n\n     # Merge .pot into one specific locale\n     mix gettext.merge priv/gettext --locale en\n     ```\n\nIt is also possible to both extract and merge messages in one step with `mix gettext.extract --merge`.\n\n## License\n\nCopyright 2015 Plataformatec\nCopyright 2020 Dashbit\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at:\n\n  \u003e \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n[docs-gettext]: http://hexdocs.pm/gettext\n[docs-gettext-module]: http://hexdocs.pm/gettext/Gettext.html\n[poedit]: http://poedit.net/\n[poeditor.com]: https://poeditor.com\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-gettext%2Fgettext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-gettext%2Fgettext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-gettext%2Fgettext/lists"}