Open Source Content Management System

Planet Midgard: Archive

2005-12-31 - 2006-01-30

Aegir Localization debugged

Posted on 2006-01-08 22:18:15 GMT.

Since I faced some trouble with aegir not showing UTF-8 code correctly when running in german language i decided to look for the source of this trouble....
Since I faced some trouble with aegir not showing UTF-8 code correctly when running in german language i decided to look for the source of this trouble....','I recently had to swap over a whole bunch of SGs from midgard 1.6.3 to a new server, which went smoothly overall (well i had to uninstall midgard 1.7.3 since it didnt work for me on a SuSE 9.3 and i had no time to debug that...)
I decided that the new installl should run under UTF-8 default encoding, but noticed terrible coding faults when switching Aegir to german language..
After a bit of investigation a few reasons for that came on:
  1. Aegir sets the person parameter :
    domain: display_setting; name: encoding; value: Content-Type: text/html; charset=ISO-8859-15
    which may prevent correct encoding
  2. Even when this parameter is removed (or changed to UTF-8) this bad behaviour stays present
  3. turns out that Aegir Localizations where not correctly coded to UTF-8
  4. unfortunately the localization strings are stored in base64 encoding in Aegir, so there is no possibility to convert them directly...
    (see snippets under AegirCore / Localization / AegirCore / de for examples)
  5. Luckily Aegir provides a Transloation Tool to correct this (as SG0-Admin see Tools - Translation tool) - unfortunately it is broken in Aegir 1.0.3...
To fix this you have to edit Snippet: / AegirCore / argv0 / localize / localize_functions
locate the function nemein_T_L_line($name,$en,$lo,$lang)
and change
[code]
<?php
function nemein_T_L_line($name,$en,$lo,$lang)
{
$enStr = $en;
$loStr = $lo;

$decname = str_replace("?", "/", $name);
$decname = base64_decode($decname);

$name = str_replace("'", """, $name);
$enStr = str_replace("'", """, $enStr);
$loStr = str_replace("'", """, $loStr);


$output = "<tr>\\n";
$optput .= '<td align="right"><b>'.$decname.' </b>'."\\n";
$optput .= '<input type="hidden" name="sNames[]" value="'.$name.'">'."\\n";
$optput .= "</td>\\n";
$optput .= '<td><input type=text size=40 name="AA['.$name.'][en]" value="'.$enStr.'" readonly></td>'."\\n";
$optput .= '<td><input type=text size=40 name="AA['.$name.']['.$lang.']" value="'.$loStr.'"></td>'."\\n";
$optput .= "</tr>\\n";
}
?>
[/code]

to look like this
[code]
<?php
function nemein_T_L_line($name,$en,$lo,$lang)
{
$enStr = $en;
$loStr = $lo;

$decname = str_replace("?", "/", $name);
$decname = base64_decode($decname);

$name = str_replace("'", """, $name);
$enStr = str_replace("'", """, $enStr);
$loStr = str_replace("'", """, $loStr);


$output = "<tr>\\n";
$output .= '<td align="right"><b>'.$decname.' </b>'."\\n";
$output .= '<input type="hidden" name="sNames[]" value="'.$name.'">'."\\n";
$output .= "</td>\\n";
$output .= '<td><input type=text size=40 name="AA['.$name.'][en]" value="'.$enStr.'" readonly></td>'."\\n";
$output .= '<td><input type=text size=40 name="AA['.$name.']['.$lang.']" value="'.$loStr.'"></td>'."\\n";
$output .= "</tr>\\n";
}
?>
[/code]

notice the typo which spells optput instead of outout...
Thats it - now you can localize again :)
have Fun!
Designed by Nemein, hosted by Anykey