Jump to content

Name of current weekday as localised string


Recommended Posts

I'm quite new to Alfred, but already loving it!

 

I'm trying to make a workflow that pastes the name of current the weekday as localised string in the front most app. I use the Copy-to-Clipboard output for this with the following formula: {date:EEEE}

 

Works great! Only thing is, that I need the weekday-name to be localised to Danish. I'm a programmer and wouldn't mind a simple if-else- or switch-structure to do the translation. Like:

 

if( {date:EEEE} == "Monday" ) return "Mandag";
else if( {date:EEEE} == "Tuesday" ) return "Tirsdag";
else if( {date:EEEE} == "Wednesday" ) return "Onsdag";
...

 

I'm not sure, if this is possible and how the syntax would be. Or if it can be done easier in another way.

 

Any help would be most appreciated! 🙂

 

 

Link to comment

Welcome @mmm,

 

2 hours ago, mmm said:

I'm a programmer

 

Then I suggest a Run Script with /bin/bash or /bin/zsh as the language:

 

case "$(date +%A)" in
Monday)
  echo -n 'Mandag'
  ;;
Tuesday)
  echo -n 'Tirsdag'
  ;;
Wednesday)
  echo -n 'Onsdag'
  ;;
Thursday)
  echo -n 'Torsdag'
  ;;
Friday)
  echo -n 'Fredag'
  ;;
Saturday)
  echo -n 'Lørdag'
  ;;
Sunday)
  echo -n 'Søndag'
  ;;
*)
  echo 'Not a valid weekday! Should never happen.' >&2
  ;;
esac

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...