Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Creating a Model including trasnlation
I am developing a backend system for my applications. These applications will be multi-language.
There are some database-based modules, like menu, pages which will also be multi-language.
For these database I want to make the translation in database.
My first plan is to do it in Models. Extend the ORM Model, and rewrite the getter to automatically return the appropriate string in the appropriate language, if there is any.
The translations would be stored in a table, eg lang_menu
Hos would you do this?
What exactly do you want to translate?
If this is about property labels (for fieldsets), that already supports i18n, just define the language key as the label.
I have a table, called menu with the following structure:
1;main;This is a title;
I want to translate the title field like this:
1;1;de;title;Das ist ein titel
I want to store the translations in database.
Maybe this is not the best implementation.
My other idea was to create a lang.php and return the queried data from database, and load it via Lang class.
If this is not static data, I would create an i18n table:
You can then define a condition on the relation which will act like a permanent filter on language. This does require that all language strings are present though.
Alternatively you could use an EAV container, where 'language' is the 'key' column, and 'title' is the 'value' column. This will allow you to access all languages simultaneously, and pick an other on a new found.
EAV creates a virtual table layout like:
// get a menu item
$menuitem = Model_Menu::find(1);
$title = isset($menuitem->german) ? $menuitem->german : $menuitem->english;
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion