[drupal-devel] Internationalization, Usability and changes in the coding conventions

Carl McDade carl_mcdade at yahoo.com
Sat Feb 19 19:06:32 UTC 2005

It's just one of many stages of getting the
localization/internationalization process out of the Drupal core and
have it handled more by the contributed modules.

"You are not authorized to access this page"

is hardcoded in a core structure piece, common.inc which means that
conmmon.inc needs a PO file for translation. But now a decision has to
be made on how to phrase and use this message because it will come up at
every "access denied" situation. Ones where login is incorrect to those
 where a hack attempt is being made. By moving the string over to a
variable and using it only as a default only the module calling the
function will need to be translated using (english for this example):

message_access('You/she do not have access rights in this area please
check with the administrator')

but in another section this may not be apporproíate language and need to
be said in a different manner.

message_access('You/They are not allowed access to this area please
because of an error in linking')

Carl McDade

> Maybe my head is just a brick, but I fail to understand how this will 
> help.
> Could you please explain to us how would the translation process work 
> in 
> this case? 
> Regards
> Karoly Negyesi
> On Saturday 19 February 2005 19.15, Carl McDade wrote:
>>   There should be an effort to externalize all english text into 
> default
>> variables. It makes a great step towards true internatiolization. 
> Does
>> not cost anything in terms of performance or matainance. What it does 
> do
>> is make the code that uses hard coded strings open and more resuable. 
> It
>> adds the flexibility in phrasology that is necessary in
>> internationalizing Drupal. It creates more usability in that better 
> text
>> instructions can be delivered to the user based on the situation of 
> the
>> process. I have made this slight change in my install which allows me 
> to
>> give a descriptive message based on the url tried. This can be done 
> in
>> both english and swedish without me having to use gettext and the 
> like
>> I also feel that this should be added to the coding conventions so 
> that
>> Drupal code will keep moving forward into internationalization and 
> need
>> less "fixing" inorder for it to happen properly.
>> I have created an issue and patch on this but I thought it should be
>> addresses directly as many will be branching their code for v4.6 and
>> this should be part of that.
>> --- common_1.inc    2005-02-19 17:33:21.451910400 +0100
>> +++ common_2.inc    2005-02-19 17:34:40.876116800 +0100
>> @@ -427,8 +427,8 @@ function object2array($object) {
>>   * Always consider whether to use drupal_access_denied() instead to
>> return a
>>   * proper (and customizable) 403 error.
>>   */
>> -function message_access() {
>> -  return t('You are not authorized to access this page.');
>> +function message_access($message = 'You are not authorized to access
>> this page.') {
>> +  return t($message);
>> }

More information about the drupal-devel mailing list