@@ -78,11 +78,11 @@ defmodule Gettext do
7878
7979 ## Gettext API
8080
81- To use `Gettext`, a module that calls `use Gettext` (referred to below as a
81+ To use `Gettext`, a module that calls `use Gettext.Backend ` (referred to below as a
8282 "backend") has to be defined:
8383
8484 defmodule MyApp.Gettext do
85- use Gettext, otp_app: :my_app
85+ use Gettext.Backend , otp_app: :my_app
8686 end
8787
8888 This automatically defines some macros in the `MyApp.Gettext` backend module.
@@ -627,55 +627,16 @@ defmodule Gettext do
627627
628628 @ doc false
629629 defmacro __using__ ( opts ) do
630- # From Elixir v1.13 onwards, use compile_env
631- env_fun = if function_exported? ( Module , :attributes_in , 1 ) , do: :compile_env , else: :get_env
632-
633630 quote do
634- require Logger
635-
636631 opts = unquote ( opts )
637- otp_app = Keyword . fetch! ( opts , :otp_app )
638-
639- @ gettext_opts opts
640- |> Keyword . merge ( Application . unquote ( env_fun ) ( otp_app , __MODULE__ , [ ] ) )
641- |> Keyword . put_new ( :interpolation , Gettext.Interpolation.Default )
642-
643- @ interpolation Keyword . fetch! ( @ gettext_opts , :interpolation )
644-
645- @ before_compile Gettext.Compiler
646-
647- def handle_missing_bindings ( exception , incomplete ) do
648- _ = Logger . error ( Exception . message ( exception ) )
649- incomplete
650- end
651-
652- defoverridable handle_missing_bindings: 2
653632
654- def handle_missing_translation ( _locale , domain , _msgctxt , msgid , bindings ) do
655- Gettext.Compiler . warn_if_domain_contains_slashes ( domain )
656-
657- with { :ok , interpolated } <- @ interpolation . runtime_interpolate ( msgid , bindings ) ,
658- do: { :default , interpolated }
659- end
660-
661- def handle_missing_plural_translation (
662- _locale ,
663- domain ,
664- _msgctxt ,
665- msgid ,
666- msgid_plural ,
667- n ,
668- bindings
669- ) do
670- Gettext.Compiler . warn_if_domain_contains_slashes ( domain )
671- string = if n == 1 , do: msgid , else: msgid_plural
672- bindings = Map . put ( bindings , :count , n )
673-
674- with { :ok , interpolated } <- @ interpolation . runtime_interpolate ( string , bindings ) ,
675- do: { :default , interpolated }
633+ if Keyword . has_key? ( opts , :backend ) do
634+ raise "not implemented yet"
635+ else
636+ # TODO: Deprecate this branch
637+ require Gettext.Backend
638+ Gettext.Backend . __using__ ( opts )
676639 end
677-
678- defoverridable handle_missing_translation: 5 , handle_missing_plural_translation: 7
679640 end
680641 end
681642
0 commit comments