diff --git a/ParserFunctions.i18n.magic.php b/ParserFunctions.i18n.magic.php index ab8bc9e8..ccc64c06 100644 --- a/ParserFunctions.i18n.magic.php +++ b/ParserFunctions.i18n.magic.php @@ -1,111 +1,96 @@ array( 0, 'expr' ), + 'if' => array( 0, 'if' ), + 'ifeq' => array( 0, 'ifeq' ), + 'ifexpr' => array( 0, 'ifexpr' ), + 'iferror' => array( 0, 'iferror' ), + 'switch' => array( 0, 'switch' ), + 'default' => array( 0, '#default' ), + 'ifexist' => array( 0, 'ifexist' ), + 'time' => array( 0, 'time' ), + 'timel' => array( 0, 'timel' ), + 'rel2abs' => array( 0, 'rel2abs' ), + 'titleparts' => array( 0, 'titleparts' ), + 'len' => array( 0, 'len' ), + 'pos' => array( 0, 'pos' ), + 'rpos' => array( 0, 'rpos' ), + 'sub' => array( 0, 'sub' ), + 'count' => array( 0, 'count' ), + 'replace' => array( 0, 'replace' ), + 'explode' => array( 0, 'explode' ), +); - /** - * English - */ - $words['en'] = array( - 'expr' => array( 0, 'expr' ), - 'if' => array( 0, 'if' ), - 'ifeq' => array( 0, 'ifeq' ), - 'ifexpr' => array( 0, 'ifexpr' ), - 'iferror' => array( 0, 'iferror' ), - 'switch' => array( 0, 'switch' ), - 'default' => array( 0, '#default' ), - 'ifexist' => array( 0, 'ifexist' ), - 'time' => array( 0, 'time' ), - 'timel' => array( 0, 'timel' ), - 'rel2abs' => array( 0, 'rel2abs' ), - 'titleparts' => array( 0, 'titleparts' ), - 'len' => array( 0, 'len' ), - 'pos' => array( 0, 'pos' ), - 'rpos' => array( 0, 'rpos' ), - 'sub' => array( 0, 'sub' ), - 'count' => array( 0, 'count' ), - 'replace' => array( 0, 'replace' ), - 'explode' => array( 0, 'explode' ), - ); +/** + * Farsi-Persian + */ +$magicWords['fa'] = array( + 'expr' => array( 0, 'حساب', 'expr' ), + 'if' => array( 0, 'اگر', 'if' ), + 'ifeq' => array( 0, 'اگرمساوی', 'ifeq' ), + 'ifexpr' => array( 0, 'اگرحساب', 'ifexpr' ), + 'iferror' => array( 0, 'اگرخطا', 'iferror' ), + 'switch' => array( 0, 'گزینه', 'switch' ), + 'default' => array( 0, '#پیش‌فرض', '#default' ), + 'ifexist' => array( 0, 'اگرموجود', 'ifexist' ), + 'time' => array( 0, 'زمان', 'time' ), + 'timel' => array( 0, 'زمان‌بلند', 'timel' ), + 'rel2abs' => array( 0, 'نسبی‌به‌مطلق', 'rel2abs' ), + 'titleparts' => array( 0, 'پاره‌عنوان', 'titleparts' ), +); - /** - * Farsi-Persian - */ - $words['fa'] = array( - 'expr' => array( 0, 'حساب', 'expr' ), - 'if' => array( 0, 'اگر', 'if' ), - 'ifeq' => array( 0, 'اگرمساوی', 'ifeq' ), - 'ifexpr' => array( 0, 'اگرحساب', 'ifexpr' ), - 'iferror' => array( 0, 'اگرخطا', 'iferror' ), - 'switch' => array( 0, 'گزینه', 'switch' ), - 'default' => array( 0, '#پیش‌فرض', '#default' ), - 'ifexist' => array( 0, 'اگرموجود', 'ifexist' ), - 'time' => array( 0, 'زمان', 'time' ), - 'timel' => array( 0, 'زمان‌بلند', 'timel' ), - 'rel2abs' => array( 0, 'نسبی‌به‌مطلق', 'rel2abs' ), - 'titleparts' => array( 0, 'پاره‌عنوان', 'titleparts' ), - ); +/** + * Hebrew + */ +$magicWords['he'] = array( + 'expr' => array( 0, 'חשב', 'expr' ), + 'if' => array( 0, 'תנאי', 'if' ), + 'ifeq' => array( 0, 'שווה', 'ifeq' ), + 'ifexpr' => array( 0, 'חשב תנאי', 'ifexpr' ), + 'iferror' => array( 0, 'תנאי שגיאה', 'iferror' ), + 'switch' => array( 0, 'בחר', 'switch' ), + 'default' => array( 0, '#ברירת מחדל', '#default' ), + 'ifexist' => array( 0, 'קיים', 'ifexist' ), + 'time' => array( 0, 'זמן', 'time' ), + 'timel' => array( 0, 'זמןמ', 'timel' ), + 'rel2abs' => array( 0, 'יחסי למוחלט', 'rel2abs' ), + 'titleparts' => array( 0, 'חלק בכותרת', 'titleparts' ), +); - /** - * Hebrew - */ - $words['he'] = array( - 'expr' => array( 0, 'חשב', 'expr' ), - 'if' => array( 0, 'תנאי', 'if' ), - 'ifeq' => array( 0, 'שווה', 'ifeq' ), - 'ifexpr' => array( 0, 'חשב תנאי', 'ifexpr' ), - 'iferror' => array( 0, 'תנאי שגיאה', 'iferror' ), - 'switch' => array( 0, 'בחר', 'switch' ), - 'default' => array( 0, '#ברירת מחדל', '#default' ), - 'ifexist' => array( 0, 'קיים', 'ifexist' ), - 'time' => array( 0, 'זמן', 'time' ), - 'timel' => array( 0, 'זמןמ', 'timel' ), - 'rel2abs' => array( 0, 'יחסי למוחלט', 'rel2abs' ), - 'titleparts' => array( 0, 'חלק בכותרת', 'titleparts' ), - ); +/** + * Indonesian + */ +$magicWords['id'] = array( + 'expr' => array( 0, 'hitung', 'expr' ), + 'if' => array( 0, 'jika', 'if' ), + 'ifeq' => array( 0, 'jikasama', 'ifeq' ), + 'ifexpr' => array( 0, 'jikahitung', 'ifexpr' ), + 'iferror' => array( 0, 'jikasalah', 'iferror' ), + 'switch' => array( 0, 'pilih', 'switch' ), + 'default' => array( 0, '#baku', '#default' ), + 'ifexist' => array( 0, 'jikaada', 'ifexist' ), + 'time' => array( 0, 'waktu', 'time' ), + 'timel' => array( 0, 'waktu1', 'timel' ), + 'rel2abs' => array( 0, 'rel2abs' ), + 'titleparts' => array( 0, 'bagianjudul', 'titleparts' ), +); - /** - * Indonesian - */ - $words['id'] = array( - 'expr' => array( 0, 'hitung', 'expr' ), - 'if' => array( 0, 'jika', 'if' ), - 'ifeq' => array( 0, 'jikasama', 'ifeq' ), - 'ifexpr' => array( 0, 'jikahitung', 'ifexpr' ), - 'iferror' => array( 0, 'jikasalah', 'iferror' ), - 'switch' => array( 0, 'pilih', 'switch' ), - 'default' => array( 0, '#baku', '#default' ), - 'ifexist' => array( 0, 'jikaada', 'ifexist' ), - 'time' => array( 0, 'waktu', 'time' ), - 'timel' => array( 0, 'waktu1', 'timel' ), - 'rel2abs' => array( 0, 'rel2abs' ), - 'titleparts' => array( 0, 'bagianjudul', 'titleparts' ), - ); - - /** - * Yiddish - */ - $words['yi'] = array( - 'expr' => array( 0, 'רעכן', 'expr' ), - 'if' => array( 0, 'תנאי', 'if' ), - 'ifeq' => array( 0, 'גלייך', 'ifeq' ), - 'ifexpr' => array( 0, 'אויברעכן', 'ifexpr' ), - 'switch' => array( 0, 'קלייב', 'switch' ), - 'default' => array( 0, '#גרונט', '#default' ), - 'ifexist' => array( 0, 'עקזיסט', 'ifexist' ), - 'time' => array( 0, 'צייט', 'time' ), - 'timel' => array( 0, 'צייטל', 'timel' ), - ); - - # English is used as a fallback, and the English synonyms are - # used if a translation has not been provided for a given word - return ( $lang == 'en' || !isset( $words[$lang] ) ) - ? $words['en'] - : array_merge( $words['en'], $words[$lang] ); -} +/** + * Yiddish + */ +$magicWords['yi'] = array( + 'expr' => array( 0, 'רעכן', 'expr' ), + 'if' => array( 0, 'תנאי', 'if' ), + 'ifeq' => array( 0, 'גלייך', 'ifeq' ), + 'ifexpr' => array( 0, 'אויברעכן', 'ifexpr' ), + 'switch' => array( 0, 'קלייב', 'switch' ), + 'default' => array( 0, '#גרונט', '#default' ), + 'ifexist' => array( 0, 'עקזיסט', 'ifexist' ), + 'time' => array( 0, 'צייט', 'time' ), + 'timel' => array( 0, 'צייטל', 'timel' ), +); diff --git a/ParserFunctions.i18n.php b/ParserFunctions.i18n.php index 2f964bd2..c9f38275 100644 --- a/ParserFunctions.i18n.php +++ b/ParserFunctions.i18n.php @@ -5,6 +5,8 @@ * @addtogroup Extensions */ +require_once( dirname(__FILE__) . '/ParserFunctions.i18n.magic.php' ); + $messages = array(); $messages['en'] = array( diff --git a/ParserFunctions.php b/ParserFunctions.php index 2ac3659e..c654f388 100644 --- a/ParserFunctions.php +++ b/ParserFunctions.php @@ -30,13 +30,12 @@ $wgPFStringLengthLimit = 1000; */ $wgPFEnableStringFunctions = false; - /** REGISTRATION */ $wgExtensionFunctions[] = 'wfSetupParserFunctions'; $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => 'ParserFunctions', - 'version' => '1.2.0', + 'version' => '1.3.0', 'url' => 'http://www.mediawiki.org/wiki/Extension:ParserFunctions', 'author' => array('Tim Starling', 'Robert Rohde', 'Ross McClure', 'Juraj Simlovic'), 'description' => 'Enhance parser with logical functions', @@ -45,11 +44,9 @@ $wgExtensionCredits['parserhook'][] = array( $wgAutoloadClasses['ExtParserFunctions'] = dirname(__FILE__).'/ParserFunctions_body.php'; $wgExtensionMessagesFiles['ParserFunctions'] = dirname(__FILE__) . '/ParserFunctions.i18n.php'; -$wgHooks['LanguageGetMagic'][] = 'wfParserFunctionsLanguageGetMagic'; $wgParserTestFiles[] = dirname( __FILE__ ) . "/funcsParserTests.txt"; - function wfSetupParserFunctions() { global $wgParser, $wgPFHookStub, $wgHooks; @@ -68,13 +65,6 @@ function wfSetupParserFunctions() { $wgHooks['ParserClearState'][] = array( &$wgPFHookStub, 'clearState' ); } -function wfParserFunctionsLanguageGetMagic( &$magicWords, $langCode ) { - require_once( dirname( __FILE__ ) . '/ParserFunctions.i18n.magic.php' ); - foreach( efParserFunctionsWords( $langCode ) as $word => $trans ) - $magicWords[$word] = $trans; - return true; -} - /** * Stub class to defer loading of the bulk of the code until a parser function is * actually used.