zorn

zorn

Looking for gettext domain recommendations

Our team has started to add gettext localization function calls for various strings inside of our project. We are not actively translating but hedging our bets that we’d like to at some point in the not-too-distant future.

https://hexdocs.pm/gettext/Gettext.html#module-domains

We are currently discussing domain use and we don’t have strong guidance on how to best define the domain structure within our app. How many domains should we make? When is a domain too large? Why should we break up into domains?

There is a general feeling that we should avoid one single domain but I’d like to ask for feedback from folks who have actively translated a project in the past for what they recommend.

Most Liked

LostKobrakai

LostKobrakai

I don’t think size should matter at all. Preventing ambiguity is the driving factor for splitting up domains. You’d want to split appart where one an the same string might need to be translated differently.

linusdm

linusdm

I agree with the above. As an example, we’re building an application with two separate front-ends, hosted on two different subdomains for different users. But they share the same core (even go to the same context files and use the same ecto schema’s). The same error might be translated differently, as the message is presented to two different populations.

One “mechanical” separation we do is keeping enum translations in a separate domain. These can’t be extracted, and are translated with Gettext.dgettext/4.

But I wouldn’t overthink it. Being prepared by avoiding literal strings in the front-end is 99% of the work. And since it’s so easy to do when starting fresh, and such a pain to add later, I have the tendency to always go through gettext for messages in the front-end, even if only one language is used. Maybe I’m biased living in a country that has three official languages for 10M people, where language is always an issue :slight_smile:

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement