Jump to content

Bash script in workflow. Language of locals ? Accented characters ?


Recommended Posts

Hi all,

 

I've have some problems with determining the locals language in bash script in workflows in Alfred2.

I'm on OSX 10.7.5 FR.

 

My script : 

DATE=$(echo "{query}" | sed -e's/HAEC/CEST/g' -e's/HNEC/CET/g'); export LC_TIME="fr_FR.UTF-8"; date -jf "%d %B %Y %T %Z" "$DATE" "+%Y%m%d%H%M%S"

 

I use it :

Select a text date (i.e. : "18 décembre 2006 19:24:12 HNEC"), use my hotkey to launch Alfred2/Workflow/Bashscript

 
Problem :
Works
• In Alfred2 when month has NO accented character (i.e. : "18 janvier 2006 19:24:12 HNEC")
• In terminal as is with or without month with accented characters
 
Does NOT work
• In Alfred2 when month has accented character
 

Note :

I had to add 'export LC_TIME="fr_FR.UTF-8"' as I assume Alfred bash script works in EN. It didn't work with french dates even though my whole system is in french and it DOES work in terminal without the export command. Also, I had to "translate" HAEC and HNEC as date command doesn't understand this frenchified CEST and CET.

 

Any ideas on how I can bypass this problem ? Is it a bug ?

 

Thanks in advance !

 

Hubert

 

Link to comment

Hi all,

 

I've have some problems with determining the locals language in bash script in workflows in Alfred2.

I'm on OSX 10.7.5 FR.

 

My script : 

DATE=$(echo "{query}" | sed -e's/HAEC/CEST/g' -e's/HNEC/CET/g'); export LC_TIME="fr_FR.UTF-8"; date -jf "%d %B %Y %T %Z" "$DATE" "+%Y%m%d%H%M%S"

 

I use it :

Select a text date (i.e. : "18 décembre 2006 19:24:12 HNEC"), use my hotkey to launch Alfred2/Workflow/Bashscript

 
Problem :
Works
• In Alfred2 when month has NO accented character (i.e. : "18 janvier 2006 19:24:12 HNEC")
• In terminal as is with or without month with accented characters
 
Does NOT work
• In Alfred2 when month has accented character
 

Note :

I had to add 'export LC_TIME="fr_FR.UTF-8"' as I assume Alfred bash script works in EN. It didn't work with french dates even though my whole system is in french and it DOES work in terminal without the export command. Also, I had to "translate" HAEC and HNEC as date command doesn't understand this frenchified CEST and CET.

 

Any ideas on how I can bypass this problem ? Is it a bug ?

 

Thanks in advance !

 

Hubert

 

I wonder if this could be a consequence of decomposed unicode. Alfred uses NSTask which automatically normalises and decomposes:

 

http://en.wikipedia.org/wiki/Unicode_equivalence#Normalization

 

Could this be the issue?

Link to comment

Andrew,

 

Thanks, but striping/replacing the accents will not work. The date command will then end in error.

 

I can use Alfred2 as is (that means in EN) and use SED to "translate" any month from FR to EN.

 

I'll see and post if I find a solution.

 

Take care.

 

Hubert

 

Thanks! Hopefully somebody can chime in to help too :)

Link to comment

I am having a similar issue with german umlauts.

 

I was able so solve the issue with the normalise command line tool posted by Andrew in another topic.

 

You could add Andrews tool to your workflow and try to do the following:

 

QUERY=$(./normalise "{query}")

DATE=$(echo "${QUERY}" | sed -e's/HAEC/CEST/g' -e's/HNEC/CET/g'); export LC_TIME="fr_FR.UTF-8"; date -jf "%d %B %Y %T %Z" "$DATE" "+%Y%m%d%H%M%S"
Link to comment
  • 1 year later...

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...