إنضمامك إلي منتديات استراحات زايد يحقق لك معرفة كل ماهو جديد في عالم الانترنت ...

انضم الينا
استراحات زايد الصفحة الرئيسية

         :: شركة تنظيف مكيفات بالدمام (آخر رد :العنود جابر)       :: شركة تركيب كاميرات مراقبة بينبع (آخر رد :rwnaa_1)       :: المنصات عبر الإنترنت من التقنيات المبتكرة (آخر رد :اسماعيل رضا)       :: برامج الحفظ عبر الإنترنت المرونة (آخر رد :اسماعيل رضا)       :: تطبيق كليك كاش click cash (آخر رد :جاسم الماهر)       :: متجر ساكورا للهدايا: تمتع بتجربة تسوق استثنائية (آخر رد :نادية معلم)       :: التداول والأسهم: دليل شامل لعالم الاستثمار (آخر رد :محمد العوضي)       :: برامج الرشاقة السعيدة (آخر رد :دارين الدوسري)       :: التسجيل في الضمان المطور: خطوة بسيطة نحو مستقبل آمن (آخر رد :مصطفيي)       :: دراسة جدوى حناء: استثمار مربح في عالم الزراعة (آخر رد :مصطفيي)      

إضافة رد
 
LinkBack أدوات الموضوع انواع عرض الموضوع
  #1  
قديم 03-15-2010, 04:10 AM
عضو ماسي
بيانات محروم.كوم
 رقم العضوية : 503
 تاريخ التسجيل : Dec 2007
الجنس : female
علم الدوله :
 المشاركات : 2,100,613
عدد الـنقاط :3341
 تقييم المستوى : 2139

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:
  1. Don't use templates and build the PMs/emails in code, but I don't like that because then the messages won't be configurable
  2. Come up with some proprietary way of parsing the templates (ie - don't use vb's {} syntax so that the template is stored as straight text, allowing me to parse it myself)
  3. Scan my message templates for instances of :arsePhrase and modify $vbphrase manually to hold the text from the language that I want to render, then call vB_Template->render(), then restore $vbphrase to it's original state.
Either way, all three of these are dirty hacks.

Has anyone found a way around this? Am I missing something [non-]obvious?

Cheers,
Dave.
__DEFINE_LIKE_SHARE__
رد مع اقتباس
إضافة رد

مواقع النشر (المفضلة)


تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة
Trackbacks are متاحة
Pingbacks are متاحة
Refbacks are متاحة



الساعة الآن 03:01 AM


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.2 TranZ By Almuhajir

RSS RSS 2.0 XML MAP HTML