Localization
- Type
- Abstract Class
- Namespace
- craft\commerce\helpers
- Inherits
- craft\commerce\helpers\Localization » craft\helpers\Localization (opens new window)
- Since
- 3.4.10
Localization Helper
View source (opens new window)
# Public Methods
| Method | Description |
|---|---|
| findMissingTranslation() (opens new window) | Looks for a missing translation string in Yii's core translations. |
| formatAsPercentage() | Return value as a percentage. |
| localeData() (opens new window) | Returns fallback data for a locale if the Intl extension isn't loaded. |
| normalizeLanguage() (opens new window) | Normalizes a language into the correct format (e.g. en-US). |
| normalizeNumber() (opens new window) | Normalizes a user-submitted number for use in code and/or to be saved into the database. |
| normalizePercentage() | Normalizes a percentage value into a float. |
# formatAsPercentage()
DEPRECATED
Deprecated in 3.4.10. This is only used as a stopgap until craft\i18n\Formatter::asDecimal() supports dynamic decimals in Craft 4
Return value as a percentage.
Decimal precision is dynamically calculated when $decimals is null.
View source (opens new window)
Arguments
$value(integer (opens new window), float (opens new window), string (opens new window)) – The value to be formatted. It must be a factor e.g.0.75will result in75%.$decimals(integer (opens new window), null (opens new window)) – The number of digits after the decimal point.$options(array (opens new window)) – Optional configuration for the number formatter. This parameter will be merged with\craft\commerce\helpers\numberFormatterOptions.$textOptions(array (opens new window)) – Optional configuration for the number formatter. This parameter will be merged with\craft\commerce\helpers\numberFormatterTextOptions.
Returns
string (opens new window) – The formatted result.
# normalizePercentage()
Normalizes a percentage value into a float.
View source (opens new window)
Arguments
$number(integer (opens new window), float (opens new window), string (opens new window), null (opens new window))