Results 1 to 10 of 10

Thread: Add logic to the en_us.lang.php file

  1. #1
    purchasing@caris.com's Avatar
    purchasing@caris.com is offline Junior Member
    Join Date
    Dec 2008
    Posts
    22

    Default Add logic to the en_us.lang.php file

    I'm trying to add logic to my en_us.lang.php located in custom/modules/Quotes/language. I added a radio button in the quote creation where a user can select the language they want the quote pdf template to be in. For example, the default would be English, the user wants to send a quote to a Spanish speaking person so he selects the Spanish radio button. When the quote is filled out and complete and saved, the user goes to print as pdf and the added logic in the en_us.lang.php file dictates how the labels will be displayed in the quote and so on. Here's some of the code I was trying to implement, but it causes sugar not to load, I get a blank page.

    if(isset($this->bean->select_language_c) && $this->bean->select_language_c = "English"){
    $mod_strings = array (
    'LBL_OPPORTUNITY_NAME' => 'Quotation/Case Number:',
    'LBL_PDF_SALES_PERSON' => 'CARIS Representative:',
    'LBL_PDF_SHIPPING' => 'Alliance Discount:',
    'LBL_DISCOUNT_TOTAL' => 'Volume Discount:',
    'LBL_PDF_TAX' => 'IFF:',
    'LBL_TAX_USDOLLAR' => 'IFF: (US Dollar)',
    'LBL_TEAM_ID' => 'Team ID',
    'LBL_GSA_SCHEDULE' => 'GSA Schedule',
    'LBL_QUOTE_TYPE2' => 'Quote Type:',
    'LBL_PDF_PART_NUMBER' => 'Product ID(s)',
    'LBL_LIST_MANUFACTURER_PART_NUM' => 'Product ID(s)',
    'LBL_EMAIL_DEFAULT_DESCRIPTION' => 'Dear ,<br><br>

    <font color="#FF0000">Start If Subscription Quote Only Delete this section if quoting anything more than Subscription</font><br><br>

    Please find the attached quotation for the renewal of your Subscription Contract. As you may already be aware, your existing contract is due for renewal on <strong>Insert Date</strong>. The attached quotation covers the period from <strong>Insert Date</strong> to <strong>Insert Date</strong>.<br><br>

    Renewing your Subscription Contract will ensure you receive the most current releases of software including new functionality, technology, and software updates. You will also have access to our Customer Services Department via the HelpDesk, e-mail, phone, and fax.<br><br>

    <font color="#FF0000">End If Subscription Quote Only Delete this section if quoting anything more than Subscription</font><br><br>

    <strong>Introduce quotation</strong><br>

    <strong>State any important details</strong><br>

    <strong>State follow-up action</strong><br><br>

    Best Regards,<br><br>',
    'LBL_LIST_TAXCLASS' => 'IFF',
    'LBL_PDF_TAX_RATE' => 'IFF Rate',
    'LBL_TAXRATE' => 'IFF Rate:',
    );
    }
    else if(isset($this->bean->select_language_c) && $this->bean->select_language_c == "Spanish"){
    $mod_strings = array (
    'LBL_OPPORTUNITY_NAME' => 'Spanish equivalent:',
    'LBL_PDF_SALES_PERSON' => 'Spanish equivalent:',
    'LBL_PDF_SHIPPING' => 'Spanish equivalent:',
    'LBL_DISCOUNT_TOTAL' => 'Spanish equivalent:',
    'LBL_PDF_TAX' => Spanish equivalent:',
    'LBL_TAX_USDOLLAR' => 'Spanish equivalent',
    'LBL_TEAM_ID' => 'Spanish equivalent',
    'LBL_GSA_SCHEDULE' => 'Spanish equivalent',
    'LBL_QUOTE_TYPE2' => 'Spanish equivalent:',
    'LBL_PDF_PART_NUMBER' => 'Spanish equivalent',
    'LBL_LIST_MANUFACTURER_PART_NUM' => 'Spanish equivalent',
    'LBL_EMAIL_DEFAULT_DESCRIPTION' => 'Dear ,<br><br>

    <font color="#FF0000">Start If Subscription Quote Only Delete this section if quoting anything more than Subscription</font><br><br>

    Please find the attached quotation for the renewal of your Subscription Contract. As you may already be aware, your existing contract is due for renewal on <strong>Insert Date</strong>. The attached quotation covers the period from <strong>Insert Date</strong> to <strong>Insert Date</strong>.<br><br>

    Renewing your Subscription Contract will ensure you receive the most current releases of software including new functionality, technology, and software updates. You will also have access to our Customer Services Department via the HelpDesk, e-mail, phone, and fax.<br><br>

    <font color="#FF0000">End If Subscription Quote Only Delete this section if quoting anything more than Subscription</font><br><br>

    <strong>Introduce quotation</strong><br>

    <strong>State any important details</strong><br>

    <strong>State follow-up action</strong><br><br>

    Best Regards,<br><br>',
    'LBL_LIST_TAXCLASS' => 'IFF',
    'LBL_PDF_TAX_RATE' => 'IFF Rate',
    'LBL_TAXRATE' => 'IFF Rate:',
    );
    }

    Any help would be much appreciated.
    Thanks

  2. #2
    crmonline's Avatar
    crmonline is offline Sugar Community Member
    Join Date
    Dec 2010
    Location
    Perth, Sydney, Melbourne and Manila
    Posts
    99

    Default Re: Add logic to the en_us.lang.php file

    Hi,

    I couldn't tell you what the error is as it sounds like a PHP error if you're getting a blank page, so I'd suggest looking at the error logs. If you continue to have this issue though, consider overriding the pdf print view within the quote and loading the module language dynamically based on that logic. This seems like a more logical place to make this change (and perhaps safer since there is some caching that goes on with the language files).

  3. #3
    ashdwi1's Avatar
    ashdwi1 is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Noida
    Posts
    427

    Default Re: Add logic to the en_us.lang.php file

    you can try a trick , change language to spanish while your operation and revert language to english again when job done.

  4. #4
    thephpdon is offline Member
    Join Date
    Jun 2010
    Location
    Noida
    Posts
    7

    Thumbs up Re: Add logic to the en_us.lang.php file

    Quote Originally Posted by ashdwi1 View Post
    you can try a trick , change language to spanish while your operation and revert language to english again when job done.
    Try this

    Check case when language Spanish use

    $mod_strings = return_module_language($current_language='Spanish' , '<Module_Name>');

    else use

    $mod_strings = return_module_language($current_language='English' , '<Module_Name>');

    after sending mail use

    $mod_strings = return_module_language($current_language='English' , '<Module_Name>');

  5. #5
    purchasing@caris.com's Avatar
    purchasing@caris.com is offline Junior Member
    Join Date
    Dec 2008
    Posts
    22

    Default Re: Add logic to the en_us.lang.php file

    Thanks crmonline, your suggestion sounds good. I would I go about implementing it? How to override the pdf print view?

    Thank you
    Last edited by purchasing@caris.com; 2013-06-14 at 06:28 PM.

  6. #6
    kir
    kir is offline Sugar Community Member
    Join Date
    Nov 2011
    Posts
    702

    Default Re: Add logic to the en_us.lang.php file

    Quote Originally Posted by purchasing@caris.com View Post
    I'm trying to add logic to my en_us.lang.php located in custom/modules/Quotes/language. I added a radio button in the quote creation where a user can select the language they want the quote pdf template to be in. For example, the default would be English, the user wants to send a quote to a Spanish speaking person so he selects the Spanish radio button. When the quote is filled out and complete and saved, the user goes to print as pdf and the added logic in the en_us.lang.php file dictates how the labels will be displayed in the quote and so on. Here's some of the code I was trying to implement, but it causes sugar not to load, I get a blank page.

    if(isset($this->bean->select_language_c) && $this->bean->select_language_c = "English"){
    $mod_strings = array (
    'LBL_OPPORTUNITY_NAME' => 'Quotation/Case Number:',
    'LBL_PDF_SALES_PERSON' => 'CARIS Representative:',
    'LBL_PDF_SHIPPING' => 'Alliance Discount:',
    'LBL_DISCOUNT_TOTAL' => 'Volume Discount:',
    'LBL_PDF_TAX' => 'IFF:',
    'LBL_TAX_USDOLLAR' => 'IFF: (US Dollar)',
    'LBL_TEAM_ID' => 'Team ID',
    'LBL_GSA_SCHEDULE' => 'GSA Schedule',
    'LBL_QUOTE_TYPE2' => 'Quote Type:',
    'LBL_PDF_PART_NUMBER' => 'Product ID(s)',
    'LBL_LIST_MANUFACTURER_PART_NUM' => 'Product ID(s)',
    'LBL_EMAIL_DEFAULT_DESCRIPTION' => 'Dear ,<br><br>

    <font color="#FF0000">Start If Subscription Quote Only – Delete this section if quoting anything more than Subscription</font><br><br>

    Please find the attached quotation for the renewal of your Subscription Contract. As you may already be aware, your existing contract is due for renewal on <strong>Insert Date</strong>. The attached quotation covers the period from <strong>Insert Date</strong> to <strong>Insert Date</strong>.<br><br>

    Renewing your Subscription Contract will ensure you receive the most current releases of software including new functionality, technology, and software updates. You will also have access to our Customer Services Department via the HelpDesk, e-mail, phone, and fax.<br><br>

    <font color="#FF0000">End If Subscription Quote Only – Delete this section if quoting anything more than Subscription</font><br><br>

    <strong>Introduce quotation</strong><br>

    <strong>State any important details</strong><br>

    <strong>State follow-up action</strong><br><br>

    Best Regards,<br><br>',
    'LBL_LIST_TAXCLASS' => 'IFF',
    'LBL_PDF_TAX_RATE' => 'IFF Rate',
    'LBL_TAXRATE' => 'IFF Rate:',
    );
    }
    else if(isset($this->bean->select_language_c) && $this->bean->select_language_c == "Spanish"){
    $mod_strings = array (
    'LBL_OPPORTUNITY_NAME' => 'Spanish equivalent:',
    'LBL_PDF_SALES_PERSON' => 'Spanish equivalent:',
    'LBL_PDF_SHIPPING' => 'Spanish equivalent:',
    'LBL_DISCOUNT_TOTAL' => 'Spanish equivalent:',
    'LBL_PDF_TAX' => Spanish equivalent:',
    'LBL_TAX_USDOLLAR' => 'Spanish equivalent',
    'LBL_TEAM_ID' => 'Spanish equivalent',
    'LBL_GSA_SCHEDULE' => 'Spanish equivalent',
    'LBL_QUOTE_TYPE2' => 'Spanish equivalent:',
    'LBL_PDF_PART_NUMBER' => 'Spanish equivalent',
    'LBL_LIST_MANUFACTURER_PART_NUM' => 'Spanish equivalent',
    'LBL_EMAIL_DEFAULT_DESCRIPTION' => 'Dear ,<br><br>

    <font color="#FF0000">Start If Subscription Quote Only – Delete this section if quoting anything more than Subscription</font><br><br>

    Please find the attached quotation for the renewal of your Subscription Contract. As you may already be aware, your existing contract is due for renewal on <strong>Insert Date</strong>. The attached quotation covers the period from <strong>Insert Date</strong> to <strong>Insert Date</strong>.<br><br>

    Renewing your Subscription Contract will ensure you receive the most current releases of software including new functionality, technology, and software updates. You will also have access to our Customer Services Department via the HelpDesk, e-mail, phone, and fax.<br><br>

    <font color="#FF0000">End If Subscription Quote Only – Delete this section if quoting anything more than Subscription</font><br><br>

    <strong>Introduce quotation</strong><br>

    <strong>State any important details</strong><br>

    <strong>State follow-up action</strong><br><br>

    Best Regards,<br><br>',
    'LBL_LIST_TAXCLASS' => 'IFF',
    'LBL_PDF_TAX_RATE' => 'IFF Rate',
    'LBL_TAXRATE' => 'IFF Rate:',
    );
    }

    Any help would be much appreciated.
    Thanks
    I don't know - did you copy original language file to the custom folder and then add your logic or it is full content of your language file.
    If it is full content - for sure you will have blank page because other array's language variables for your module are not defined (array will be overrwritten with only your new values).
    I would create logic hook after retrieve and override only exact values you need to in $GLOBALS[][] array according to Language mark (select_language_c) in current module...

  7. #7
    purchasing@caris.com's Avatar
    purchasing@caris.com is offline Junior Member
    Join Date
    Dec 2008
    Posts
    22

    Default Re: Add logic to the en_us.lang.php file

    Hi kir,
    I tried copying the entire file from modules/Quotes/language directory to custom/modules/Quotes/language, added my condition statement, performed a quick repair and rebuild, hit the back button in browser and that's when I get the blank page.

    I don't know how to create a logic hook?

    Thanks

  8. #8
    kir
    kir is offline Sugar Community Member
    Join Date
    Nov 2011
    Posts
    702

    Default Re: Add logic to the en_us.lang.php file

    First Check your condition -> there assignment of English language to your $bean->select_language_c
    if(isset($this->bean->select_language_c) && $this->bean->select_language_c = "English")

    logic hooks is files to process some actions on some event.
    You have to create class and function to process and set path to that file.
    Define type of event and class and function_name in custom/modules/<modulename>/logic_hooks.php - you will find examples there almost in all custom module's folders. Google forum and you will find many examples and understand how to code it.

  9. #9
    purchasing@caris.com's Avatar
    purchasing@caris.com is offline Junior Member
    Join Date
    Dec 2008
    Posts
    22

    Default Re: Add logic to the en_us.lang.php file

    Quote Originally Posted by kir View Post
    First Check your condition -> there assignment of English language to your $bean->select_language_c



    logic hooks is files to process some actions on some event.
    You have to create class and function to process and set path to that file.
    Define type of event and class and function_name in custom/modules/<modulename>/logic_hooks.php - you will find examples there almost in all custom module's folders. Google forum and you will find many examples and understand how to code it.
    Changed the equality and still getting blank page. I'll try and look up some examples of these logic hooks as you said.

    Thanks

  10. #10
    purchasing@caris.com's Avatar
    purchasing@caris.com is offline Junior Member
    Join Date
    Dec 2008
    Posts
    22

    Default Re: Add logic to the en_us.lang.php file

    Quote Originally Posted by thephpdon View Post
    Try this

    Check case when language Spanish use

    $mod_strings = return_module_language($current_language='Spanish' , '<Module_Name>');

    else use

    $mod_strings = return_module_language($current_language='English' , '<Module_Name>');

    after sending mail use

    $mod_strings = return_module_language($current_language='English' , '<Module_Name>');
    Where would I insert this code? In the sugarpdf.standard.php?

    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. en_us.lang.php file is out of control!
    By frontstrat in forum Help
    Replies: 1
    Last Post: 2013-04-18, 11:00 AM
  2. Replies: 8
    Last Post: 2011-12-07, 08:29 PM
  3. Dropdown Editor and custom en_us.lang.php file
    By deji163 in forum General Discussion
    Replies: 3
    Last Post: 2011-08-16, 03:25 PM
  4. Replies: 1
    Last Post: 2010-09-23, 02:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •