datysho Posted May 14, 2014 Posted May 14, 2014 (edited) Hello this is a simple but useful program, i named it :DatyshoSwitcher.With DS you can convert selected text to any language what you need (Russian, Ukrainian and English by default, but it really easy to update it). Your selected word or paragraph can easy switch between russian end english layout. You can convert all selected letters to UPPERCASE, lowercase or Title Case. With FN key, you can copy result to clipboard, without replacing selected text.With Control key, you can search result in google.With Option key, you can jump to google translater with current result. Default shortcut Option + Command + SpaceDefault keyword ds >>>Download link<<< Edited May 15, 2014 by datysho arsenty 1
politicus Posted May 15, 2014 Posted May 15, 2014 Nice idea. A workflow I would really love to use. Searching in Google Translate via Alfred is not as smooth as your workflow. Had some issues while trying to install alfred via pip clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) in the future error: command 'cc' failed with exit status 1 Mavericks user. arsenty 1
datysho Posted May 15, 2014 Author Posted May 15, 2014 (edited) Which python do you have?i use Python 2.7.6 (default, Apr 9 2014, 11:48:52) provide by brewand i makemv /usr/bin/python /usr/bin/python.oldsudo ln -s /usr/local/bin/python /usr/bin/python Update: all needed packages included in workflow directory Edited May 15, 2014 by datysho
deanishe Posted May 15, 2014 Posted May 15, 2014 (edited) Hi datysho, You shouldn't be messing with the default system Python. Well, you can mess with your own, but not other folks' (though changing the system Python is generally a bad idea). You should install the required libraries directly into the workflow with "pip --target=my/workflow/directory" before you distribute it. There are a few reasons: firstly, it's possible that your workflow/app/whatever requires a different version of a library to some other software. You can't install both versions, so one of them will end up broken. Secondly, your software may break on a system update and certainly won't sync between machines. If you install the libraries directly into your workflow, it will sync between machines and still work. Finally, if you ensure your system Python is pristine, you can be fairly certain that code you send to other Mac users will run without problems. It's very easy to forget that a library you're using is one you've installed and not a standard Python one. I keep my custom Pythons in /usr/local/bin (which is what brew does, and for a good reason) and never mess with the system one. Edited May 15, 2014 by deanishe
datysho Posted May 15, 2014 Author Posted May 15, 2014 (edited) deanishe, thanks for your comment, i updated my workflow, please try again. Edited May 16, 2014 by datysho
politicus Posted May 16, 2014 Posted May 16, 2014 Hi datysho. It is working now! How could I NOT have results in russian and ukranian?
Sebastian Daza Posted May 16, 2014 Posted May 16, 2014 Hi, Could you add a brief explanation about how to modify/update languages (e.g., add english <-> spanish), remove upper/lower case... Thanks!
deanishe Posted May 16, 2014 Posted May 16, 2014 To edit the languages, you need to edit the code in the Script Filter. To remove Russian, for example, comment out (add # to the beginning of the lines) the two lines starting with ru_translation = ... and the ru_translation, line in the print alfred.render([... block at the end. For Ukrainian, comment out the 3 uk_translation lines.Use the same procedure to deactivate the uppercase/lowercase/title case results (3 lines per item).To change the languages, either copy the 3 ru_translation lines and change them to, say, es_translation and change to_lang="ru" to to_lang="es" in the first of the three lines. That'll give you Spanish results.@datysho: The workflow is throwing errors for me now. My Mavericks system doesn't like the lxml library: ImportError: dlopen(lxml/etree.so, 2): no suitable image found. Did find: lxml/etree.so: mach-o, but wrong architecture Might I suggest using Python's built in xml.etree library? It doesn't have the cool builder interface, but it'll work on all versions of OS X/Python.
politicus Posted May 16, 2014 Posted May 16, 2014 +1 to deanishe Me too, I had some problem with lmxl when trying to install the workflow. So why not using xml.etree?
deanishe Posted May 16, 2014 Posted May 16, 2014 lxml has a much nicer interface for generating XML and it's ridiculously fast. Pretty much anyone who codes Python has it installed. I imagine datysho is just used to using it. I know I use it for everything I don't intend to distribute. But it is a complete and utter bitch to compile on OS X. Stuff of nightmares.
datysho Posted May 16, 2014 Author Posted May 16, 2014 (edited) Sebastian Daza, to remove any option you need delete some lines from print alfred.render([ switched, uppers, lowers, titles, ru_translation, en_translation, uk_translation ]) How it work? uppers = val.upper() #convert your text to upper uppers = alfred.Item(arg=uppers, title=uppers, subtitle="UPPER", icon='icon.png') #generete alfred item instance with your values print alfred.render([ #render list of instances ... uppers, ... ]) If you delete some from alfred.render area, you need delete it from announcement area for better performance.Some additional information with languages: ru_translation = Translator(from_lang="auto", to_lang="ru").translate('''{query}''') #translate from auto detect to russian, {query} - your input en_translation = Translator(from_lang="auto", to_lang="en").translate('''{query}''') # from auto detect to english uk_translation = Translator(from_lang="auto", to_lang="uk").translate('''{query}''') # from autodetect to ukrainian deanishe, if you want you can show me your screen in the skype: datysho, i need more info about this problem. I have mavericks 10.9.3my root python packages is >>>pip freeze<<< Pygments==1.6 gnureadline==6.2.5 httpie==0.8.0 ipython==2.0.0 requests==2.2.1 stevedore==0.14.1 virtualenv==1.11.4 virtualenv-clone==0.2.4 virtualenvwrapper==4.2 wsgiref==0.1.2 Edited May 16, 2014 by datysho
deanishe Posted May 17, 2014 Posted May 17, 2014 deanishe, if you want you can show me your screen in the skype Sorry, not going to do that. Might I suggest using one of the other workflow libraries that doesn't depend on lxml. It's a pretty excessive requirement just to generate a bit of XML. lxml is notorious for being horrible to get running on OS X, and while it's brilliant for XML/HTML parsing, it's really big and over-the-top for generating workflow feedback. Python's built-in XML libraries are more than good enough for that. Nikipore's workflow library works in a very similar way to the one you're using.
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