|
إنضمامك إلي منتديات استراحات زايد يحقق لك معرفة كل ماهو جديد في عالم الانترنت ...
انضم الينا
#1
| ||
| ||
Hi guys, I am wondering if anyone has figured out how to render a template in a language that differs from the currently session's language preference. My use case is that I'm writing a mod that that allows users to request permission to a particular resource. Those applications can be reviewed/approved/rejected by an admin. When a user applies for access, an email is sent out to the admins. When the admins approve/reject and application, a PM is sent to the applicant and an email is sent out to the rest of the admins telling them that the request has already been dealt with. Here's the rub. My board has users and admins from several different countries, each having their own language preferences. Therefore, I have created templates for the emails/PMs with phrases in them. The problem that i'm having is that vB_Template->render() is only concerned with the language preference of the current session and I can't figure out how to get it to render for a different language. class_core.php: vB_Template->render() is pretty simple; ultimately it just calls 'eval' on the template text which is stored in the vb_template table. Instances of {vb:rawphrase phraseName} in the template are stored, in vb_template as: PHP Code: vB_Template_Runtime::parsePhrase("phraseName") If you have a look at class_core.php: vb_Template_Runtime->parsePhrase reads as follows: PHP Code: public static function parsePhrase($phraseName) { global $vbphrase; $arg_list = func_get_args(); $arg_list[0] = $vbphrase[$phraseName]; return construct_phrase_from_array($arg_list); } Okay, so functions.php: construct_phrase_from_array() is commented as the following: Code: /** * Construct Phrase from Array * * this function is actually just a wrapper for sprintf but makes identification of phrase code easier * and will not error if there are no additional arguments. The first element of the array is the phrase text, and * the (unlimited number of) following elements are the variables to be parsed into that phrase. [snip] Cool, so construct_phrase_from_array is nothing but a wrapper for sprintf (and it accepts parameters for phrases) but the key here lies in parsePhrase where it takes the phrase text from $vbphrase. This variable only stores the phrases for the current language preference meaning that when I call vB_Template->render(), the template (and phrases in the templates) will be rendered in a single language. That's not what I want. I want the PM to be sent to the applicant in their own language and I want to send the email out to each admin in their own language. From what I can see, this isn't currently possible. Note: There are three workarounds here:
Has anyone found a way around this? Am I missing something [non-]obvious? Cheers, Dave. __DEFINE_LIKE_SHARE__ |
مواقع النشر (المفضلة) |
| |