I’m setting up a database which will support multiple languages.
As an example lets say I have the following tables
‘languages’ FEILDS : ID, code, name, active INT(1)
‘products’ FIELDS : ID
‘product_descriptions’ FIELDS: product_id, language_id, title, description
Now I’ve setup setup a scope called ‘preferred’ on products_descriptions which retrieves languages in the order that I want the fallback order to be proceeded (eg. user language, website language, development language).
On the admin panel CRUD, is there a good/fast way for me to go about showing all enabled languages to the user for the ‘title’ and ‘description’.
I’m currently considering doing something like this (in product crud form):
FOR EACH active_languages
LOOK-UP product_description ( product_id , language_id ) EXISTS DISPLAY content filled edit fields ELSE DISPLAY empty edit fields
All in all it’s not a horrible solution, but I’m wondering is there a faster / better way (code wise) to do this via relations (I do not want to define any relations in the languages model) ? I will be re-using this data structure over and over again.