ShareShortcuts

Google Translate

EN:Translate TR:Çeviri

furkan2427
Fork “Google Translate”

Built something new on top of this Shortcut? Share it as a fork: it becomes a Shortcut of your own, which you manage, and both pages link to each other so furkan2427 gets credit.

  1. 1Get the Shortcut and change it in the Shortcuts app. Give it a name of its own.
  2. 2Share it from the Shortcuts app and copy the iCloud link.
  3. 3Come back here, paste the link and describe what is different, e.g. “Added a step that uses Apple Intelligence to personalise the text.”
Downloads
33K
Saved
2
Actions
96
Category
API
Version
1.0
Language
EN

Preview

EN:Translate

TR:Çeviri

What's New

Version 1.0

First release

Version History
1.0 Apr 19, 2023

First release

What it does

96 actions
  1. Comment
    Made by u/brechtbakker Version 2.9.5 Made on iOS 14 Thanks to u/danboy4 for the list of countries used in this Shortcut
  2. Comment
    For use with other Shortcuts please check the examples on: https://routinehub.co/shortcut/254 You need a Dictionary as input to this Shortcut containing keys 'Text' and 'Language'. Text would be the text you'd want to translate and the language woul…
  3. If
  4. Get Dictionary from Input
  5. Get Dictionary Value
  6. Count
  7. If
  8. Number
  9. Set Variable
    External
  10. Set Variable
    Input Language
  11. Set Variable
    Use UpdateKit
  12. Get Variable
  13. If
  14. Get Variable
  15. If
  16. Text
  17. Choose from Menu
    …
  18. Choose from Menu
    Clipboard
  19. Get Clipboard
  20. Choose from Menu
    Enter text...
  21. Ask for Input
    Please enter text to translate
  22. Comment
    This is a list of favourites, please be sure to enter the favourites the same way they are found in the 'Languages' list below!
  23. Text
  24. Text
  25. Text
  26. Split Text
  27. Replace Text
  28. Set Variable
    Favourites
  29. Text
  30. Split Text
  31. Set Variable
    Languages
  32. Text
  33. Split Text
  34. Set Variable
    Short Names
  35. Text
  36. Base64 Encode
  37. Get Dictionary from Input
  38. Set Variable
    Language Dictionary
  39. Count
  40. If
  41. Get Variable
  42. If
  43. Choose from List
  44. If
  45. Choose from List
  46. Change Case
  47. Get Dictionary Value
  48. Replace Text
  49. Replace Text
  50. Dictionary
  51. Get Dictionary Value
  52. Repeat with Each
  53. Get Dictionary Value
  54. Count
  55. If
  56. Get Dictionary Value
  57. Repeat with Each
  58. Text
  59. If
  60. Text
  61. Combine Text
  62. URL
    https://translate.google.com/translate_a/single?…
  63. Get Contents of Web Page
  64. Text
  65. Base64 Encode
  66. URL
    data:text/html;base64,…
  67. Get Contents of Web Page
  68. URL Encode
  69. Set Variable
    Translation
  70. Get Variable
  71. If
  72. If
  73. Text
  74. Choose from Menu
    …
  75. Choose from Menu
    Share...
  76. Share
  77. Choose from Menu
    Copy to Clipboard
  78. Copy to Clipboard
  79. Choose from Menu
    Check for update
  80. Number
  81. Set Variable
    Use UpdateKit
  82. If
  83. Dictionary
  84. URL
    data:text/html,<script> let xhr = new XMLHttpRequest() xhr.open('GET', '…/versions/latest', false) xhr.send() document.write(xhr.responseText) </script>
  85. Get Contents of Web Page
  86. If
  87. Get Text from Input
  88. Get Dictionary Value
  89. If
  90. Text
  91. Choose from Menu
    …
  92. Choose from Menu
    Download Update
  93. URL
  94. Open URLs
  95. Choose from Menu
    Not now
  96. Text

View as code
Beta

Every action of this Shortcut written out as Cherri, a programming language for Shortcuts. Great for learning how it works.

#include 'actions/web'
#include 'actions/text'
#include 'actions/sharing'
#define color violet
#define glyph globe

/*
Made by u/brechtbakker
Version 2.9.5
Made on iOS 14

Thanks to u/danboy4 for the list of countries used in this Shortcut
*/
/*
For use with other Shortcuts please check the examples on:

https://routinehub.co/shortcut/254

You need a Dictionary as input to this Shortcut containing keys 'Text' and 'Language'. Text would be the text you'd want to translate and the language would be the language to translate to
*/

if ShortcutInput {
	const Settings = getDictionary(ShortcutInput)
	const Text = getValue(Settings, "Text")
	const Count = count(Text, "Characters")
	if Count > 0 {
		@External = 1
		@InputLanguage = Settings['Language']
		@UseUpdateKit = Settings['UpdateKit']
		// TODO: Get Variable not supported: Assign variable here to 'Settings['Text']'.
	} else {
		// TODO: Get Variable not supported: Assign variable here to 'ShortcutInput'.
	}
} else {
	const Text1 = "What would you like to Translate?"
	menu Text1 {
	item "Clipboard":
		getClipboard()
	item "Enter text...":
		prompt("Please enter text to translate")
	}
}
// This is a list of favourites, please be sure to enter the favourites the same way they are found in the 'Languages' list below! 

const Favs = "English\nSpanish\nFrench"
const Other = "Other..."
const Text2 = "{Favs}\n{Other}"
splitText(Text2)
replaceText("(?m)^\s+|\s+$", "", false, true)
@Favourites
const Text3 = "Afrikaans\nAlbanian\nAmharic\nArabic\nArmenian\nAzerbaijani\nBasque\nBelarusian\nBengali\nBosnian\nBulgarian\nCatalan\nCebuano\nChichewa\nChinese\nChinese (Traditional)\nCorsican\nCroatian\nCzech\nDanish\nDutch\nEnglish\nEsperanto\nEstonian\nFilipino\nFinnish\nFrench\nFrisian\nGalician\nGeorgian\nGerman\nGreek\nGujarati\nHaitian Creole\nHausa\nHawaiian\nHebrew\nHindi\nHmong\nHungarian\nIcelandic\nIgbo\nIndonesian\nIrish\nItalian\nJapanese\nJavanese\nKannada\nKazakh\nKhmer\nKorean\nKurdish (Kurmanji)\nKyrgyz\nLao\nLatin\nLatvian\nLithuanian\nLuxembourgish\nMacedonian\nMalagasy\nMalay\nMalayalam\nMaltese\nMaori\nMarathi\nMongolian\nMyanmar (Burmese)\nNepali\nNorwegian\nPashto\nPersian\nPolish\nPortuguese\nPunjabi\nRomanian\nRussian\nSamoan\nScots Gaelic\nSerbian\nSesotho\nShona\nSindhi\nSinhala\nSlovak\nSlovenian\nSomali\nSpanish\nSundanese\nSwahili\nSwedish\nTajik\nTamil\nTelugu\nThai\nTurkish\nUkrainian\nUrdu\nUzbek\nVietnamese\nWelsh\nXhosa\nYiddish\nYoruba\nZulu"
splitText(Text3)
@Languages
const Text4 = "af\nsq\nam\nar\nhy\naz\neu\nbe\nbn\nbs\nbg\nca\nceb\nny\nzh-CN\nzh-TW\nco\nhr\ncs\nda\nnl\nen\neo\net\ntl\nfi\nfr\nfy\ngl\nka\nde\nel\ngu\nht\nha\nhaw\niw\nhi\nhmn\nhu\nis\nig\nid\nga\nit\nja\njw\nkn\nkk\nkm\nko\nku\nky\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yIsIk1hbGFnYXN5IjoibWciLCJIYWl0aWFuIENyZW9sZSI6Imh0IiwiQmVsYXJ1c2lhbiI6ImJlIiwiTmVwYWxpIjoibmUiLCJNYWx0ZXNlIjoibXQiLCJKYXBhbmVzZSI6ImphIiwiU2NvdHMgR2FlbGljIjoiZ2QiLCJIbW9uZyI6ImhtbiIsIlRhamlrIjoidGciLCJLYW5uYWRhIjoia24iLCJUYW1pbCI6InRhIiwiWGhvc2EiOiJ4aCJ9"
const Base64Encoded = base64Encode(Text5)
getDictionary(Base64Encoded)
@LanguageDictionary
const Count1 = count(@InputLanguage, "Characters")

if Count1 > 0 {
	// TODO: Get Variable not supported: Assign variable here to '@InputLanguage'.
} else {
	const SelectedItem = chooseFromList(@Favourites, "Please select language to translate to")
	if SelectedItem contains Other {
		chooseFromList(@Languages, "Please select language to translate to")
	}
}
const Language1 = uppercase(Language)
const LanguageShortName = @LanguageDictionary[Language1]
replaceText("\", "\\", Input, false)
replaceText("[<&`\">]", "", false, true)
const Dictionary = {
	"client": "gtx",
	"dt": [
		"at",
		"bd",
		"ex",
		"ld",
		"md",
		"qca",
		"rw",
		"rm",
		"ss",
		"t"
	],
	"hl": "{LanguageShortName}",
	"ie": "UTF-8",
	"kc": 7,
	"oe": "UTF-8",
	"otf": 1,
	"q": "{}",
	"sl": "auto",
	"ssel": 0,
	"tk": "000000.000000",
	"tl": "{LanguageShortName}",
	"tsel": 0
}
const DictionaryValue = getValues(Dictionary)

for _ in DictionaryValue {
	const Values = getValue(Dictionary, @RepeatItem)
	const Count2 = count(Values, "Items")
	if Count2 > 1 {
		const DictionaryValue1 = getValue(Dictionary, @RepeatItem)
		for _ in DictionaryValue1 {
		}
	} else {
	}
}
joinText(RepeatResults, "&")
url("https://translate.google.com/translate_a/single?{}")
getWebpageContents()
const Text6 = "<!doctype html><html><head><meta charset=\\"utf-8\\"></head><body><script>var t=`{}`.replaceAll(/[\t\n\r]+/gm,' ');var r=/\[(.*)\]/s;var s=r.exec(t)[0];s=s.replace('‎',' ');var b=JSON.parse(s);var re=\\"\\";b[0].forEach(function(obj){if(obj[0]){re+=obj[0];}});document.write(re);</script></body></html>"
base64Encode(Text6)
url("data:text/html;base64,{}")
getWebpageContents()
urlEncode()
@Translation
// TODO: Get Variable not supported: Assign variable here to '@External'.

if @External == 0 {
} else {
	const Text7 = "Translation results\n—————————\n{@Translation}"
	menu Text7 {
	item "Share...":
		share(@Translation)
	item "Copy to Clipboard":
		setClipboard(@Translation, "")
	item "Check for update":
	}
	@UseUpdateKit = 1
}

if @UseUpdateKit == "1" {
	const Dictionary1 = {
		"Current Version": "2.9.5",
		"RoutineHub ID": 254,
		"Shortcut Name": "Google Translate",
		"URL": "https://routinehub.co/api/v1/shortcuts/254"
	}
	url("data:text/html,<script>\nlet xhr = new XMLHttpRequest()\nxhr.open('GET', '{Dictionary1['URL']}/versions/latest', false)\nxhr.send()\ndocument.write(xhr.responseText)\n</script>")
	const ContentsOfWebPage = getWebpageContents()
	if ContentsOfWebPage {
		const Text8 = getText(ContentsOfWebPage)
		const DictionaryValue2 = getValue(Text8, "Version")
		if DictionaryValue2 > Dictionary1['Current Version'] {
			menu  {
			item "Download Update":
				const URL = url(Text8['URL'])
				openURL(URL)
			item "Not now":
			}
		}
	}
}
Decompiled with cherri 2.3.0 (GPL-2.0). May need small fixes before it compiles.

Ratings & Reviews

Write a Review
–
out of 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Advertisement

More by furkan2427

See All

You Might Also Like

See All
Advertisement