如何将我的网页翻译成其他语言? [英] How to translate into other languages my web page?

查看:150
本文介绍了如何将我的网页翻译成其他语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何翻译我的网页?实际上,应该使用什么技术或脚本(如果需要)?有关信息;我都翻译了文字.但是我不想为其他语言创建类似克隆站点的内容. 我只使用javascript-包括jquery.

How can I translate my web pages? Actually what technology or what scripting-if require- should be used? For info; I have all translated text. But I do not want to create something like clone site for other language. I used just javascript -including jquery .

推荐答案

只需使用JavaScript ...

Just using JavaScript...

<script type="text/javascript">

// JSON-formatted, potentially read from a database
var article = {
    title: {
      en_US: "Article Title",
      fr_FR: "Titre de l\'Article"
    },
    content: {
      en_US: "Content of the Article.",
      fr_FR: "Contenu de l\'Article."
    }
}

// simple function to write the info to the page
function get_i18n(item, lang) {
    document.write(article[item][lang]);
}
</script>

<!-- English Version -->
<div class="story">
   <h1 class="title"><script>get_i18n('title','en_US');</script></h1>
   <p class="content"><script>get_i18n('content','en_US');</script></p>
</div>

<!-- French Version -->
<div class="story">
   <h1 class="title"><script>get_i18n('title','fr_FR');</script></h1>
   <p class="content"><script>get_i18n('content','fr_FR');</script></p>
</div>

请注意:这不是一个非常优雅的解决方案.我敢肯定有一种更漂亮的方法...

Please Note: This isn't a very graceful solution. I'm sure there's a prettier method...

这篇关于如何将我的网页翻译成其他语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆