Variable relms/namespaces++<br><br>New names for variable functions--<br><br>Variable registry with defaults in a DB--<br><br>Variable defaults in hooks+- (not sure)<br><br>This is MHO.<br><br>Robin<br><br><div><span class="gmail_quote">
On 5/3/07, <b class="gmail_sendername">Gabor Hojtsy</b> &lt;<a href="mailto:gabor@hojtsy.hu">gabor@hojtsy.hu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>To be able to translate variables to multiple languages in Drupal<br>nicely, we would need a small conceptual change, which would benefit all<br>of the Drupal developers, so I am posting the call here in hopes we have
<br>someone or a small group to pick this task up.<br><br>**We need a central place to define variable defaults**<br><br>Simple! Now whenever you need a variable, you do<br><br>&nbsp;&nbsp; variable_get(&#39;my_fine_var&#39;, &#39;my_default_value&#39;);
<br><br>The problem with this is that you need to repeat this multiple times,<br>and of course there is a chance you need to modify it later on, so you<br>need to find all places a variable is used. Not good. Remember the
<br>changes from bluemarine to garland, we have been fixing theme_default<br>errors for days, finding out places where the variable was used...<br><br>So we need a central place to define variable defaults. For Drupal 6<br>
this is enough now:<br><br>&nbsp;&nbsp; hook_settings() {<br>&nbsp;&nbsp;&nbsp;&nbsp; return array(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;my_fine_var&#39; =&gt; &#39;my_default_value&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp; );<br>&nbsp;&nbsp; }<br><br>Have fun with naming it hook_settings(), as far as I see, it is an
<br>appropriate name, and not taken at the moment :) So Drupal can do a<br>module_invoke_all() on hook_settings() and collect defaults to all<br>variables from the modules defining them. It gets easier and shorter to<br>use variables:
<br><br>&nbsp;&nbsp; variable_get(&#39;my_fine_var&#39;);<br><br>We can either cache the default vars as returned by the callback in the<br>variable_get() function, or in the database among other variables, you<br>get the idea. It is important to have all variables defined in
<br>hook_settings(), even if the default value is an empty string or array.<br><br>Don&#39;t care yet about how this fits into translatable variables, because<br>we can only follow up on that if this gets done. So someone please grab
<br>this issue and run with it ;)<br><br>Gabor<br></blockquote></div><br><br clear="all"><br>-- <br>Robin Monks<br>@ <a href="http://www.civicspacelabs.org">www.civicspacelabs.org</a><br>@ <a href="http://www.gmking.org">
www.gmking.org</a><br><br>Fax: (419) 791-8076<br><br>&quot;Some people, when confronted with a problem, think &quot;I know, I&#39;ll use regular expressions.&quot; Now they have two problems.&quot; ~IRC