แอป Dictionary มีประสบการณ์ที่ยอดเยี่ยมบน MacOSX แต่ฉันต้องติดตั้งพจนานุกรมเพื่อใช้ เป็นไปได้หรือไม่ที่จะผูกไว้กับ Google Translate
ขอบคุณ!
แอป Dictionary มีประสบการณ์ที่ยอดเยี่ยมบน MacOSX แต่ฉันต้องติดตั้งพจนานุกรมเพื่อใช้ เป็นไปได้หรือไม่ที่จะผูกไว้กับ Google Translate
ขอบคุณ!
คำตอบ:
น่าเสียดายที่มันดูเหมือนจะเป็นไปไม่ได้หรืออย่างน้อยก็ตรงไปตรงมา เป็นทางเลือกที่คุณอาจต้องการที่จะต้องพิจารณาการสร้าง X OS บริการที่เปิด Google Translate ในหน้าต่างเบราว์เซอร์สำหรับคำว่าไฮไลต์ใด ๆ หรือวลีที่คุณได้เลือก
หากฟังดูเหมาะสมให้ทำตามขั้นตอนด้านล่าง:
AutomatorแอพจากApplicationsโฟลเดอร์ของคุณServiceเป็นประเภทเอกสารและคลิกChooseRun AppleScriptกระทำจากรายการทางด้านซ้ายในพื้นที่ที่มีข้อความ 'ลากการกระทำหรือไฟล์ที่นี่เพื่อสร้างเวิร์กโฟลว์ของคุณ'คัดลอกสคริปต์ด้านล่างและวางลงในRun Applescriptการดำเนินการ:
on run {input, parameters}
set phrase to input as string
set phrase to quoted form of phrase
set ui_lang to "en"
set from_lang to "en"
set to_lang to "zh-CN"
do shell script "open 'https://translate.google.com/?hl='" & ui_lang & "'&sl='" & from_lang & "'&tl='" & to_lang & "'&text='" & phrase
end run
หน้าต่างของคุณควรมีลักษณะดังนี้:
มีสามค่าที่คุณอาจต้องการเปลี่ยนในสคริปต์ด้านบน:
ui_lang - ภาษาที่ใช้สำหรับส่วนติดต่อของหน้าfrom_lang - ภาษาต้นฉบับto_lang - ภาษาปลายทางเปลี่ยนหนึ่งหรือมากกว่านี้เพื่อให้ได้การแปลที่ต้องการ เพื่อหาค่าพารามิเตอร์ภาษาที่ถูกต้องดูที่อ้างอิงภาษา ในตัวอย่างข้างต้นenอ้างถึงEnglishและzh-CNเป็นภาษาจีน (แบบง่าย)
หลังจากทำการเปลี่ยนแปลงแล้วให้คลิกFile> Save...และในแผงควบคุมที่ปรากฏขึ้นให้พิมพ์ชื่อที่เหมาะสม (เช่นTranslate English to Chinese)
หลังจากบันทึกเวิร์กโฟลว์ของคุณด้านบนคุณสามารถใช้บริการแปลของคุณด้วยหนึ่งในสองวิธีต่อไปนี้:
1. วิธีการเมนูบริการ
ServicesและTranslate English to Chinese(หรือชื่อที่คุณให้บริการเมื่อบันทึก):2. วิธีเมนูตามบริบท
Servicesจากนั้นTranslate English to Chinese(หรือชื่อบริการที่กำหนดเองของคุณ):วิธีใดก็ตามที่คุณใช้หน้าต่างเบราว์เซอร์ควรปรากฏพร้อมข้อความแปลของคุณ:
from_lang "auto"
อันนี้ทำทุกอย่างเหมือนคำตอบของ Soulcakeแต่ถ้า url ของผู้แปลมีอยู่แล้ว - โหลดการแปลใหม่ในแท็บเดียวกัน
on run {input, parameters}
set phrase to input as string
set ui_lang to "en"
set from_lang to "en"
set to_lang to "ru"
set theBaseUrl to "https://translate.google.com/"
set theUrl to theBaseUrl & "?hl=" & ui_lang & "&sl=" & from_lang & "&tl=" & to_lang & "&text=" & phrase
tell application "Google Chrome"
activate
if (count every window) = 0 then
make new window
end if
set found to false
set theTabIndex to -1
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if theTab's URL starts with theBaseUrl then
set found to true
exit repeat
end if
end repeat
if found then
exit repeat
end if
end repeat
if found then
set URL of theTab to theUrl
set theWindow's active tab index to theTabIndex
set index of theWindow to 1
else
tell window 1 to make new tab with properties {URL:theUrl}
end if
end tell
end run