Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Speech Recognition failed
-
@Python567 you have to foresee a way to leave (break) this infinite loop.
-
@cvp two questions:
- If I open a shortcut on ios with the shortcuts module the app shortcut is open, can I close it from the skript or can I bring Pythonista to the front?
- How can I change the language for this code:
t = f"{datetime.datetime.now():%A}"
-
@Python567 said:
If I open a shortcut on ios with the shortcuts module the app shortcut is open, can I close it from the skript or can I bring Pythonista to the front?
It depends: how do you open the shortcuts module?
Anyway, you can't never close an app from another app -
@cvp I open it with
shortcuts.open_shortcuts_app(name='', shortcut_input='')
And how can I change the language on the code which I posted before?
-
@Python567 said:
How can I change the language for this code:
Normally, Python allows the locale.setlocale function to do that, but it has never worked in the past.
I know I did it viaObjectiveC but I don't find my script, let me some time, not free this morning.Of course, if somebody knows a way, don't hesitate to help.
-
@Python567 said:
If I open a shortcut on ios with the shortcuts module the app shortcut is open, can I close it from the skript or can I bring Pythonista to the front?
I think you can ask shortcut to go back to Pythonista...
-
@cvp Yes that‘s a good idea. I found following in the documentation, but I don‘t know how the set it in german
Weekday as locale’s abbreviated name.
Sun, Mon, ..., Sat (en_US);
So, Mo, ..., Sa (de_DE)
(1)
%A Weekday as locale’s full name.
Sunday, Monday, ..., Saturday (en_US);
Sonntag, Montag, ..., Samstag (de_DE) -
@Python567 the doc = Python doc but locale did never function in Pythonista
-
@cvp it‘s the pythonista doc
-
@Python567 yes but this Pythonista doc, for Python keywords, points to standard doc. And this locale function has never worked.
-
About the shortcut, do you want to open Shortuts app, execute a shortcut and come back in your script or only open Pythonista
-
@cvp I want to execute a shortcut and come back to my skript
-
Even if I drunk too much 🍷
# https://forum.omz-software.com/topic/4480/handling-locale-date-string-conversion import datetime from objc_util import * NSDateFormatter = ObjCClass('NSDateFormatter') dateFormatter = NSDateFormatter.alloc().init() NSLocale = ObjCClass('NSLocale') deLocale = NSLocale.alloc().initWithLocaleIdentifier_(ns('de')) dateFormatter.setLocale_(deLocale) NSDate = ObjCClass('NSDate') date = NSDate.alloc().init() now = f"{datetime.datetime.now():%d/%m/%Y}" # see https://coderwall.com/p/jj6k_a/quick-guide-to-objective-c-dateformatting dateFormatter.setDateFormat_('dd/MM/yyyy') date = dateFormatter.dateFromString_(now) dateFormatter.setDateFormat_('EEEE') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German)
If you want an abbreviated name, use
dateFormatter.setDateFormat_('EE')
-
@Python567 said:
I want to execute a shortcut and come back to my skript
Please, read carefully this topic and try with short script and shortcut.
I didn't retry....
-
You can also use, for month name
dateFormatter.setDateFormat_('MMM') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German) dateFormatter.setDateFormat_('MMMM') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German)
-
Or
dateFormatter.setDateFormat_('EEEE dd MMMM yyyy') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German) # ==> Sonntag 14 Februar 2021
-
@cvp ok, but what have I to import for that?
-
@Python567 some posts above,(4 hours ago), you have a full script with the imports....
-
@cvp that?:
import datetime from objc_util import *
-
@Python567 yes, plus these lines once at begin of script
NSDateFormatter = ObjCClass('NSDateFormatter') dateFormatter = NSDateFormatter.alloc().init() NSLocale = ObjCClass('NSLocale') deLocale = NSLocale.alloc().initWithLocaleIdentifier_(ns('de')) dateFormatter.setLocale_(deLocale) NSDate = ObjCClass('NSDate') date = NSDate.alloc().init()