Request: Share text and alert pinyin

Hey all, just getting into shortcuts and I was trying to create one that allowed me to share chinese text, get the pinyin, and show it in an alert popup.

I started off with this site: https://hanzi-piny.in/# and made a shortcut where sharing chinese text would populate this url (e.g. https://hanzi-piny.in/#世界 output is niu yue with diacritics), and I tried to scrape the pinyin from the html output and pipe it into an alert. I found that it didn’t work as the site runs a script to generate the pinyin, so the pinyin wasn’t even present in the html at the time of scraping. Could any of you kind folks help me out, or provide some guidance?

Posted Apr 29, 2020, 9:01 PM UTC

10
Smith_sc•
1
Rogue_ToasterOP•

Amazing, this is just what I was looking for, thanks!! One quick follow up, this breaks when you input a character that has multiple pronunciations — try 你着好 (zhe has parentheses that breaks up the result in html). Any ideas on how to fix?

1
Smith_sc•
1
Rogue_ToasterOP•

This didn’t fix it for me unfortunately... entering 你着好 results in: “nǐ zhe<span style=color:#aaaaaa>(zháo,zhúo)</span> hǎo”

Entering just 着 also gives me ”zhe<span style=color:#aaaaaa>(zháo,zhúo)</span>”

Any idea what’s going on? I noticed that the “Contains” condition is highlighted in red, so maybe the new code is never executing. Appreciate your help very much!

1
Smith_sc•

strange to me it works by inserting 你 着 好 and also 着

https://i.imgur.com/JWF8MZh.png

i used this

https://www.icloud.com/shortcuts/ce325ad2976a49e99c69aa4bf11029bc

1
azoon•

https://www.icloud.com/shortcuts/eeb90afed5864b9d81b903334b73c7dd

hope this helps. Pinyin will be displayed above each Chinese character.

https://imgur.com/2bRVpsm

1
Rogue_ToasterOP•

Thank you! Checking it out

1