2007-04-26 11:33:59 +00:00
|
|
|
|
<?php
|
2012-06-06 20:42:13 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Armenian (Հայերեն) specific code.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
*
|
|
|
|
|
|
* @file
|
|
|
|
|
|
* @author Ruben Vardanyan (Me@RubenVardanyan.com)
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2007-04-26 11:33:59 +00:00
|
|
|
|
|
2012-06-06 20:42:13 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Armenian (Հայերեն)
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @ingroup Language
|
|
|
|
|
|
*/
|
2007-04-26 11:33:59 +00:00
|
|
|
|
class LanguageHy extends Language {
|
2011-05-29 16:32:05 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Convert from the nominative form of a noun to some other case
|
|
|
|
|
|
* Invoked with {{grammar:case|word}}
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param $word string
|
|
|
|
|
|
* @param $case string
|
|
|
|
|
|
* @return string
|
|
|
|
|
|
*/
|
2007-04-26 11:33:59 +00:00
|
|
|
|
function convertGrammar( $word, $case ) {
|
|
|
|
|
|
global $wgGrammarForms;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( isset( $wgGrammarForms['hy'][$case][$word] ) ) {
|
2007-04-26 11:33:59 +00:00
|
|
|
|
return $wgGrammarForms['hy'][$case][$word];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# These rules are not perfect, but they are currently only used for site names so it doesn't
|
|
|
|
|
|
# matter if they are wrong sometimes. Just add a special case for your site name if necessary.
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
# join and array_slice instead mb_substr
|
2007-04-26 11:33:59 +00:00
|
|
|
|
$ar = array();
|
|
|
|
|
|
preg_match_all( '/./us', $word, $ar );
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
|
2007-04-26 11:33:59 +00:00
|
|
|
|
switch ( $case ) {
|
2010-07-29 09:43:18 +00:00
|
|
|
|
case 'genitive': # սեռական հոլով
|
|
|
|
|
|
if ( join( '', array_slice( $ar[0], -1 ) ) == 'ա' )
|
|
|
|
|
|
$word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'այի';
|
|
|
|
|
|
elseif ( join( '', array_slice( $ar[0], -1 ) ) == 'ո' )
|
|
|
|
|
|
$word = join( '', array_slice( $ar[0], 0, -1 ) ) . 'ոյի';
|
|
|
|
|
|
elseif ( join( '', array_slice( $ar[0], -4 ) ) == 'գիրք' )
|
|
|
|
|
|
$word = join( '', array_slice( $ar[0], 0, -4 ) ) . 'գրքի';
|
2007-04-26 11:33:59 +00:00
|
|
|
|
else
|
2010-07-29 09:43:18 +00:00
|
|
|
|
$word .= 'ի';
|
2007-04-26 11:33:59 +00:00
|
|
|
|
break;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
case 'dative': # Տրական հոլով
|
|
|
|
|
|
# stub
|
2007-04-26 11:33:59 +00:00
|
|
|
|
break;
|
2010-07-29 09:43:18 +00:00
|
|
|
|
case 'accusative': # Հայցական հոլով
|
|
|
|
|
|
# stub
|
2007-04-26 11:33:59 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 'instrumental': #
|
2010-07-29 09:43:18 +00:00
|
|
|
|
# stub
|
2007-04-26 11:33:59 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 'prepositional': #
|
2010-07-29 09:43:18 +00:00
|
|
|
|
# stub
|
2007-04-26 11:33:59 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
return $word;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-29 15:03:33 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @param $count int
|
|
|
|
|
|
* @param $forms array
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return string
|
|
|
|
|
|
*/
|
2007-11-18 20:15:49 +00:00
|
|
|
|
function convertPlural( $count, $forms ) {
|
2010-07-29 09:43:18 +00:00
|
|
|
|
if ( !count( $forms ) ) { return ''; }
|
2007-11-18 20:15:49 +00:00
|
|
|
|
$forms = $this->preConvertPlural( $forms, 2 );
|
|
|
|
|
|
|
2010-07-29 09:43:18 +00:00
|
|
|
|
return ( abs( $count ) <= 1 ) ? $forms[0] : $forms[1];
|
2007-04-26 11:33:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-05-22 22:05:18 +00:00
|
|
|
|
/**
|
2007-04-26 11:33:59 +00:00
|
|
|
|
* Armenian numeric format is "12 345,67" but "1234,56"
|
2011-05-29 15:53:18 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @param $_ string
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return string
|
2007-04-26 11:33:59 +00:00
|
|
|
|
*/
|
2010-07-29 09:43:18 +00:00
|
|
|
|
function commafy( $_ ) {
|
|
|
|
|
|
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
|
|
|
|
|
|
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
|
2007-04-26 11:33:59 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
return $_;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|