I have an Articles class, which must store these fields:
- article_id
- name
- title_es
- title_en
- alias_es (article slug for url)
- alias_en
- description_es
- description_en
- date_c
- date_m
- date_p
As you have probably guessed, I need them to be both in English and Spanish. No problem at this point because there are only two languages.
What if I needed to add more in the future? This class would become a monster. So, how would you implement this?
The only good solution I can think of would be to split any article in different ones for every language, adding a language field, and some sort of relationship “article (English)-article (Spanish)”, in an additional table maybe. I believe Joomla does something like this.
What do you think about this approach?
Would it be possible to do an efficient implementation to this without splitting an article for every language? Any design pattern for this?
I would leave only 1 of each field and add a language field. Then you can create 2 article objects, one for English, one for Spanish. Display whichever you need, according to the language the user chose.