Better way of storing translations in database?


Currently you store translations as serialized data in one row cell in database (instead of separates tables/rows with translation). Is there any special reason?

I found that the possibility of searching translated names in database is limited. For example look at your searching bar, I can only find the original names of products.

1 Answer


Hello and thank you for the great question.

Every decision is a compromise between priorities.

The main and overwhelmingly prevalent use case for translations is showing them on the frontend to end user. The main priority is to make the retrieval and display as fast as possible. The next priority is to make the usage of code as simple and minimal as possible for theme developers, because it is very frequent. Current solution allows retrieval of translations in the same request as the main record, and is great to cover main priorities.

It would be possible to store translations in relational manner, but that would compromise the main priorities and complicate retrieval if any optimizations for multiple records are to be applied (for ex.: collect information about translations required throughout web request and retrieve them all in the same sql request before output).

In general, this structure works well for uncompromised main priorities, while it is still possible to go over the records and collect translations for such purposes as data integrity reports and finding missing translations.

I hope this answers your question.

EDIT: I've given it a more thought, and I believe you have a valid use case for admin users. I will work on a solution that is fast and does not require lots of work for devs that will use it. Thank you.

Please log in or register to answer this question.

Know someone who can answer? Share a link to this