From 362896be58231a55de707cfa7cefbf774bfb36ac Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Sun, 3 Jul 2005 09:51:17 +0000 Subject: [PATCH] allow the definition of replacement chars for the URL on a per-language basis --- docs/NEWS | 5 +++++ include/functions_permalinks.inc.php | 10 ++++++++-- lang/serendipity_lang_ru.inc.php | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index c74e631..ee728be 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,11 @@ Version 0.9 () ------------------------------------------------------------------------ + * Allow language files to define $i18n_filename_from and _to array + so that each language can individually rewrite URL characters. + Only the Russian language currently makes use of this. + (garvinhicking) + * fixed serendipity_traversePath() - PHP5 issue with array_merge() Thanks to jdhawk for the fix (flotsam) diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index 238bac9..b2ed4f7 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -89,8 +89,14 @@ function serendipity_makeFilename($str) { 'y'); - // Replace international chars not detected by every locale - $str = str_replace($from, $to, $str); + if (isset($GLOBALS['i18n_filename_from'])) { + // Replace international chars not detected by every locale. + // The array of chars is defined in the language file. + $str = str_replace($GLOBALS['i18n_filename_from'], $GLOBALS['i18n_filename_to'], $str); + } else { + // Replace international chars not detected by every locale + $str = str_replace($from, $to, $str); + } // Nuke chars not allowed in our URI $str = preg_replace('#[^' . PAT_FILENAME . ']#i', '', $str); diff --git a/lang/serendipity_lang_ru.inc.php b/lang/serendipity_lang_ru.inc.php index f1508e3..042f7bb 100644 --- a/lang/serendipity_lang_ru.inc.php +++ b/lang/serendipity_lang_ru.inc.php @@ -11,6 +11,8 @@ @define('NUMBER_FORMAT_DECPOINT', '.'); @define('NUMBER_FORMAT_THOUSANDS', ', '); @define('LANG_DIRECTION', 'ltr'); +$i18n_filename_from = array(' ', 'а', 'А', 'б', 'Б', 'в', 'В', 'г', 'Г', 'д', 'Д', 'е', 'Е', 'ё', 'Ё', 'Ж', 'ж', 'з', 'З', 'и', 'И', 'й', 'Й', 'к', 'К', 'л', 'Л', 'м', 'М', 'н', 'Н', 'о', 'О', 'п', 'П', 'р','Р', 'с', 'С', 'т', 'Т', 'у', 'У', 'ф', 'Ф', 'х', 'Х', 'ц', 'Ц', 'ч', 'Ч', 'ш', 'Ш', 'щ', 'Щ', 'ъ', 'Ъ', 'ы', 'Ы', 'ь', 'Ь', 'э', 'Э', 'ю', 'Ю', 'Я', 'я'); +$i18n_filename_to = array('_', 'a', 'A', 'b', 'B', 'v', 'V', 'g', 'G', 'd', 'D', 'e', 'E', 'jo', 'Jo', 'zh', 'Zh', 'z', 'Z', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'f', 'F', 'h', 'H', 'c', 'C', 'ch', 'Ch', 'sh', 'Sh', 'w', 'W', '#', '#', 'y', 'Y', '’', '’', 'je', 'Je', 'ju', 'Ju', 'ja', 'Ja'); @define('SERENDIPITY_ADMIN_SUITE', 'Администрирование Serendipity'); @define('HAVE_TO_BE_LOGGED_ON', 'Вы должны войти под каким-нибудь пользователем, чтобы иметь доступ к этой странице'); -- 2.39.5