class Categories extends Zend_Db_Table_Abstract{
private function setUp()
{
$locale = Zend_Registr::get('locale');
$this->_name = 'categories_data_' . $locale->toString();
}
}
So, you would have one Categories model for all of your language tables.
Moritz Mertinkat пишет:
> If your categories are the same for each language, I'd rather use
> Zend_Translate than maintaining different sets in your database.
>
> If there's a reason to keep it in database or if your categories differ from
> language to language, I'd still use the same table, as it makes things a lot
> easier in general. You also wouldn't need to different Zend_Db_Tables and thus
> no redundant code.
>
> Use Zend_Locale and a model which selects the right categories from your
> database using "Categories extends Zend_Db_Table" depending on the
> locale/language.
>
> Maurice.
>
>
> Václav Vaník schrieb:
>
>> Hi guys,
>>
>> i started to solve multilingual db models and i am finding the best
>> practise.
>>
>> My model looks http://www.walk.cz/download/vicejazycnost.png
>> http://www.walk.cz/download/vicejazycnost.png .
>>
>> It means in my case I will use in ZF views categories_cs and categories_en
>> only.
>>
>> In ZF I have to have 2 models:
>>
>> class CategoriesCs extends Zend_Db_Table {}
>> class CategoriesEn extends Zend_Db_Table {}
>>
>> But here I have 2 problems:
>>
>> a) redundant code in both models (could be solved by inheritance, but
>> extending is evil, probably could be solved by any design pattern, but I
>> dont know which to use)
>> b) how to easily create model instance for current language? (the best way
>> is imho Factory pattern, but where should be the Factory?)
>>
>
>
>
>
>
--
Thanks,
Yaroslav Vorozhko, Software Engeneer, Consultant
Skype: yarik0083
AIM: yarik0083
ICQ: 148966172
My blog: http://pro100pro.com
Web-design firm: http://vdesign.com.ua
没有评论:
发表评论