wolfiton
Multilanguge CMS database schema, ideas, opinions
Hi everyone,
I only found this on this topic How to approach multi language content management system?
and wondering if in 2020 there is a better way to structure the database schema except for embedding the translations in the article table?
How would you solve this problem?
Any suggestion or ideas is welcomed.
I am also interested in using absinthe and phoenix templates apps how to handle this?
Thanks in adavance
First Post!
OvermindDL1
Without having read that link I’d do it by having a column that encodes the language key as well, makes it for easy and efficient lookup, making it trivial to even fall back to another with minimal network use compared to embedding and so forth.
Most Liked
kokolegorille
For the table, I would add a translation table, if You don’t want to embed translation…
create table(:posts) do
add :title, :string
add :content, :string
add :published, :boolean, default: false, null: false
timestamps()
end
create table(:posts_translations) do
add :post_id, references(:posts, on_delete: :delete_all)
add :language_id, references(:languages, on_delete: :nothing)
# Add fields You want to translate
add :title, :string
add :content, :string
timestamps()
end
This is more or less what globalize does.
OvermindDL1
I’ve generally seen both a side translation table and an embedded translation thing as crutches for fixing up originally broken designs. Designing the tables with the translation keys from the start is far superior as there is less joining, more efficient indexes, etc…
kip
ex_cldr handles RFC compliant language tags and also manages fallbacks to supported languages. For a somewhat extreme example:
iex> MyApp.Cldr.validate_locale "en-AU-u-nu-latn-cu-AUD-cf-account-tz-ausyd"
{:ok,
%Cldr.LanguageTag{
canonical_locale_name: "en-Latn-AU",
cldr_locale_name: "en",
extensions: %{},
gettext_locale_name: nil,
language: "en",
language_subtags: [],
language_variant: nil,
locale: %{
currency: :AUD,
currency_format: :accounting,
number_system: :latn,
timezone: "Australia/Sydney"
},
private_use: [],
rbnf_locale_name: "en",
requested_locale_name: "en-AU",
script: "Latn",
territory: "AU",
transform: %{}
}}
Which should tell you pretty much everything you need to know. And there are other related libs for format dates, numbers, units (and soon messages) etc as required.
Last Post!
wolfiton
Moved everything regarding WolfCMS here WolfCMS thread suggestions and help and discussions
Thanks for the help everyone and also for the great ideas
Popular in Discussions
Other popular topics
Latest Phoenix Threads
Chat & Discussions>Discussions
Latest on Elixir Forum
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









