I have a working 2sxc App with a single language. I now need to turn it into a multi language app at all levels: model, controller and views.
2sxc resources takes care of the most basic view stuff. But that's only 1% of the app.
How do I properly use two languages in a database/entity/table?
One (awefull) way to do is to create a "mirror"/copy entity for each language, and use a simple if clause in the view (if lang is A, use ent stuffA, else use ent stuffB). Since the fields names would be the same, no more changes would be needed.
I think the proper way would be to duplicate the needed fields. Let's say I have the entity Animals with the fields animalID and animalName. In a multilang app this would change to animalID, animalName_EN, animalName_PT. This, however, would be a nightmare to use a view. For every call of animalName, I would need to specify if lang is one or the other.
One sweet trick would be to use a query from the database for each language, but changing the name of the field from animalName_EN to animalName. The view and controller would use only a single version of the field, and no more changes would be needed. But I guess this is not possible, right?
The question is, how do I properly use multiple languages in a table, without causing a nightmare in the view and controller?
Don't do anything at all! 2sxc does it automatically for you! seriously - it's a no brainer. Just enable the additional languages in 2sxc (in the apps-management), and all entities are 100% multi-language immediately.
Here's on old description (the screenshots are very old) but the principle is still the same: https://2sxc.org/en/Discover/Multiple-Languages