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.

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料