lalabuy948 / PhoenixAnalytics

📊 Plug and play analytics for Phoenix applications.
https://theindiestack.com/analytics
Apache License 2.0
270 stars 10 forks source link

Update Gettext usage to address deprecation warning #6

Closed cbuctok closed 2 months ago

cbuctok commented 2 months ago

Description

During compilation, the following deprecation warning is encountered:

warning: defining a Gettext backend by calling

    use Gettext, otp_app: ...

is deprecated. To define a backend, call:

    use Gettext.Backend, otp_app: :my_app

Then, instead of importing your backend, call this in your module:

    use Gettext, backend: MyApp.Gettext

  lib/phoenix_analytics/web/gettext.ex:4: PhoenixAnalytics.Web.Gettext (module)

This warning suggests that our current Gettext implementation is using a deprecated approach.

Current Implementation

The current implementation uses:

defmodule PhoenixAnalytics.Web.Gettext do
  @moduledoc false

  use Gettext, otp_app: :phoenix_analytics
end

Proposed Solution

To resolve this deprecation warning, we should update our Gettext usage as follows:

  1. In lib/phoenix_analytics/web/gettext.ex:
defmodule PhoenixAnalytics.Web.Gettext do
  @moduledoc false

  use Gettext.Backend, otp_app: :phoenix_analytics
end
  1. In modules where Gettext is currently imported, replace:
import PhoenixAnalytics.Web.Gettext

with:

use Gettext, backend: PhoenixAnalytics.Web.Gettext

Benefits

Additional Notes

lalabuy948 commented 2 months ago

Resoled in 0.1.3