Skip to content

Commit

Permalink
Rename translation to message and expand short variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Jul 20, 2022
1 parent 8e5594d commit e131109
Show file tree
Hide file tree
Showing 28 changed files with 597 additions and 578 deletions.
42 changes: 21 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
## v0.19.1

* Fix warnings on Elixir v1.14+
* Rename `ex-autogen` to `elixir-autogen` and make sure `elixir-autogen` is added to existing translations
* Rename `ex-autogen` to `elixir-autogen` and make sure `elixir-autogen` is added to existing messages

## v0.19.0

* Remove the `:one_module_per_locale` option in favor of `:split_module_by`
and `:split_module_compilation`
* Make `Gettext.dngettext/6` bindings argument optional (effectively
introducing `Gettext.dngettext/5`)
* Preserve the `fuzzy` translation flag when merging
* Preserve the `fuzzy` message flag when merging
* Add the `--check-unextracted` flag to `mix gettext.extract`, which is useful
in CI and similar
* Place each translation reference on its own line in extracted PO files
* Place each message reference on its own line in extracted PO files
* Make the interpolation module customizable via the `:interpolation`
configuration option
* Use a different flag to detect autogenerated translations (`ex-autogen`)
* Use a different flag to detect autogenerated messages (`ex-autogen`)
* Update `gettext.extract` to correctly extract on recompilation for Elixir
1.13+

Expand Down Expand Up @@ -66,11 +66,11 @@

## v0.17.1

* Store the `msgctxt` value in translation and dump it when dumping
translations
* Store the `msgctxt` value in message and dump it when dumping
messages
* Fix a bug when dumping references
* Improve code generation
* Preserve whitespace in translation flags
* Preserve whitespace in message flags

## v0.17.0

Expand All @@ -90,17 +90,17 @@

## v0.15.0

* Generate correct plural forms when dumping new translations in PO files
* Generate correct plural forms when dumping new messages in PO files
* Fix a bug where we were losing translator comments for fuzzy-merged
translations
messages
* Don't make an exact match when merging prevent later fuzzy matches
* Allow multiple translations to fuzzy-match against the same translation when
* Allow multiple messages to fuzzy-match against the same message when
merging
* Bump the Elixir requirement to v1.4 and on

## v0.14.1

* Copy flags from existing translations when merging translations
* Copy flags from existing messages when merging messages

## v0.14.0

Expand All @@ -112,7 +112,7 @@
* Improve compilation time of Gettext backends in roughly 20%
* Add `:one_module_per_locale` for parallel compilation of backends (requires
Elixir v1.6)
* Use the `elixir-format` flag to mark autogenerated translations
* Use the `elixir-format` flag to mark autogenerated messages

## v0.13.1

Expand All @@ -124,16 +124,16 @@

* Add the `gettext_noop/1`, `dgettext_noop/2`, `ngettext_noop/3`, and
`dngettext_noop/4` macros to Gettext backends. These macros can be used to
mark translations for extractions without translating the given string
mark messages for extractions without translating the given string

## v0.12.2

* Fix a bug where we failed miserably with a "no process" error when
extracting translations without having the `:gettext` compiler run
extracting messages without having the `:gettext` compiler run
* Slightly revisit the indentation of subsequent literal strings in dumped
PO(T) files; before, they were dumped one per line, indented one level more
than the parent translation, while now they're indented at the same level as
the parent translation
than the parent message, while now they're indented at the same level as
the parent message

## v0.12.1

Expand All @@ -145,7 +145,7 @@
* Add `:compiler_po_wildcard` to explicitly choose the po files that are
tracked by the compiler
* Allow the developer to configure what happens when there are missing
bindings in the translation. The default has been changed to log and return
bindings in the message. The default has been changed to log and return
the incomplete string instead of raising
* Move the configuration for the `:gettext` application to compile-time config
in `project/0` in `mix.exs` (under the `:gettext` key, with configuration
Expand All @@ -161,7 +161,7 @@
* No longer traverse directories given to `gettext.merge` recursively (from
now on `gettext.merge` expect specific locale directories)
* Re enable the "compile" task in `mix gettext.extract`
* Ensure translations are tracked to the proper child app when using umbrella
* Ensure messages are tracked to the proper child app when using umbrella
apps

## v0.11.0
Expand Down Expand Up @@ -201,8 +201,8 @@
compile-time strings in the form of `~s`/`~S` sigils.
* Create missing locale directories (for example, `en/LC_MESSAGES`) when
running the `gettext.merge` Mix task.
* Fallback to default translations (that is, the `msgid`) when the `msgstr`
(or one or more `msgstr` strings for plural translations) is empty.
* Fallback to default messages (that is, the `msgid`) when the `msgstr`
(or one or more `msgstr` strings for plural messages) is empty.

## v0.7.0

Expand All @@ -227,7 +227,7 @@

* Add a `:flags` field to the `Gettext.PO.Translation` and
`Gettext.PO.PluralTranslation` structs
* Add support for fuzzy matching translations in `gettext.merge` and
* Add support for fuzzy matching messages in `gettext.merge` and
`gettext.extract --merge`
* Add the `:fuzzy_threshold` configuration option for the `:gettext`
application
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ and invoke the Gettext API, which consists of the `*gettext` macros:
```elixir
import MyApp.Gettext

# Simple translation
# Simple message
gettext("Here is one string to translate")

# Plural translation
# Plural message
number_of_apples = 4
ngettext("The apple is ripe", "The apples are ripe", number_of_apples)

# Domain-based translation
# Domain-based message
dgettext("errors", "Here is an error message to translate")
```

Translations 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`).
Messages 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`).

For example, the translation to `pt_BR` of the first two `*gettext` calls in the snippet above must be placed in the `priv/gettext/pt_BR/LC_MESSAGES/default.po` file with contents:
For example, the message to `pt_BR` of the first two `*gettext` calls in the snippet above must be placed in the `priv/gettext/pt_BR/LC_MESSAGES/default.po` file with contents:

```pot
msgid "Here is one string to translate"
Expand All @@ -60,20 +60,20 @@ msgstr[1] "Aqui estão os textos para traduzir"

`.po` are text-based files 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].

Finally, because translations 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")`.
Finally, 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")`.

Read the [documentation for the `Gettext` module][docs-gettext-module] for more information on locales, interpolation, pluralization, and other features.

## Workflow

Gettext is able to automatically extract translations from your source code, alleviating developers and translators from the repetitive and error-prone work of maintaining translation files.
Gettext 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.

When extracted from source, translations are placed into `.pot` files, which are template files. Those templates files can then be merged into translation files for each specific locale your application is being currently translated to.
When extracted from source, messages are placed into `.pot` files, which are template files. Those templates files can then be merged into message files for each specific locale your application is being currently translated to.

In other words, the typical workflow looks like this:

1. Add `gettext` calls to your source code. No need to touch translation files
at this point as Gettext will return the given string if no translation is
1. Add `gettext` calls to your source code. No need to touch message files
at this point as Gettext will return the given string if no message is
available:

```elixir
Expand All @@ -96,7 +96,7 @@ In other words, the typical workflow looks like this:
mix gettext.merge priv/gettext --locale en
```

It is also possible to both extract and merge translations in one step with `mix gettext.extract --merge`.
It is also possible to both extract and merge messages in one step with `mix gettext.extract --merge`.

## License

Expand Down

0 comments on commit e131109

Please sign in to comment.