How can I use the linguist package with Phoenix? I'm trying to have internationalization in a web page. I have added the package to mix.exs and ran mix deps.get
with success.
Now, I don't know where in which folder to write the module file of the package as well as if it should be ex or exs in extension like the other country language file in the Usage case (fr.exs).
Also, after writing the module, how exactly would I apply it to my HTML tags?
Quickly looking at the readme it seems you specify the path to the local file in the locale
declaration when writing your I18n
module. It's this line:
locale "fr", Path.join([__DIR__, "fr.exs"])
In this case it says "look into the current directory for a file named 'fr.exs'", but you can specify whatever you want, for example something like this:
locale "fr", Path.join(["lib", "translations", "fr.exs"])
Then in your views you just call the functions on the I18n
module you defined, like the readme says:
<%= I18n.t!("fr", "greeting") %>
Have you looked at the sample code at the Linguist GitHub Page? You may also want to look at the phoenix_linguist github page as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With