2

We are using the Craft's currency filter to display localised prices 344552.32 | currency('GBP') which works great in most instances.

However the currency symbol for UK Sterling in the French locale file is £UK and the translation company we are working with are saying that we just need to output £.

This is defined in the currencySymbols array of craft/app/framework/i18n/data.fr.php.

Is there a way we can affect that at a configuration level or at runtime? If not I guess we would have to create our own filter function that wraps the core functionality and does a string replace on the output.

1

A further requirement came up to change the Italian output (symbol moved to after the price rather than before) so I opted for a simple Twig extension:

/**
 * Wrapper for Craft's NumberFormatter->formatCurrency
 * Changes formats for French and Italian display
 *
 * @param        $value
 * @param string $currency
 *
 * @return string
 */
public function currencyDisplay ($value, $currency = 'GBP')
{
    $value = craft()->numberFormatter->formatCurrency($value, $currency);
    $localeId = craft()->locale->id;

    if ($localeId == 'fr')
    {
        $value = str_replace('£UK', '£', $value); // remove UK
    }
    else if ($localeId == 'it')
    {
        $value = str_replace('£ ', '', $value) . ' £'; // relocate sterling symbol
    }

    return $value;
}
| improve this answer | |
0

I don't think you can override that, but I'm not 100% sure. But, there's always the option to run the replacefilter on the output from currency:

{{ 344552.32 | currency('GBP') | replace('£UK', '£') }}
| improve this answer | |
0

A plugin like you mention is an option, but you should be able to use static translations for this, too. Only downside is that it would replace all instances of £UK with £, which may or may not be a problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.