I need to translate to any language I've set-up on my application, in
the same controller, this is necessary so that notifications for
example, are sent in the right language to every user.

Anyway, after trying lots of different things, and reading i18n and
l10n source code, this is what I came up with:

function trans($word, $lang_code, $sess_lang)
    {
        $i18n =& I18n::getInstance();
        $i18n->__l10n->found = false;
        $i18n->__domains = array();
        Configure::write('Config.language', $lang_code);
        $t_word = $i18n->translate($word);
        $i18n->__l10n->found = false;
        $i18n->__domains = array();
        Configure::write('Config.language', $sess_lang);

        return $t_word;
    }

Before this I tried using Configure::read('Config.language') to get
the session/current language code, but I was getting some session
errors. Anyway, the above function is quite ugly, it's a lazy
approach, I don't like resetting internal i18n variables, but this was
the most straightforward way I found of accomplishing what I need,
since there's no equivalent function built in i18n (translate() uses
what was already set by l10n, which is not re-set if it was already
set).

Any suggestions?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to