> I've been thinking about how I can setup an internationalised (i18n)
> Postgres schema. There doesn't seem to be too much documented, and lots of
> references refer to duplicating tables (e.g. `posts_en` and `posts_fr` where
> you switch your SQL joins based on the language you want. This just feels
> like you'll end up with more tables than you can keep track of.
imho, you should have a `post_translations` table, with columns
`post_id`, referencing `posts` table, and `lang` specifying teh
language.
you would then be able to:
Post.has_many(:post_translations)
Post[666].post_translations_dataset.where(lang: :anything_you_want)
# or perhaps
PostTranslation.subset(:fr, lang: :fr)
PostTranslation.subset(:en, lang: :en)
Post[666].post_translations_dataset.fr.first
Post[666].post_translations_dataset.en.first
> Similarly there are suggestions of creating a master translation table which
> references tables and fields where you'd store an "override" for a default
> field value - this doesn't seem particularly good practice for a relational
> structure.
wat idk if i get wat u mean, but this approach seems reasonable
> Reading this
> (http://undefined-reference.org/2016/04/01/translateable-attributes-data.html)
> yielded a Gem (https://github.com/olegantonyan/translateable) that bolts on
> to ActiveRecord allowing you to switch to have your model to reference
> `@post.title` but having the `posts.title` table field as a JSONB
> (postgres!) field that looks like {"en":"My Post Title", "fr":"Title de
> Post"} (sorry!) - ActiveRecord, with this gem, uses the setting you've given
> the I18n gem to select the right JSONB key. This has the added benefit of
> you not having to reference @post.title_en or @post.title_fr etc.
>
> To wrap up a rambling post - does this seem a reasonably sensible solution
> to the i18n problem, and would porting the Plugin to Sequel be worthwhile?
no
--
Igor
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.