Usage
nebula.singularPlural(value, singular, plural)
Parameters
value
(Required) (Integer or Float) The value to determine the label for
Default: None
singular
(Required) (String) The singular label
Default: None
plural
(Optional) (String) The plural label
Default: Adds an "s" to the singular label
Parameter Notes
If the plural form of the singular label is the same but with an “s” (like “book” and “books”), you do not need to pass the plural parameter.
Examples
When the plural simply adds an "s", no need for the third parameter.
nebula.singularPlural(number, 'hour');
When the plural is spelled differently, the third parameter is needed.
nebula.singularPlural(number, 'story', 'stories');
Source File
Located in /assets/js/modules/utilities.js on line 870.
No Hooks
This function does not have any filters or actions available. Request one?nebula.singularPlural = function(value, singular, plural=''){ if ( value == 1 ){ return singular; } if ( !plural ){ plural = singular + 's'; //Append an "s" to the singular label to simplify calling the function most of the time } return plural; };
Override
To override or disable this JavaScript function, simply redeclare it with the exact same function name. Remember: Some functionality is conditionally loaded via dynamic imports, so if your function is not overriding properly, try listening for a DOM event (described below).
For non-module import functions:
nebula.singularPlural = function(value, singular, plural){ //Write your own code here, leave it blank, or return false. }
For dynamically imported module function overrides:
jQuery(window).on('load', function(){ nebula.singularPlural = function(value, singular, plural){ //Write your own code here, leave it blank, or return false. } });
Custom Nebula DOM events do also exist, so you could also try the following if the Window Load listener does not work:
jQuery(document).on('nebula_module_loaded', function(module){ //Note that the module variable is also available to know which module specifically was imported if ( typeof nebula.singularPlural === 'function' ){ nebula.singularPlural = function(value, singular, plural){ //Write your own code here, leave it blank, or return false. } } });