rice.shawn Posted February 19, 2016 Author Share Posted February 19, 2016 I can't understand what's going on. I used this workflow some time ago with the paid API and decided to stop until the multiple langue support was released. Now the workflow no longer works. Try adding a new API key to the Google project and then plugging that one in. Link to comment
xilopaint Posted February 19, 2016 Share Posted February 19, 2016 (edited) Try adding a new API key to the Google project and then plugging that one in. Still not working. By the way, why the first result has no flag or language? Look: P.S.: Notice, as I already pointed out in this thread, that the code for Brazilian Portuguese is wrong (pt-BZ instead pt-BR). Edited February 19, 2016 by xilopaint Link to comment
rice.shawn Posted February 19, 2016 Author Share Posted February 19, 2016 Still not working. By the way, why the first result has no flag or language? Look: P.S.: Notice, as I already pointed in this thread, that the code for Brazilian Portuguese is wrong (pt-BZ instead pt-BR). Try deleting the config file. It should be somewhere like ~/Library/Application Support/Alfred 2/Workflow Data/com.spr.translate.api/config.ini. Then re-enter the api key and try again. More than likely there is a null value for the first item. I'll change the code for BR soon. Link to comment
xilopaint Posted February 19, 2016 Share Posted February 19, 2016 Try deleting the config file. It should be somewhere like ~/Library/Application Support/Alfred 2/Workflow Data/com.spr.translate.api/config.ini. Then re-enter the api key and try again. More than likely there is a null value for the first item. I'll change the code for BR soon. Nothing has changed and the null value persists. Link to comment
rice.shawn Posted February 19, 2016 Author Share Posted February 19, 2016 Can you copy/paste the INI file here? Replace the API key value with xxxxxxxxxxxxxxx Link to comment
xilopaint Posted February 19, 2016 Share Posted February 19, 2016 ;;;;; ; `config.ini` generated by Alphred v0.9.7 ; at 2016-Feb-19 16:48:32 ;;;;; api_key = "xxxxxxxxxxxxxxx" languages = ",pt-BR,en,es" Link to comment
mickaphd Posted February 22, 2016 Share Posted February 22, 2016 I have the same problem than xilopaint Link to comment
rice.shawn Posted February 22, 2016 Author Share Posted February 22, 2016 Another thought for possible failure. Google provides three months free (basically), but if you downloaded the previous version and created the project on Google then, you didn't need to add a credit card to your account. If you haven't added one by now to let it bill you, then it might be rejecting the queries based on that. Link to comment
xilopaint Posted February 22, 2016 Share Posted February 22, 2016 Unfortunately it's not my case. I added the credit card when created the project. Link to comment
admiraltso Posted April 5, 2016 Share Posted April 5, 2016 Is it possible to add Pinyin to the results? The functionality doesn't seem to be published on Google's API documentation, however the Google API seems to support it (at least the previous version before they locked down the API) as seen in this package: https://pypi.python.org/pypi/goslate#romanlization I looked through the source for the but couldn't even find where this package made an API call... Link to comment
rice.shawn Posted April 7, 2016 Author Share Posted April 7, 2016 Is it possible to add Pinyin to the results? The functionality doesn't seem to be published on Google's API documentation, however the Google API seems to support it (at least the previous version before they locked down the API) as seen in this package: https://pypi.python.org/pypi/goslate#romanlization I looked through the source for the but couldn't even find where this package made an API call... It'll probably take me a while to get to this. If it were in the documentation, then it would be much easier to do, but otherwise I have to find the time to reverse engineer the API calls (which might change if they're not official). Link to comment
deanishe Posted April 7, 2016 Share Posted April 7, 2016 Is it possible to add Pinyin to the results? The functionality doesn't seem to be published on Google's API documentation, however the Google API seems to support it (at least the previous version before they locked down the API) as seen in this package: https://pypi.python.org/pypi/goslate#romanlization I looked through the source for the but couldn't even find where this package made an API call... It adds &dt=rm to the URL. Link to comment
cands Posted July 9, 2016 Share Posted July 9, 2016 ;;;;; ; `config.ini` generated by Alphred v0.9.7 ; at 2016-Feb-19 16:48:32 ;;;;; api_key = "xxxxxxxxxxxxxxx" languages = ",pt-BR,en,es" I think the null value is due to the first comma in ",pt-BR,en,es". Try to remove it, i.e. replace with "pt-BR,en,es". Link to comment
xilopaint Posted July 11, 2016 Share Posted July 11, 2016 I think the null value is due to the first comma in ",pt-BR,en,es". Try to remove it, i.e. replace with "pt-BR,en,es". Yes, I had noticed that after the discussion. Thank you! Link to comment
yuyuyu Posted February 8, 2019 Share Posted February 8, 2019 help me Starting debug for 'Translate' [2019-02-08 22:37:55][STDERR: input.scriptfilter] [22:37:54][filter.php:103][ERROR] Request completely failed, and no cached data exists. cURL debug information follows: [22:37:54][filter.php:103][ERROR] cURL error number: 22 [22:37:54][filter.php:103][ERROR] cURL error message: `The requested URL returned error: 503 Service Unavailable`. [22:37:55][filter.php:103][ERROR] Request completely failed, and no cached data exists. cURL debug information follows: [22:37:55][filter.php:103][ERROR] cURL error number: 22 [22:37:55][filter.php:103][ERROR] cURL error message: `The requested URL returned error: 503 Service Unavailable`. [2019-02-08 22:37:55][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON: Warning: Invalid argument supplied for foreach() in /Users/moritayu/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.000099A5-D31E-4F18-8757-38D71113EBF3/functions.php on line 22 Warning: Invalid argument supplied for foreach() in /Users/moritayu/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.000099A5-D31E-4F18-8757-38D71113EBF3/functions.php on line 22 <?xml version="1.0" encoding="UTF-8"?> <items> <item arg="{"action":"translate","translation":"","original":"word","code":"ja","listen":""}" valid="yes"> <title></title> <subtitle>Japanese: word</subtitle> <icon>icons/ja.png</icon> <subtitle mod="cmd">Open in Web Browser</subtitle> <subtitle mod="alt">Listen to Translation</subtitle> </item> <item arg="{"action":"translate","translation":"","original":"word","code":"en","listen":""}" valid="yes"> <title></title> <subtitle>English: word</subtitle> <icon>icons/en.png</icon> <subtitle mod="cmd">Open in Web Browser</subtitle> <subtitle mod="alt">Listen to Translation</subtitle> </item> </items> Link to comment
DrUhlen Posted September 4, 2019 Share Posted September 4, 2019 On 2/8/2019 at 2:39 PM, yuyuyu said: help me Starting debug for 'Translate' [2019-02-08 22:37:55][STDERR: input.scriptfilter] [22:37:54][filter.php:103][ERROR] Request completely failed, and no cached data exists. cURL debug information follows: [22:37:54][filter.php:103][ERROR] cURL error number: 22 [22:37:54][filter.php:103][ERROR] cURL error message: `The requested URL returned error: 503 Service Unavailable`. [22:37:55][filter.php:103][ERROR] Request completely failed, and no cached data exists. cURL debug information follows: [22:37:55][filter.php:103][ERROR] cURL error number: 22 [22:37:55][filter.php:103][ERROR] cURL error message: `The requested URL returned error: 503 Service Unavailable`. [2019-02-08 22:37:55][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON: Warning: Invalid argument supplied for foreach() in /Users/moritayu/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.000099A5-D31E-4F18-8757-38D71113EBF3/functions.php on line 22 Warning: Invalid argument supplied for foreach() in /Users/moritayu/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.000099A5-D31E-4F18-8757-38D71113EBF3/functions.php on line 22 <?xml version="1.0" encoding="UTF-8"?> <items> <item arg="{"action":"translate","translation":"","original":"word","code":"ja","listen":""}" valid="yes"> <title></title> <subtitle>Japanese: word</subtitle> <icon>icons/ja.png</icon> <subtitle mod="cmd">Open in Web Browser</subtitle> <subtitle mod="alt">Listen to Translation</subtitle> </item> <item arg="{"action":"translate","translation":"","original":"word","code":"en","listen":""}" valid="yes"> <title></title> <subtitle>English: word</subtitle> <icon>icons/en.png</icon> <subtitle mod="cmd">Open in Web Browser</subtitle> <subtitle mod="alt">Listen to Translation</subtitle> </item> </items> Exactly the same for me. Thanks for an excellent Alfred workflow Link to comment
milopus Posted October 31, 2021 Share Posted October 31, 2021 (edited) I've been using this workflow using a Google API for years now with no problems. It's like magic to everyone around me trying to figure out how I do this. With the recent Monterey MacOS upgrade, this workflow does not work. Normally, I trigger Alfred, then start to type my trigger "tl", and I could just start to the the text I want translated. However, I see the logo for the workflow for a moment before it goes into Alfred's search mode. I don't think I did anything to the workflow before the Monterey update. Not sure what's going on. Here is the bug report: Edited October 31, 2021 by milopus Link to comment
vitor Posted October 31, 2021 Share Posted October 31, 2021 13 hours ago, milopus said: Not sure what's going on. The cause is the removal of PHP in Monterey. I don’t have an API key to test (and I’m still on Big Sur) but this should work to fix it:Install Homebrew.Install PHP (brew install php).Add to the top of the Script Filter and both Run Scripts:export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}" Link to comment
milopus Posted November 1, 2021 Share Posted November 1, 2021 3 hours ago, vitor said: The cause is the removal of PHP in Monterey. I don’t have an API key to test (and I’m still on Big Sur) but this should work to fix it: Install Homebrew. Install PHP (brew install php). Add to the top of the Script Filter and both Run Scripts: export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}" Thanks, I installed Homebrew and PHP as well as adding that text at the top of the Script filter. However, it still does not work, but I see this in the debugger. Thanks in advance. Quote [9:08:19.035 AM] Translate API[Script Filter] Queuing argument '' [9:08:19.104 AM] Translate API[Script Filter] Script with argv '(null)' finished [9:08:19.106 AM] STDERR: Translate API[Script Filter] PHP Warning: Undefined array key "" in /Users/myHDD/~~~~~~~~~/Alfred.alfredpreferences/workflows/user.workflow.0D0939D0-C140-4F96-8094-0F56E470FD56/filter.php on line 37 [9:08:19.107 AM] Translate API[Script Filter] Warning: Undefined array key "" in /Users/myHDD/~~~~~~~~~/Alfred.alfredpreferences/workflows/user.workflow.0D0939D0-C140-4F96-8094-0F56E470FD56/filter.php on line 37 <?xml version="1.0" encoding="UTF-8"?> <items> <item valid="no"> <title>Type to translate...</title> </item> <item autocomplete="› set language ›" valid="no"> <title>Set Translation Languages</title> <subtitle>Currently translating to ``</subtitle> </item> <item arg="{"action":"set-api-key"}" valid="yes"> <title>Set Google Translate API Key</title> <subtitle>API Key is currently set to "MyGoogleAPI_is_confirmed_and_here"</subtitle> </item> </items> [9:08:19.109 AM] ERROR: Translate API[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0. in JSON: Warning: Undefined array key "" in /Users/myHDD/~~~~~~~~~/Alfred.alfredpreferences/workflows/user.workflow.0D0939D0-C140-4F96-8094-0F56E470FD56/filter.php on line 37 <?xml version="1.0" encoding="UTF-8"?> <items> <item valid="no"> <title>Type to translate...</title> </item> <item autocomplete="› set language ›" valid="no"> <title>Set Translation Languages</title> <subtitle>Currently translating to ``</subtitle> </item> <item arg="{"action":"set-api-key"}" valid="yes"> <title>Set Google Translate API Key</title> <subtitle>API Key is currently set to "MyGoogleAPI_is_confirmed_and_here"</subtitle> </item> </items> Link to comment
cands Posted January 16, 2022 Share Posted January 16, 2022 (edited) On 11/1/2021 at 3:15 AM, milopus said: hanks, I installed Homebrew and PHP as well as adding that text at the top of the Script filter. However, it still does not work, but I see this in the debugger. Thanks in advance. This workflow has been so useful, it's a pity it does not work on Monterey, hopefully it can be fixed. I also installed php using homebrew in Monterey, seems to be running php correctly but seems there is code in the workflow being deprecated in newer versions of php. I paste the debugger information below when translating the string "Alfred is great". I'm on macOS 12.1 using Alfred version 4.6.1 and php 8.1.1. Errors about auto_detect_line_endings and JSON. Unfortunately I do not know anything about php so do not understand how to fix. As you can see from the debug info below the string is actually translated, so possibly just a few changes are needed to make the workflow working again. Anyone with needed skills that can assist? [10:46:58.566] STDERR: Translate API[Script Filter] PHP Deprecated: auto_detect_line_endings is deprecated in phar:///Users/***/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.80D64116-6465-4CFF-B003-3F558C5495AB/Alphred.phar/Main.php on line 29 [10:46:58.567] ERROR: Translate API[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0. in JSON: Deprecated: auto_detect_line_endings is deprecated in phar:///Users/***/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.80D64116-6465-4CFF-B003-3F558C5495AB/Alphred.phar/Main.php on line 29 <?xml version="1.0" encoding="UTF-8"?> <items> <item valid="no"> <title>Type to translate...</title> </item> <item autocomplete="› set language ›" valid="no"> <title>Set Translation Languages</title> <subtitle>Currently translating to `English, Swedish`</subtitle> </item> <item arg="{"action":"set-api-key"}" valid="yes"> <title>Set Google Translate API Key</title> <subtitle>API Key is currently set to "*****"</subtitle> </item> </items> [10:47:01.331] STDERR: Translate API[Script Filter] PHP Deprecated: auto_detect_line_endings is deprecated in phar:///Users/***/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.80D64116-6465-4CFF-B003-3F558C5495AB/Alphred.phar/Main.php on line 29 [10:47:01.332] ERROR: Translate API[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0. in JSON: Deprecated: auto_detect_line_endings is deprecated in phar:///Users/***/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.80D64116-6465-4CFF-B003-3F558C5495AB/Alphred.phar/Main.php on line 29 <?xml version="1.0" encoding="UTF-8"?> <items> <item arg="{"action":"translate","translation":"Alfred is great","original":"Alfred is great","code":"en"}" valid="yes"> <title>Alfred is great</title> <subtitle>English: Alfred is great</subtitle> <icon>icons/en.png</icon> <subtitle mod="cmd">Open in Web Browser</subtitle> </item> <item arg="{"action":"translate","translation":"Alfred \u00e4r j\u00e4ttebra","original":"Alfred is great","code":"sv"}" valid="yes"> <title>Alfred är jättebra</title> <subtitle>Swedish: Alfred is great</subtitle> <icon>icons/sv.png</icon> <subtitle mod="cmd">Open in Web Browser</subtitle> </item> </items> Edited January 16, 2022 by cands Link to comment
deanishe Posted January 16, 2022 Share Posted January 16, 2022 (edited) 23 minutes ago, cands said: Anyone with needed skills that can assist? Turn off deprecation warnings? Edited January 16, 2022 by deanishe cands 1 Link to comment
cands Posted January 23, 2022 Share Posted January 23, 2022 On 1/16/2022 at 11:23 AM, deanishe said: Turn off deprecation warnings? Thanks for the tip, that might work, but seems the file to edit is in a special php .phar package named "Alphred.phar". Could not find a simple way to edit, had very little time to look into this now though and I have no experience with php. Maybe the fix is simple with just a little bit experience, if I get more time later I will take a closer look. Link to comment
vitor Posted January 23, 2022 Share Posted January 23, 2022 Installing an older version of PHP might do it for you: brew install php@7.4 brew link php@7.4 cands 1 Link to comment
cands Posted January 23, 2022 Share Posted January 23, 2022 5 hours ago, vitor said: Installing an older version of PHP might do it for you: brew install php@7.4 brew link php@7.4 Yes, that did it! Thanks a lot for your tips! 😃 Link to comment
Brekker Posted April 27, 2022 Share Posted April 27, 2022 (edited) Hi! I just managed to add the API by adding Quote PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}" to the script. It still does not work and nothing happens. Same thing happens if I use /opt/homebrew/opt/php@7.4/bin/php filter.php "{query}" The problem seems to revolve around line 37 in filter.php but I don't know what's wrong. I am using a Macbook Pro 16" with Apples M1 Pro chip. Any recommendations on how I can solve this? Thanks a lot in advance. Quote [01:07:42.640] Translate API[Script Filter] Queuing argument '' [01:07:42.787] Translate API[Script Filter] Script with argv '(null)' finished [01:07:42.789] STDERR: Translate API[Script Filter] PHP Notice: Undefined index: in /Users/doogie/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.91003814-D445-4A42-8425-0CBD61A92904/filter.php on line 37 [01:07:42.790] Translate API[Script Filter] Notice: Undefined index: in /Users/doogie/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.91003814-D445-4A42-8425-0CBD61A92904/filter.php on line 37 <?xml version="1.0" encoding="UTF-8"?> <items> <item valid="no"> <title>Type to translate...</title> </item> <item autocomplete="› set language ›" valid="no"> <title>Set Translation Languages</title> <subtitle>Currently translating to ``</subtitle> </item> <item arg="{"action":"set-api-key"}" valid="yes"> <title>Set Google Translate API Key</title> <subtitle>API Key is currently set to "XXX"</subtitle> </item> </items> [01:07:42.791] ERROR: Translate API[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0. in JSON: Notice: Undefined index: in /Users/doogie/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.91003814-D445-4A42-8425-0CBD61A92904/filter.php on line 37 <?xml version="1.0" encoding="UTF-8"?> <items> <item valid="no"> <title>Type to translate...</title> </item> <item autocomplete="› set language ›" valid="no"> <title>Set Translation Languages</title> <subtitle>Currently translating to ``</subtitle> </item> <item arg="{"action":"set-api-key"}" valid="yes"> <title>Set Google Translate API Key</title> <subtitle>API Key is currently set to "XXX"</subtitle> </item> </items> Edited April 28, 2022 by Brekker 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