Jump to content
bigluck

Currency Converter workflow with natural language support

Recommended Posts

Hi everybody,

 

I've created a simple but (i hope) useful currency converter; this workflow support simple and complex queries like:

 

  • currency € -- Current EUR/USD exchange
  • currency € £ -- Current EUR/GBP exchange
  • currency 12 € -- Convert 12 EUR to USD
  • currency 12€ £ -- Convert 12 EUR to GBP
  • currency 12 € £ -- Convert 12 EUR to GBP
  • currency 12 EUR £ -- Convert 12 EUR to GBP
  • currency 12 EUR to £ -- Convert 12 EUR to GBP
  • currency from 12 € to GBP -- Convert 12 EUR to GBP
  • currency to GBP from 3€ -- Convert 3 EUR to GBP
  • currency to GBP 3€ -- Convert 3 EUR to GBP
125p63a.jpg
 

 

Share this post


Link to post

Hi, 

 

Just started using your workflow, awesome stuff! I just have one problem with it, when I try to type 'currency' (or my current shortcut curr) quickly I do get sometimes the 'currency-set-to' instead of the converter. Is there some way that you can mark 'currency' in the code as the 'main' action? Or maybe this is a good suggestion for the alfred V2 workflow code?

Share this post


Link to post

Otherwise great, but the default currency feature doesn't really work. If I set my default to currency to EUR, it converts USD into EUR without any additional parameters, but when I try any other currency (GBP, JPY), it automatically converts it to USD instead of EUR.

Share this post


Link to post

Otherwise great, but the default currency feature doesn't really work. If I set my default to currency to EUR, it converts USD into EUR without any additional parameters, but when I try any other currency (GBP, JPY), it automatically converts it to USD instead of EUR.

 

That's also bothering me a bit, even though the workflow is really nice. I'm trying to dig through the code but it seems I'm not pro enough for this one..  :wacko:

Share this post


Link to post

Like this workflow as well, but the default currency was bothering me as well. The problem appears to lie on line 129 of e4QueryParser.php in libs.

 

Change this from:-

 

$this->to = $this->from->isEqualOf($this->defaultFrom) ? $this->defaultTo : $this->defaultFrom;

 

to:-

 

$this->to = $this->from->isEqualOf($this->defaultTo) ? $this->defaultFrom : $this->defaultTo;

Share this post


Link to post

Quite new to Alfred but thought it might be a useful hint anyway... apologies if it is beneath the 'level'....

 

I just created a short TextExpander snippet to speed up the process...

 

Having set currencies to From USD to GBP

 

I have a snippet that is just $£ that expands to Currency - I then just type the amount... I think it makes an already useful workflow even easier.

 

 

Share this post


Link to post

Nice one. What’s missing is an optional preference to round the output value to 2 decimal places if the input value is NOT EQUAL to 1.

 

Explanation:

  • If one enters no input value or 1, it means the user is interested in the exchange rate in full detail. Example: EUR 1 = USD 1.3533.
  • If however the input value is an "actual" cost/price, so the input DOES NOT EQUAL 1(.00), it is clear that this input is an "actual" conversion of that price/cost. Example: EUR 0.23 or EUR 154.89 as input value looks like an actual price.
  • An alternative (better ???) method to decide when to round to 2 decimal digits and when not to round, might be the size of the output (!) number itself (= number of digits in front of the comma/period). Example: When the input value of a large scale mass-produced item is lets say EUR 4.53, the third decimal place of the resulting USD value (so those 0.x Cents) might be important, thus the full number should be copied to the clipboard. If the output result however is USD 183.48(7) the out result should be rounded to 2 decimals -> 183.49 should be displayed and copied to the clipboard.

Share this post


Link to post

Hi

 

Thank you so much for this great workflow, really helpful. Is there any easy way to change from where the information is collected? So instead of google finance, to use another service? In some countries (eg. China) google is unavailable, and when not connected to a VPN the workflow doesn't work.

Share this post


Link to post

This workflow ceased working some weeks ago. It appears to be abandoned.

 

It generates a query error. There is a way to fix it.

 

View the workflow in Finder.
Edit the file:  `/libs/e4QuerySend.php`

Change line 56. It is currently:
 

$response = $this->app->sendHTTPRequest('http://www.google.com/finance/converter?'.http_build_query(array(

Change it to:

$response = $this->app->sendHTTPRequest('https://finance.google.com/finance/converter?'.http_build_query(array(


You can view the required changes here, https://github.com/bigluck/alfred2-currencyconverter/pull/22/files - courtesy of Enochenti.

 

It will now work as before.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...