[英]Webpage-text translation on client-side (without internet connectivity)
I need a web-application to be translated from English to Portuguese. 我需要将Web应用程序从英语翻译为葡萄牙语的应用程序。 Since the servers on which this application runs have no internet access, is there a way to achieve this without using a 3rd Party API.
由于运行此应用程序的服务器无法访问互联网,因此有一种无需使用第三方API即可实现此目的的方法。 Is there a JS Library that can translate from say Language A to Language B on the client side ?
是否有一个JS库可以在客户端将语言A转换为语言B?
You can definitely use Java Script for that. 您绝对可以为此使用Java脚本。
The library well known for translations is the i18next 众所周知的翻译库是i18next
You can integrate with jQuery, but I strongly recommend you using something like AngularJS or Mustache for customise your template. 您可以与jQuery集成,但是我强烈建议您使用AngularJS或Mustache之类的工具自定义模板。
If you choose use AngularJS you can have a different JSON file with your expressions, and depending on the language you are navigating, loads a different JSON file, like: 如果选择使用AngularJS ,则表达式中可以包含其他JSON文件,并且根据要浏览的语言,将加载其他JSON文件,例如:
en.json, es.json, pt.json en.json,es.json,pt.json
You can use JS Cookies for saving the language as same you would do with any backend language. 您可以使用JS Cookies来保存语言,就像使用任何后端语言一样。
Mustache is used to create templates front-side with double brackets {{custom_text}}. 小胡子用于在正面创建带有双括号{{custom_text}}的模板。 AngularJS uses the same idea.
AngularJS使用相同的想法。
The only issue if you want to use AJAX. 如果要使用AJAX,这是唯一的问题。 Read more about Google Chrome --allow-file-access-from-files disabled for Chrome Beta 8
阅读有关Google Chrome的更多信息-Chrome Beta 8禁止从文件访问文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.