What is the best appraoch to add data entries in a multilingual website, with products having translated tags in each language? #26702
Replies: 2 comments
|
The cleanest model is usually to separate the product identity from the localized presentation. Right now your
With Strapi i18n enabled, that means Strapi treats the English product and Persian product as two localized versions of the same content entry. That is expected behavior. If the What I would avoid is treating A better structure would be something like this: Product
- uniqueID: 123
- color: relation to Color
- usage: relation to Usage
- other non-translatable product fieldsThen: Color
- code: yellow
- label/name: yellow / زرد via i18nUsage
- code: wall
- label/name: wall / دیوار via i18nThe important part is that the product relates to the concept, not to the translated text. The translated text is only what you display to the user depending on the current locale. If Strapi’s i18n setup makes the localized Color EN
- code: yellow
- name: yellow
Color FA
- code: yellow
- name: زردThat way your application can treat For the
For your case, since A practical content model might be: Product
- uniqueID
- color -> Color
- usage -> Usage
- ...
Color
- key/code
- name/title localized
Usage
- key/code
- name/title localizedThen in your frontend, when rendering Persian, show the Persian localized The tradeoff is that you may need to handle the locale lookup in your query or frontend logic. For example, if a non-localized product relation shows both If you really need fully localized product pages later, another good pattern is: ---
If my answer solved your problem, you can click **answered the question**. I'm really here to help, and along the way I'm also collecting Galaxy Brain badges haha 😆 |
|
Keep i18n enabled on Product, and let Strapi's relation locale resolution do the work you are currently doing by hand. The behavior that helps you is documented but easy to miss: for relations whose target content type is localized, Strapi automatically resolves the relation to the corresponding entry in the target locale when it exists. Localized versions of an entry share the same So the setup becomes:
On the API side the same rule applies: query the product with The variant you tried, disabling i18n on Product entirely, breaks down exactly where you noticed: the relation picker has no locale to filter by, so it offers every localization of every tag. That is expected with a non-localized source relating to a localized target, and there is no admin setting to filter the picker by language in that configuration. The two-locale product with shared non-localized fields is the intended shape for your case, and after the field-level tweak the real duplicated work per product drops to one extra click plus verifying the tags resolved. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
My situation
I have a website in which I can add products as a collection type named Product, with each product having almost 11 tags and 1 text filed named uniqueID, imagine something like this:
(in the example below, I only use 2 tags)
English vresion of the new Product entry:
uniqueID: 123
color: yellow
usage: wall
Persian vresion of the new Product entry:
uniqueID: 123
color: زرد
usage: دیوار
Both "color" and "usage" (and the rest of the tags) are oneWay relation with "color" and "usage" collection types with only one text field inside, with internationalization option checked. So I have to add new entries in "color" and "usage" collection types in both English and Persian languages, and after that, when I want add a new entry in Product collection type, I have to add one entry 2 times (one for English, and another for the Persian language):
for English language, I fill uniqueID text field, and then select the previously-added tag values one by one (like the color, and usage values that I mentioned, and it shows English version of the tag values added)
for Persian language, I fill uniqueID text field, and then select the previously-added tag values one by one (it shows Persian version of the tag values added)
Problem
If I enable internationalization for the Product collection type, I have to select English tags while adding an entry for the English language, and the same for the Persian language as well. But, if I disable internationalization option for the Product collection type and I want to add a new entry, I can finally add it just once, but for the color, for example, it shows previously-added color values in any language possible (for the color, for exmaple, it shows "yellow" and "زرد")
Question
What's the best way to add one entry only once, so it can apply to all languages? Maybe it's not a good question, but I want to know how others think about my situation, where I have to add one product but 2 times for 2 languages, just because tags have to be translated in 2 different languages!
All reactions