LanguageKaa.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Karakalpak (Qaraqalpaqsha) specific code.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup Language
  22. */
  23. /**
  24. * Karakalpak (Qaraqalpaqsha)
  25. *
  26. * @ingroup Language
  27. */
  28. class LanguageKaa extends Language {
  29. # Convert from the nominative form of a noun to some other case
  30. # Invoked with {{GRAMMAR:case|word}}
  31. /**
  32. * Cases: genitive, dative, accusative, locative, ablative, comitative + possessive forms
  33. *
  34. * @param string $word
  35. * @param string $case
  36. *
  37. * @return string
  38. */
  39. function convertGrammar( $word, $case ) {
  40. global $wgGrammarForms;
  41. if ( isset( $wgGrammarForms['kaa'][$case][$word] ) ) {
  42. return $wgGrammarForms['kaa'][$case][$word];
  43. }
  44. /* Full code of function convertGrammar() is in development. Updates coming soon. */
  45. return $word;
  46. }
  47. /**
  48. * It fixes issue with ucfirst for transforming 'i' to 'İ'
  49. *
  50. * @param string $string
  51. *
  52. * @return string
  53. */
  54. public function ucfirst( $string ) {
  55. if ( substr( $string, 0, 1 ) === 'i' ) {
  56. return 'İ' . substr( $string, 1 );
  57. }
  58. return parent::ucfirst( $string );
  59. }
  60. /**
  61. * It fixes issue with lcfirst for transforming 'I' to 'ı'
  62. *
  63. * @param string $string
  64. *
  65. * @return mixed|string
  66. */
  67. function lcfirst( $string ) {
  68. if ( substr( $string, 0, 1 ) === 'I' ) {
  69. return 'ı' . substr( $string, 1 );
  70. }
  71. return parent::lcfirst( $string );
  72. }
  73. /**
  74. * Avoid grouping whole numbers between 0 to 9999
  75. *
  76. * @param string $_
  77. *
  78. * @return string
  79. */
  80. function commafy( $_ ) {
  81. if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
  82. return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
  83. } else {
  84. return $_;
  85. }
  86. }
  87. }