llms_get_time_period_l10n( string $period, integer $length = 1 )

Retrieve the translated (and optionally pluralized) name for a given time period string


Description Description

This is used primarily to display time period data which is stored directly in the database. When displaying to a user, we wish to ensure that the translated version is displayed instead of the raw and untranslated value stored in the database.


Top ↑

Parameters Parameters

$period

(string) (Required) A time period string, accepts "day", "week", "month", or "year".

$length

(integer) (Optional) The length of the period, passed to _n() and used for pluralization. Defaults to 1.

Default value: 1


Top ↑

Return Return

(string) The translated and pluralized time period string. Returns the submitted string for unsupported strings.


Top ↑

Source Source

File: includes/functions/llms-functions-locale.php

function llms_get_time_period_l10n( $period, $length = 1 ) {

	switch ( strtolower( $period ) ) {

		case 'day':
			$period = _n( 'day', 'days', $length, 'lifterlms' );
			break;

		case 'week':
			$period = _n( 'week', 'weeks', $length, 'lifterlms' );
			break;

		case 'month':
			$period = _n( 'month', 'months', $length, 'lifterlms' );
			break;

		case 'year':
			$period = _n( 'year', 'years', $length, 'lifterlms' );
			break;

	}

	/**
	 * Filter the translated name for a given time period string.
	 *
	 * @since 5.3.0
	 *
	 * @param string $period Translated period name.
	 * @param int    $length Period length, used for pluralization.
	 */
	return apply_filters( 'llms_time_period_l10n', $period, $length );

}


Top ↑

Changelog Changelog

Changelog
Version Description
5.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.