Amire80 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/245184
Change subject: Move the Ukrainian grammar rules from PHP and JS to JSON
......................................................................
Move the Ukrainian grammar rules from PHP and JS to JSON
Bug: T115217
Change-Id: I15a06b07e381cc9074e64e746d22ec51e9e638c4
---
M languages/classes/LanguageUk.php
A languages/data/grammarTransformations/uk.json
M resources/Resources.php
D resources/src/mediawiki.language/languages/uk.js
4 files changed, 18 insertions(+), 77 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/84/245184/1
diff --git a/languages/classes/LanguageUk.php b/languages/classes/LanguageUk.php
index 8261f11..a155d03 100644
--- a/languages/classes/LanguageUk.php
+++ b/languages/classes/LanguageUk.php
@@ -27,50 +27,6 @@
* @ingroup Language
*/
class LanguageUk extends Language {
-
- /**
- * Convert from the nominative form of a noun to some other case
- * Invoked with {{grammar:case|word}}
- *
- * @param string $word
- * @param string $case
- * @return string
- */
- function convertGrammar( $word, $case ) {
- global $wgGrammarForms;
- if ( isset( $wgGrammarForms['uk'][$case][$word] ) ) {
- return $wgGrammarForms['uk'][$case][$word];
- }
-
- # These rules don't cover the whole language.
- # They are used only for site names.
-
- # join and array_slice instead mb_substr
- $ar = array();
- preg_match_all( '/./us', $word, $ar );
- if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
- switch ( $case ) {
- case 'genitive': # родовий відмінок
- if ( join( '', array_slice( $ar[0], -2
) ) === 'ія' ) {
- $word = join( '', array_slice(
$ar[0], 0, -2 ) ) . 'ії';
- } elseif ( join( '', array_slice(
$ar[0], -2 ) ) === 'ти' ) {
- $word = join( '', array_slice(
$ar[0], 0, -2 ) ) . 'т';
- } elseif ( join( '', array_slice(
$ar[0], -2 ) ) === 'ди' ) {
- $word = join( '', array_slice(
$ar[0], 0, -2 ) ) . 'дів';
- } elseif ( join( '', array_slice(
$ar[0], -3 ) ) === 'ник' ) {
- $word = join( '', array_slice(
$ar[0], 0, -3 ) ) . 'ника';
- }
- break;
- case 'accusative': # знахідний відмінок
- if ( join( '', array_slice( $ar[0], -2
) ) === 'ія' ) {
- $word = join( '', array_slice(
$ar[0], 0, -2 ) ) . 'ію';
- }
- break;
- }
- }
- return $word;
- }
-
/**
* Ukrainian numeric format is "12 345,67" but "1234,56"
*
diff --git a/languages/data/grammarTransformations/uk.json
b/languages/data/grammarTransformations/uk.json
new file mode 100644
index 0000000..6512225
--- /dev/null
+++ b/languages/data/grammarTransformations/uk.json
@@ -0,0 +1,18 @@
+{
+ "@metadata": {
+ "authors": [
+ "Gutsul",
+ "Amir E. Aharoni ([email protected])"
+ ],
+ "comment": "These rules don't cover the whole grammar of the
language, and are intended only for names of languages and Wikimedia projects."
+ },
+ "genitive": [
+ [ "(.+)ія$", "$1ії" ],
+ [ "(.+)ти$", "$1т" ],
+ [ "(.+)ди$", "$1дів" ],
+ [ "(.+)ник$", "$1ника" ]
+ ],
+ "accusative": [
+ [ "(.+)ія$", "$1ію" ]
+ ]
+}
diff --git a/resources/Resources.php b/resources/Resources.php
index e63238b..f7c22d5 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -1486,7 +1486,6 @@
'la' =>
'resources/src/mediawiki.language/languages/la.js',
'os' =>
'resources/src/mediawiki.language/languages/os.js',
'sl' =>
'resources/src/mediawiki.language/languages/sl.js',
- 'uk' =>
'resources/src/mediawiki.language/languages/uk.js',
),
'dependencies' => array(
'mediawiki.language.data',
diff --git a/resources/src/mediawiki.language/languages/uk.js
b/resources/src/mediawiki.language/languages/uk.js
deleted file mode 100644
index 138045c..0000000
--- a/resources/src/mediawiki.language/languages/uk.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*!
- * Ukrainian (Українська) language functions
- */
-
-mediaWiki.language.convertGrammar = function ( word, form ) {
- var grammarForms = mediaWiki.language.getData( 'uk', 'grammarForms' );
- if ( grammarForms && grammarForms[ form ] ) {
- return grammarForms[ form ][ word ];
- }
- switch ( form ) {
- case 'genitive': // родовий відмінок
- if ( word.slice( -2 ) === 'ія' ) {
- word = word.slice( 0, -2 ) + 'ії';
- } else if ( word.slice( -2 ) === 'ти' ) {
- word = word.slice( 0, -2 ) + 'т';
- } else if ( word.slice( -2 ) === 'ди' ) {
- word = word.slice( 0, -2 ) + 'дів';
- } else if ( word.slice( -3 ) === 'ник' ) {
- word = word.slice( 0, -3 ) + 'ника';
- }
-
- break;
- case 'accusative': // знахідний відмінок
- if ( word.slice( -2 ) === 'ія' ) {
- word = word.slice( 0, -2 ) + 'ію';
- }
-
- break;
- }
-
- return word;
-};
--
To view, visit https://gerrit.wikimedia.org/r/245184
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I15a06b07e381cc9074e64e746d22ec51e9e638c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits