This trait provides various utility functions for manipulating strings, handling pluralization, formatting dates, and managing language settings.

String Manipulation

getPrettyName

Converts a table name to a more readable format.

Returns a string with the first letter capitalized and underscores replaced by spaces.

getPrettyNameInAllCaps

Converts a table name to an all-uppercase format.

Returns a string with all letters in uppercase and underscores replaced by spaces.

singularizeName

Converts a plural name to its singular form.

Returns the singular form of the given name, with exceptions for irregular nouns.

pluralizeName

Converts a singular name to its plural form.

Returns the plural form of the given name, with exceptions for irregular nouns.

nullToString

Converts null or undefined values to an empty string.

Returns an empty string if the input is null, undefined, or an empty value; otherwise, returns the input value.

remove_accents

Removes accents from a string.

Returns the input string with accented characters replaced by their non-accented equivalents.

Data Formatting

getSelector

Generates an array for use in select dropdowns.

Returns an array of key-value pairs suitable for use in a dropdown selector.

dateFormatter

Formats a date string according to the specified format and locale.

Returns the formatted date string based on the current language setting.

Language Management

_setLang

Sets the language for the application based on a cookie value.

This method checks for a language cookie and sets the application language accordingly. It also loads the appropriate language file and sets the locale.

This method is protected and intended to be used internally within the class.