Results 1 to 2 of 2

Thread: Single Quotes / Double Quotes

  1. #1
    Devis is offline Sugar Community Member
    Join Date
    Jun 2005
    Location
    Schio - Italy
    Posts
    141

    Default Single Quotes / Double Quotes

    In SugarCrm language files strings are sometimes wrote with single quotes, sometimes with double quotes, sometimes with single backslashes, sometimes with double backslashes.

    1) double quotes and single backslashes
    'LBL_ROUTING_CHECK_RULE' => "An error was detected:\n"

    2) single quotes and single backslashes
    'LBL_EMAIL_SETTINGS_FULL_SYNC_WARN' => 'Perform a full synchronization?\nLarge mail accounts may take a few minutes.'

    3) double quotes and double backslashes
    'ERR_DECIMAL_SEP_EQ_THOUSANDS_SEP' => "The decimal separator cannot use the same character as the thousands separator.\\n\\n Please change the values."

    This is causing some problem in the localization.

    Considering that strings are used in PHP and Javascript too, this is a bit confusing for a translator and for an automatic translation tool too.
    I have always used double quotes but this is causing javascript errors.
    If I would use always single quotes I see not rendered "\n" in the html.

    IMO JS strings should be enclosed in single quotes and, viceversa, HTML strings in double quotes. The variable name should indicates if it is a JS string or a HTML string to decide which quoting to use.

    Any suggestion ? Should I review every string of every file to see which quoting is SugarCRM using and maybe where ?
    Devis Lucato
    Ex maintainer Italian Localization
    Senior PHP Developer
    Linux System Admin
    London

  2. #2
    julian's Avatar
    julian is offline Sugar Team Member
    Join Date
    Sep 2004
    Posts
    1,639

    Default Re: Single Quotes / Double Quotes

    You bring up a good point... this should be standardized. Even though there is a (VERY) slight performance degradation when using double quotes instead of single quotes in PHP, I would recommend always using double quotes, i.e.:

    PHP Code:
    "LBL_MY_LABEL" => "my value\n"
    If you want to include double-quotes inside your string, they should just be escaped:

    PHP Code:
    "LBL_MY_LABEL" => "my \"value\" with double quotes inside"
    Where do you see JavaScript errors being triggered?
    Julian Ostrow
    Systems and Applications Engineer
    SugarCRM Inc.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. C3 OpenSales - Products, Quotes, & Contracts
    By rustinp77 in forum Downloads
    Replies: 2
    Last Post: 2007-06-19, 03:44 PM
  2. Account Quotes - Listing all accounts
    By rustinp77 in forum Help
    Replies: 1
    Last Post: 2007-05-09, 01:13 PM
  3. Customizing Quotes Module
    By pmeisner in forum Developer Help
    Replies: 2
    Last Post: 2006-02-09, 05:55 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
  •