【问题标题】:Translating the content of a html paragraph翻译 html 段落的内容
【发布时间】:2018-06-25 00:16:08
【问题描述】:

我们网站的管理端有一个生成的段落(因此无法事先知道内容)。

内容可以是不同的语言。我想将此段落的翻译显示为不同的段落。最好使用谷歌翻译。

【问题讨论】:

  • 是否真的有必要在任何地方都包括这个:How do I ask a good question? 和那里:解释你是如何遇到你试图解决的问题的,以及任何阻碍你自己解决的困难. 可能,这就是原因。

标签: html translation google-translate


【解决方案1】:

你被否决了,因为我们不是在这里做所有的代码,你必须在发布你的问题之前尝试一些想法或在谷歌上找到解决方案......

这是一个使用谷歌翻译 api 翻译定义 div 的有效解决方案,在尝试之前您需要一个 API 密钥:

<script src="https://www.google.com/jsapi?key=YOUR_GOOGLE_KEY"></script>
<div id="languages"><p>
    <a href="?lang=en" rel="en">English</a> / <a href="?lang=es" rel="es">Spanish</a> / <a href="?lang=it" rel="it">Italian</a> /
    <a href="?lang=fr" rel="fr">French</a>
</p></div>

<div id="languageBlock">
    <p>Lights go out and I can't be saved <br />
    Tides that I tried to swim against  <br />
    Brought me down upon my knees  <br />
    Oh I beg, I beg and plead </p>

    <p>Singin', come out if things aren't said  <br />
    Shoot an apple off my head  <br />
    And a, trouble that can't be named  <br />
    Tigers waitin' to be tamed </p>

    <p>Singing, yooooooooooooo ohhhhhh  <br />
    Yoooooooooooo ohhhhhh </p>

    <p>Home, home, where I wanted to go <br /> 
    Home, home, where I wanted to go  <br />
    Home, home, where I wanted to go  <br />
    Home, home, where I wanted to go</p>
</div>

【讨论】:

  • 我怎样才能让它立即翻译成我的首选语言,而无需我点击链接?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-06
  • 2023-03-16
  • 2017-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多