开发者

Getting 'default' translation for a translation that doesn't exist

I'm trying to develop a database driven translation site in cakePHP.

When I'm setting the Model locale or Config.language to a language such as de-de like below:

Configure::write("Config.language", "de-de");

it loads the correct translations of de_DE from the i18n table.

My problem is, if the translation does not exist for another row, it doesn't return anything. Is there anything you have to setup so if it doesn't find anything, it returns the 'default' language translation or the data directly from the Model??

I think it's too much work to stay checking all the time if data is returned and if not changing the locale/language settings all time to the default language you want..

Or maybe I'm doing this wrong?


Code:

data in i18n table:

id  locale  model   foreign_key field       content
2   de_DE   Suite   4           description description in en_US for vilhena
3   en_US   Suite   3           description description in en_Us for del Monte
4   en_US   Suite   2           description description in en_Us for Pinto
5   en_US   Suite   1           descriptio开发者_如何学Cn description in en_Us for Hompesch


Configure::write("Config.language", "de-de");
$this->Suite->find("all");

returns

Array
(
    [0] => Array
        (
            [Suite] => Array
                (
                    [id] => 4
                    [name] => Vilhena
                    [enabled] => 1
                    [description] => description in en_US for vilhena
                    [locale] => de_de
                )

        )

)


must be Configure::write("Config.language", "de-DE");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜