Skip to content

Commit 59a6b5e

Browse files
committed
I18N: Add new WP_Locale::get_month_genitive() method.
Complements existing helper methods such as `WP_Locale::get_month_abbrev()`. Props ankitkumarshah, Tkama, SergeyBiryukov. Fixes #58658. git-svn-id: https://develop.svn.wordpress.org/trunk@59494 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9c7d008 commit 59a6b5e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/wp-includes/class-wp-locale.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,26 @@ public function get_month_abbrev( $month_name ) {
336336
return $this->month_abbrev[ $month_name ];
337337
}
338338

339+
/**
340+
* Retrieves translated version of month genitive string.
341+
*
342+
* The $month_number parameter has to be a string
343+
* because it must have the '0' in front of any number
344+
* that is less than 10. Starts from '01' and ends at
345+
* '12'.
346+
*
347+
* You can use an integer instead and it will add the
348+
* '0' before the numbers less than 10 for you.
349+
*
350+
* @since 6.8.0
351+
*
352+
* @param string|int $month_number '01' through '12'.
353+
* @return string Translated genitive month name.
354+
*/
355+
public function get_month_genitive( $month_number ) {
356+
return $this->month_genitive[ zeroise( $month_number, 2 ) ];
357+
}
358+
339359
/**
340360
* Retrieves translated version of meridiem string.
341361
*

0 commit comments

Comments
 (0)