About PW-TextformatterCurrency

Locale aware currency formatter module for Processwire

Category Text Formatters
Textformatter modules that provide run-time formatting for blocks of text (typically used with Text/Textarea fields).
Release StateBeta
Close to stable, but users are advised to be cautious and test thoroughly.*
Authornetcarver
Module Version1.1.0
Class NameTextformatterCurrency
Compatibility2.7, 3.0
Date AddedMay 15, 2016
Last UpdatedMay 21, 2016
Recommended ByNew recommendations may take up to 1 day to appear.

Instructions

This module's files should be placed in /site/modules/TextformatterCurrency/
How to install or uninstall modules

README

TextformatterCurrency

A locale-aware currency formatter module for Processwire.

The module reads a conforming input money formatted string, splits it and formats each valid monetary amount accordingto the locale defined in the module settings. The module is capable of using the visiting browser's headers to determine which locale to use when formatting monetary amounts of various currencies.

Internally, the module uses PHPs Internationalization extension (intl) to do the formatting.

Input money format

The input money format is made up of any number of currency-amount pairs.

Each input money pair is made up of a currency code and an amount. These are always separated by at least one space with the code comingfirst. (eg. GBP 50.99 or JPY 100000.)

  • No thousands separators are allowed in the input.
  • A full-stop . character is the only acceptable decimal separator.

Each money pair is separated by a configurable character string ('|' by default.) You can change the character used tosplit the incoming string into currency-amount pairs in the module settings page.

Output format

Each currency-amount pair is formatted using the defined locale or that supplied by the browser and thus appearslocalised in the output of the formatter. If the input text has more than one currency-amount money pair then the output will join the localised outputs for each pair using the output glue string defined in the module settings.

Examples Using Module Defaults

Input GBP 50.99 | EUR 100 gives £50.99 + €100.00 when viewed in browser set to British English but gives 50,99 £GB + 100,00 € using a browser set to French.

Comments

No comments yet. Be the first to post!

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.