This question about Using an extension: Answered

Build EUR Macro for NumberPlugin

Hi,

I just installed NumberPlugin, which does exactly what I need.

But I tried to use the %EUR% Macro, which is mentioned in the documentation. There is no setting for it in foswiki's configure page, so tried to add the line
$Foswiki::cfg{NumberPlugin}{Currencies} = "EUR, USD";

to LocalSite.cfg, but the Macro does not work. I'm missing something here?

-- MichaelLorenzen - 12 Mar 2021

Yes: you need to configure a {RatesProvider} via configure. Which means you'll presumably need an api key depeding on the provider of your choice.

-- MichaelDaum - 12 Mar 2021

OK, I think I'll try that. Does the plugin do api-calls, if no currency conversion is required?

My use case is just to format numbers as EUR with german locale.

-- MichaelLorenzen - 12 Mar 2021

I don't want to access external api provider, but just want to use NumberPlugin's format capabilities, so I did the following (which works perfectly for me):

  1. Set a macro in WebPreferences (I choosed EURO because I don't want to conflict with the EUR-Macro of NumberPlugin):
       * Set EURO = %NUMBER{"%DEFAULT{default=0}%" type="currency" currency="EUR"}% 
  2. Use my own Macro to format numbers:
     %EURO{" 1200 "}% 
    gives 1.200,00 €

-- MichaelLorenzen

This is more of a docu issue: the $Foswiki::cfg{NumberPlugin}{Currencies} setting simply doesn't exist. Your approach is just right: define a macro as required. The plugin itself does the same for all known currencies ... as available by the currency provider. Calling the macro %EUR is fine as well.

-- MichaelDaum - 15 Mar 2021

Next release will bring back the functionality without having to configure a rates provider.

-- MichaelDaum - 15 Mar 2021
 

QuestionForm edit

Subject Using an extension
Extension NumberPlugin
Version Foswiki 2.1.6
Status Answered
Related Topics
Topic revision: r6 - 15 Mar 2021, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy