From 972499d9a0e11083c23ead94c7f4451ae8c398d8 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Wed, 4 Sep 2024 09:12:02 -0400 Subject: [PATCH] Update gettext (#583) * Update Gettext Use the backend module to remove warnings --- CHANGELOG.md | 3 +++ lib/beacon/gettext.ex | 4 ++++ lib/beacon/web/components/core_components.ex | 6 +++--- lib/beacon/web/gettext.ex | 4 ---- lib/beacon_web.ex | 2 +- mix.exs | 2 +- mix.lock | 4 ++-- 7 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 lib/beacon/gettext.ex delete mode 100644 lib/beacon/web/gettext.ex diff --git a/CHANGELOG.md b/CHANGELOG.md index f23ed566..a757de86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.1.0-dev +### Breaking Changes + * Require minimum Gettext v0.26 to use the new backend module + ## 0.1.0-rc.1 (2024-08-27) ### Enhancements diff --git a/lib/beacon/gettext.ex b/lib/beacon/gettext.ex new file mode 100644 index 00000000..ba3c0b1e --- /dev/null +++ b/lib/beacon/gettext.ex @@ -0,0 +1,4 @@ +defmodule Beacon.Gettext do + @moduledoc false + use Gettext.Backend, otp_app: :beacon +end diff --git a/lib/beacon/web/components/core_components.ex b/lib/beacon/web/components/core_components.ex index 240e4755..ca1be3bd 100644 --- a/lib/beacon/web/components/core_components.ex +++ b/lib/beacon/web/components/core_components.ex @@ -6,7 +6,7 @@ defmodule Beacon.Web.CoreComponents do use Phoenix.Component alias Phoenix.LiveView.JS - import Beacon.Web.Gettext + use Gettext, backend: Beacon.Gettext @doc """ Renders a modal. @@ -629,9 +629,9 @@ defmodule Beacon.Web.CoreComponents do # with our gettext backend as first argument. Translations are # available in the errors.po file (as we use the "errors" domain). if count = opts[:count] do - Gettext.dngettext(Beacon.Web.Gettext, "errors", msg, msg, count, opts) + Gettext.dngettext(Beacon.Gettext, "errors", msg, msg, count, opts) else - Gettext.dgettext(Beacon.Web.Gettext, "errors", msg, opts) + Gettext.dgettext(Beacon.Gettext, "errors", msg, opts) end end diff --git a/lib/beacon/web/gettext.ex b/lib/beacon/web/gettext.ex deleted file mode 100644 index b6ef32a5..00000000 --- a/lib/beacon/web/gettext.ex +++ /dev/null @@ -1,4 +0,0 @@ -defmodule Beacon.Web.Gettext do - @moduledoc false - use Gettext, otp_app: :beacon -end diff --git a/lib/beacon_web.ex b/lib/beacon_web.ex index bcc31986..3c274380 100644 --- a/lib/beacon_web.ex +++ b/lib/beacon_web.ex @@ -46,7 +46,7 @@ defmodule Beacon.Web do layouts: [html: Beacon.Web.Layouts] import Plug.Conn - import Beacon.Web.Gettext + use Gettext, backend: Beacon.Gettext end end diff --git a/mix.exs b/mix.exs index 5261b5ce..2f3e4bb2 100644 --- a/mix.exs +++ b/mix.exs @@ -65,7 +65,7 @@ defmodule Beacon.MixProject do {:ex_aws, "~> 2.4.0"}, {:ex_aws_s3, "~> 2.4.0"}, {:floki, ">= 0.30.0"}, - {:gettext, "~> 0.20"}, + {:gettext, "~> 0.26"}, {:hackney, "~> 1.16"}, {:image, "~> 0.40"}, {:jason, "~> 1.0"}, diff --git a/mix.lock b/mix.lock index 84b6a499..574e0f16 100644 --- a/mix.lock +++ b/mix.lock @@ -21,10 +21,10 @@ "ex_brotli": {:hex, :ex_brotli, "0.4.1", "b9d43d1ba0641b460b8477b1dc20f224827651c5af5977419b92c4e63c27d619", [:mix], [{:phoenix, ">= 0.0.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:rustler, "~> 0.29", [hex: :rustler, repo: "hexpm", optional: true]}, {:rustler_precompiled, "~> 0.6", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "840eeace8354abfa470fa094b8b0231ef184f5692cd4b219143c403bcf8f0756"}, "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, "exconstructor": {:hex, :exconstructor, "1.2.13", "7021eed1450202dcbcd1ef021d6aacf7351854ff9d7964f166931567f9dfa9fb", [:mix], [], "hexpm", "69d3f0251a07bb7c5ef85bde22a1eee577dfbb49852d77fb7ad7b937035aeef2"}, - "expo": {:hex, :expo, "0.5.2", "beba786aab8e3c5431813d7a44b828e7b922bfa431d6bfbada0904535342efe2", [:mix], [], "hexpm", "8c9bfa06ca017c9cb4020fabe980bc7fdb1aaec059fd004c2ab3bff03b1c599c"}, + "expo": {:hex, :expo, "1.0.1", "f9e2f984f5b8d195815d52d0ba264798c12c8d2f2606f76fa4c60e8ebe39474d", [:mix], [], "hexpm", "f250b33274e3e56513644858c116f255d35c767c2b8e96a512fe7839ef9306a1"}, "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, "floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"}, - "gettext": {:hex, :gettext, "0.24.0", "6f4d90ac5f3111673cbefc4ebee96fe5f37a114861ab8c7b7d5b30a1108ce6d8", [:mix], [{:expo, "~> 0.5.1", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "bdf75cdfcbe9e4622dd18e034b227d77dd17f0f133853a1c73b97b3d6c770e8b"}, + "gettext": {:hex, :gettext, "0.26.1", "38e14ea5dcf962d1fc9f361b63ea07c0ce715a8ef1f9e82d3dfb8e67e0416715", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "01ce56f188b9dc28780a52783d6529ad2bc7124f9744e571e1ee4ea88bf08734"}, "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, "httpoison": {:hex, :httpoison, "2.2.1", "87b7ed6d95db0389f7df02779644171d7319d319178f6680438167d7b69b1f3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "51364e6d2f429d80e14fe4b5f8e39719cacd03eb3f9a9286e61e216feac2d2df"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},