hubertcampan Posted April 10, 2013 Share Posted April 10, 2013 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
Andrew Posted April 16, 2013 Share Posted April 16, 2013 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
hubertcampan Posted April 16, 2013 Author Share Posted April 16, 2013 Andrew, thanks for your reply. It could be what you say, I really have no idea. How do I bypass this problem is my question. Cheers. Hubert Link to comment
Andrew Posted April 16, 2013 Share Posted April 16, 2013 Andrew, thanks for your reply. It could be what you say, I really have no idea. How do I bypass this problem is my question. Cheers. Hubert I'm not sure as I would have assumed that sed would be happy with decomposed unicode. You could maybe strip the accented characters first using iconv? http://stackoverflow.com/questions/9889428/unaccent-string-in-bash-script-rhel Link to comment
hubertcampan Posted April 16, 2013 Author Share Posted April 16, 2013 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 Link to comment
Andrew Posted April 16, 2013 Share Posted April 16, 2013 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
_mk_ Posted April 20, 2013 Share Posted April 20, 2013 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" hubertcampan 1 Link to comment
hubertcampan Posted April 21, 2013 Author Share Posted April 21, 2013 @_mk_ Thank you for pointing me in the right direction. It does work indeed. Danke schön @Andrew Problem solved. Thanks to your command line tool. Hubert Link to comment
mklement0 Posted April 25, 2014 Share Posted April 25, 2014 @Andrew: Just an FYI (given that your `normalise` CLI solved the problem): using `iconv -t ASCII/TRANSLIT` to replace accented characters with their base form, as described in the stackoverflow.com answer you linked to, does NOT work properly on OS X as of 10.9.2. For instance echo 'aüé' | iconv -f UTF8 -t ASCII//TRANSLIT yields 'a"u'e' rather than 'aue'. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now