Closed (fixed)
Project:
Salesforce Suite
Version:
6.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
23 Apr 2009 at 10:47 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
aaronbaumanIn this patch:
Comment #2
Bevan commentedWow! That was fast! I'll review this later. :)
Comment #3
Bevan commentedThis needs a reroll; Moving the admin settings form into
salesforce_api.admin.inchas already been committed elsewhere. Several whitespace changes have also been committed. There are some issues about some of the changes:Check out the code from CVS so that your patches are cleaner and don't include additions that drupal.org's packager makes to
*.infofiles in the downloadable tarballs.Setting then restoring salesforce_api variables is a hack, and prone to error, for example if the toolkit is unavailable. Instead, modify
salesforce_api_connect()to take connection settings as an optional parameter. If the parameter has not been passed thensalesforce_api_connect()should get the settings fromvariable_get(). Make the optional parameterNULLby default, but pass it an array, so that the function's signature and function documentation doesn't get ugly.You'll need to re-add
$form['#validate'][] = 'salesforce_api_settings_form_validate';back into the settings form and patch.salesforce_api_enable()is mostly good, though salesforce module usually refers to "Salesforce", not "SalesForce", and we should be consistent on this. We should address this issue too, though perhaps in a separate issue and patch.The method you have used for
t()doesn't allow the link text to be translated. For better i18n-compatibilityt()should take a constant string as it's parameter, not a variable. The words "click here" are meaningless in links.Suggestion to solve the above issues;
drupal_set_message(t('Salesforce module requires you <a href="!url">enter your Salesforce connection details</a> before it can connect to Salesforce.com.', $vars));salesforce_api_requirements()looks, though I didn't run it. I'm not sure if curly braces in switch commands is accepted in Drupal's coding standards, though I think they should be! What a great idea! I wouldn't usecompact()for something like this since it adds unnecessary vagueness without saving many lines of code, which makes it harder for less-experienced programmers to read.Comment #4
aaronbaumanfinally got around to cleaning this up.
Bevan,
I rerolled against 6.x-2.x-dev and implemented all the changes you suggested, except for the t() syntax.
Using
<a href>inside t() creates more problems than it solves if, e.g. the user doesn't have clean urls or has set up url aliases...here's what i'm using instead:
drupal_set_message(t('Salesforce module enabled: Before making any Salesforce connections, !link', array('!link' => l(t('please enter your Salesforce API credentials'), SALESFORCE_PATH_ADMIN))), 'warning');Also, I added 2 more minor things:
Comment #5
Bevan commentedLinks, clean urls, and aliases, do not cause problems because
url()handles this at render-time taking all of that into consideration.!urlgets substituted forurl()'s return value at render-time too. In fact<a href="http://api.drupal.org/api/function/l/6">l()</a>usesurl()to generate the URI thatl()puts in<a href="">.The patch still needs review, though feel free to correct this and re-submit.
Comment #6
aaronbaumanSorry, I'm still not clear on the value of using an HTML
<a>tag andurl()function, when as you notedl()does the same thing.Comment #7
Bevan commentedurl() and l() are not the same. l() is dependent on url()
url() returns a uri, e.g.
http://drupal.org/node/12345l() returns an html link, e.g.
<a href="http://drupal.org/node/12345">Some node</a>In order to make strings translatable one whole conmprehensible and meaningful phrases, including the parts inside and outside the
<a>, we call t() ONCE with the whole phrase, and include minimal amounts of html in that translatable string.Imagine trying to translate "Salesforce module requires you !link before it can connect to Salesforce.com." and "enter your Salesforce connection details" and as 2 disconnected and separate language strings, without the context of each other. Translation becomes difficult and the translation is likely to lose it's meaning.
Comment #8
aaronbaumanI see your point, Bevan.
Both solutions still seem less than optimal to me though... translation is hard =P
Comment #9
Bevan commentedTranslation IS hard.
I'm not sure what is sub-optimal about
t('Some <a href="!url">links</a> in a string', $vars);though? Because the translator has to look at some html? The translator MUST decide which text goes inside and outside the link – so there has to be SOME kind of placeholder. Arguably it could be simpler than<a href="!url">, though I don't think that is very complicated. If it were<em>instead I think it would be fine. Anything more complicated than one or two trivial attributes would probably start to be a problem though. In that case you could also doBut that quite quickly starts to get more complicated in the PHP than necessary.
Comment #10
Bevan commentedFixed a simpler version in http://drupal.org/cvs?commit=245274