|
1 | 1 | # Changelog |
2 | 2 |
|
| 3 | +## v0.26.0 |
| 4 | + |
| 5 | +This release changes the way you use Gettext. We're not crazy: it does so because doing so makes it a lot faster to compile projects that use Gettext. |
| 6 | +The changes *you* have to make to your code are minimal, and the old behavior is deprecated so that you will be guided on how to update. |
| 7 | + |
| 8 | +The reason for this change is that it removes compile-time dependencies from modules that used to `import` a Gettext backend. In applications such as Phoenix applications, where every view and controller `import`s the Gettext backend, this change means a lot less compilation when you make translation changes! |
| 9 | + |
| 10 | +Here's the new API. Now, instead of defining a Gettext backend (`use Gettext`) and then `import`ing that to use its macros, you need to: |
| 11 | + |
| 12 | + 1. Define a Gettext backend with `use Gettext.Backend` |
| 13 | + 1. Import and use its macros with `use Gettext, backend: MyApp.Gettext`. |
| 14 | + |
| 15 | +### Before and After |
| 16 | + |
| 17 | +Before this release, code using Gettext used to look something like this: |
| 18 | + |
| 19 | +```elixir |
| 20 | +defmodule MyApp.Gettext do |
| 21 | + use Gettext, otp_app: :my_app |
| 22 | +end |
| 23 | + |
| 24 | +defmodule MyAppWeb.Controller do |
| 25 | + import MyApp.Gettext |
| 26 | +end |
| 27 | +``` |
| 28 | + |
| 29 | +This creates a compile-time dependency for every module that `import`s the Gettext backend. |
| 30 | + |
| 31 | +With this release, the above turns into: |
| 32 | + |
| 33 | +```elixir |
| 34 | +defmodule MyApp.Gettext do |
| 35 | + use Gettext.Backend, otp_app: :my_app |
| 36 | +end |
| 37 | + |
| 38 | +defmodule MyAppWeb.Controller do |
| 39 | + use Gettext, backend: MyApp.Gettext |
| 40 | +end |
| 41 | +``` |
| 42 | + |
| 43 | +We are also updating [Phoenix](https://github.com/phoenixframework/phoenix) generators to use the new API. |
| 44 | + |
| 45 | +If you update Gettext and still use `use Gettext, otp_app: :my_app` to define a backend, Gettext will emit a warning now. |
| 46 | + |
| 47 | +### Detailed Changelog |
| 48 | + |
| 49 | +This is a detailed list of the new things introduced in this release: |
| 50 | + |
| 51 | + * Add `Gettext.Macros`, which contains all the macros you know and love (`*gettext`). It also contains `*gettext_with_backend` variants to explicitly pass a backend at compile time and keep extraction working. |
| 52 | + * Document `lgettext/5` and `lngettext/7` callbacks in `Gettext.Backend`. These get generated in every Gettext backend. |
| 53 | + * Add the `Gettext.domain/0` type. |
| 54 | + |
3 | 55 | ## v0.25.0 |
4 | 56 |
|
5 | 57 | * Run merging for `mix gettext.extract`'s POT files even if they are unchanged. |
|
0 commit comments