From: <pdo...@us...> - 2007-03-30 20:47:26
|
Revision: 12357 http://squirrelmail.svn.sourceforge.net/squirrelmail/?rev=12357&view=rev Author: pdontthink Date: 2007-03-30 13:47:23 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Add sq_change_text_domain for plugins to use when switching text domains Modified Paths: -------------- branches/SM-1_4-STABLE/squirrelmail/ChangeLog branches/SM-1_4-STABLE/squirrelmail/functions/i18n.php Modified: branches/SM-1_4-STABLE/squirrelmail/ChangeLog =================================================================== --- branches/SM-1_4-STABLE/squirrelmail/ChangeLog 2007-03-30 20:45:55 UTC (rev 12356) +++ branches/SM-1_4-STABLE/squirrelmail/ChangeLog 2007-03-30 20:47:23 UTC (rev 12357) @@ -34,6 +34,8 @@ - Session not correctly handled on webmail.php (#1685031). - session_id reporting session id when no active session (#1685031). - sqm_baseuri moved to strings.asp (#1685114). + - Added sq_change_text_domain() for plugins to use when switching text + domains. If plugins use this function, it fixes #1434043. Version 1.4.9a - 3 December 2006 -------------------------------- Modified: branches/SM-1_4-STABLE/squirrelmail/functions/i18n.php =================================================================== --- branches/SM-1_4-STABLE/squirrelmail/functions/i18n.php 2007-03-30 20:45:55 UTC (rev 12356) +++ branches/SM-1_4-STABLE/squirrelmail/functions/i18n.php 2007-03-30 20:47:23 UTC (rev 12357) @@ -23,6 +23,56 @@ require_once(SM_PATH . 'functions/global.php'); /** + * Wrapper for textdomain(), bindtextdomain() and + * bind_textdomain_codeset() primarily intended for + * plugins when changing into their own text domain + * and back again. + * + * Note that plugins using this function must have + * their translation files located in the SquirrelMail + * locale directory. + * + * @param string $domain_name The name of the text domain + * (usually the plugin name, or + * "squirrelmail") being switched to. + * + * @return void + * + * @since 1.5.2 and 1.4.10 + */ +function sq_change_text_domain($domain_name) { + + global $languages, $sm_notAlias, $use_gettext; + static $domains_already_seen = array(); + + // only need to call bindtextdomain() once unless + // $use_gettext is turned on + // + if (!$use_gettext && in_array($domain_name, $domains_already_seen)) { + textdomain($domain_name); + return; + } + + $domains_already_seen[] = $domain_name; + + bindtextdomain($domain_name, SM_PATH . 'locale/'); + textdomain($domain_name); + + // set codeset in order to avoid gettext charset conversions + if (function_exists('bind_textdomain_codeset') + && isset($languages[$sm_notAlias]['CHARSET'])) { + + // Japanese translation uses different internal charset + if ($sm_notAlias == 'ja_JP') { + bind_textdomain_codeset ($domain_name, 'EUC-JP'); + } else { + bind_textdomain_codeset ($domain_name, $languages[$sm_notAlias]['CHARSET']); + } + + } +} + +/** * php setlocale function wrapper * * From php 4.3.0 it is possible to use arrays in order to set locale. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |