Yoga
Can't find i18n in Phoenix docs
Maybe I am doing something wrong but I can’t find anything about i18n in Phoenix docs.
Also, I have noticed, that for some reason the lang tag is hardcoded in the default root template as “en”.
Also, I can’t find anything about locales, default_locale, fallback_locale as in other frameworks like Laravel.
I do see gettext folder.
Why is there gettext folder and locales are completely missing?
Also, is there a tutorial on how to setup a Phoenix app with a typical urls like / and /de/ and /ua/ ?
I have checked LiveView help and there, also, is nothing about making the website multilingual.
Most Liked
LostKobrakai
Phoenix uses the gettext library to do i18n. You can find its documentation here: Gettext — gettext v1.0.2
al2o3cr
Like @LostKobrakai said, most of the docs you’ll need are under the Gettext library.
I found this tutorial that looks useful; it demonstrates doing the URL-locale thing:
Yoga
How do you make
<html lang="en">
dynamic and not hardcoded in root template using LiveView?
In Laravel it is done like this:
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
How do you achieve this in Phoenix?
And again, why isn’t it already there in the first place? Together with the locales and default locale? For example, in Laravel it is set in config/app.php file, namely locale, default_locale, fallback_locale and faker_locale. I mean at least the locale could be put in config/config.exs somewhere by default ;(
As it is now, it seems half baked meaning you got gettext but you are missing locales and local is hardcoded in the root template file.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








