elixir-gettext / gettext

Internationalization and localization support for Elixir.
https://hexdocs.pm/gettext
469 stars 87 forks source link

Configurable default domain? #253

Closed halostatue closed 4 years ago

halostatue commented 4 years ago

I’ve been working with a couple of different JS implementations of gettext (before rolling a fork of one of them to work better with Vue), and it appears that most JS implementations use messages as their default domain—and have an easy way to change the active default domain.

As best as I can tell, this would be set by calling textdomain(domainname) in the C version of gettext. What I think would be useful would be providing a domain value to use Gettext:

defmodule MyApp.Gettext do
  use Gettext, otp_app: :my_app, domain: "messages"
end

I can work up a PR for this if that makes sense.

josevalim commented 4 years ago

Sounds good to me. Let’s call it default_domain though!

halostatue commented 4 years ago

Should this be global or per-backend? I’m leaning toward per-backend, but it won’t be hard to make it work like :default_locale.

halostatue commented 4 years ago

Also, I’m looking at this and assuming that Gettext.gettext/3 would always use "default", or should it use dgettext(backend, binding.__gettext__(:default_domain), magic, bindings)?