Internationalization

Great. Thank you so much!

I added the plugin and I can see it on the plugin’s page and in settings. I add a new locales (so I have two now, being EN the default one).

What’s next? I can’t see anything changed in the content builder OR when entering content.

How do I add another language copy for the same component?

Thanks

You need to activate i18n on your content type.
To do so, you need to go in the content type builder, click on the pencil icon next to the content type’s name, go to the advanced settings and check the “Enable localization for the content type” checkbox.

Then you can control the localisation of each field in the advanced tab of each attribute.

Here are some informations about the localisation:

  • when i18n is enable on a content type all relational fields are localised
  • the uid field will always be localised due to the unique constraint
  • dynamique zones and components can be localised
  • Unique fields must also be localised because of the unique constraint
2 Likes

That’s a bummer. I’d guess in most use cases an ID should identify objects independent of language.

3 Likes

It’s a hard requirement of how we store the information in the database while still keeping database constraints. Setting something as unique applies a database constraint and since all locales are stored in the same database table you can’t have two entries (say english and french) that share the same unique value.

Abstracting them out to different tables in the database means all relations become polymorphic in nature making relations extremely complicated to manage.

1 Like

Hey ! First of all, thanks for this amazing CMS.

As I do understand the requirement explained above, this is still a bummer.
It means there is no way to identify an entity with the same but unique textual attribute ?
Like a guid or sku attribute assigned to a product for example ?

Thanks for building Strapi <3 and adding the long-awaited localization feature.

This doesn’t make a lot of sense to me. Uniques should be the same across all locales, technically (coming from RDBMS background) this can be implemented as a unique constraint on two columns.

For those looking for a hack, I’m providing this sample from one of my products. On PostgreSQL I did the following to fix this on the database level:

alter table products
    drop constraint "products_SKU_unique"; // this query deletes the constraint created automatically by strapi

alter table products add constraint unique_sku_per_locale
unique ("SKU", locale); // this one creates a new unique constraint on two columns 

:warning: Please note that I didn’t test this on production yet and it might cause problems, so please make sure you know what you’re doing.

this way, SKU will only be required to be unique in one locale.

@soupette please consider rethinking this design,
Thanks!

Good intuition re: uniques across locales - it will immediately cause issues with things like NextJS’s dynamic static page generation. @soupette

I am still a bit unclear on how to migrate from _en, _fr to i18n plugin?
Is there a guide I can follow or this is all manual process?