duanning9110 2017-12-01 23:33
浏览 97
已采纳

如何从谷歌应用程序脚本中的谷歌翻译语言代码中获取语言名称?

I have a script I'm using with the google translate api. I am translating like this:

LanguageApp.translate(content, 'en', 'es')

I now need to translate content to many more languages, and as languages are added or dropped I don't want to update much, so how can I get the name of a language from its language 'code'?

I'm expecting something like this

LanguageApp.getNameFromCode('es')

and it would return "spanish" in this case.

How can I achieve this?

If it's not possible, I can use JS to on my frontend, or PHP in my backend, but using GAS is the most preferable way for me.

  • 写回答

1条回答 默认 最新

  • dongsi3826 2017-12-06 14:15
    关注

    This should be the method you are looking for:

    List<Language> languages = translate.listSupportedLanguages(target);
    

    I shared the Java code, but you can have a look at the documentation and choose the one that fits your application better.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度