translation.js

/**
* Global Config variables
*/
supportLanguage1 = "en-US";
supportLanguage1Alias = encodeURI("English Version");

supportLanguage2 ="zh-CN";
supportLanguage2Alias = encodeURI("中文版");

var cookie = new JSCookie();

/**
* Auto translates the entire page when document is ready .
*
* @Author overseas
*/
$(document).ready(function(){

//language_complete = navigator.language.split("-");
//language = (language_complete[0]);
//console.log("Sprache (root): %s", language);
//$(window).load(function(){

var currentLanguage = cookie.GetCookie("power7000Language");

if ( (!currentLanguage && typeof(currentLanguage)!="undefined" && currentLanguage!=0) || (currentLanguage=="") )
{
currentLanguage = supportLanguage1;//"en-US";
changeLanguage();
}

var resPath = getRootPath_web() + ‘/locales/__lng__/__ns__.json‘;

i18n.init({
lng: currentLanguage,
ns: { namespaces: [‘power7000.jsp‘], defaultNs:‘power7000.jsp‘},
resGetPath: resPath,
fallbackLng: false,
useLocalStorage:false
}, function() {
// save to use translation function as resources are fetched
$("*").i18n();

//alert(currentLanguage);
//alert(i18n.t("app.name")+":114");

//后置翻译方法 2015-01-21 lkg
//检测方法postTranslate是否存在
if(window.loadData)
{
window.loadData();
}

// In order to display HTML page after loading complete 2015-01-20 lkg
document.body.style.visibility="visible";

//调整窗体布局 2015-01-21 lkg
///检测方法adjustLayout是否存在
if(window.adjustLayout)
{
window.adjustLayout();
}

//div #hideAll: in order to display HTML page after loading complete
//document.getElementById("hideAll").style.display = "none";

});
});

/**
* Read cookie value by name .
*
* @Author overseas
*/
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(‘;‘);
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ‘ ‘) c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) {
return decodeURIComponent(c.substring(nameEQ.length, c.length))
}
} return null
}

/**
* Set cookie value .
*
* @Author overseas
*/
function setCookie(name, value, expires, path, domain) {
if (!expires) expires = -1;
if (!path) path = "/";
var d = "" + name + "=" + value;
var e;

if (expires < 0) {
e = "";
}
else if (expires == 0) {
var f = new Date(1970, 1, 1);
e = ";expires=" + f.toUTCString();
}
else {
var now = new Date();
var f = new Date(now.getTime() + expires * 1000);
e = ";expires=" + f.toUTCString();
}
var dm;
if (!domain) {
dm = "";
}
else {
dm = ";domain=" + domain;
}
document.cookie = name + "=" + value + ";path=" + path + e + dm;

};

/**
* Change language via cookie.
*/
function changeLanguage(){
var currentLanguage = cookie.GetCookie("power7000Language");
var currentLanguageAlias = cookie.GetCookie("power7000LanguageAlias");
var nextLanguageAlias = cookie.GetCookie("power7000NextLanguageAlias");

//var supportLanguage1 = "en-US";
//var supportLanguage1Alias = encodeURI("English Version");

//var supportLanguage2 ="zh-CN";
//var supportLanguage2Alias = encodeURI("中文版");

var newLanguage = supportLanguage1;
var newLanguageAlias = supportLanguage1Alias;

var path = "/";

if (!currentLanguage && typeof(currentLanguage)!="undefined" && currentLanguage!=0){
//null
newLanguage = supportLanguage1;
newLanguageAlias = supportLanguage1Alias;
nextLanguageAlias = supportLanguage2Alias;
}
else if(currentLanguage==supportLanguage1){

newLanguage = supportLanguage2;
newLanguageAlias = supportLanguage2Alias;
nextLanguageAlias = supportLanguage1Alias;
}
else if(currentLanguage==supportLanguage2){
newLanguage = supportLanguage1;
newLanguageAlias = supportLanguage1Alias;
nextLanguageAlias = supportLanguage2Alias;
}
else{
//other
newLanguage = supportLanguage1;
newLanguageAlias = supportLanguage1Alias;
nextLanguageAlias = supportLanguage2Alias;
}

//alert(currentLanguage +"-->"+newLanguage);

var expire_time = new Date();
expire_time.setFullYear(expire_time.getFullYear() + 100);

cookie.SetCookie(‘power7000Language‘, newLanguage, expire_time);
cookie.SetCookie(‘power7000LanguageAlias‘, newLanguageAlias, expire_time);
cookie.SetCookie(‘power7000NextLanguageAlias‘, nextLanguageAlias, expire_time);

//alert(readCookie("power7000Language"));
i18n.setLng(newLanguage);
$("*").i18n();
}

/**
* Format a message with placeholder.
*
* Examples:
* var addr = "{0}省, {1}市, {2}区";
* alert(addr.format("广东","深圳"));
* alert("{0}省, {1}市, {2}区".format("广东","深圳"));
* @Author overseas
*/
String.prototype.format = function(){
var args = arguments;
return this.replace(/\{(\d+)\}/g,
function(m,i){
return args[i];
});
};

/**
* Get web root path .
*
* @Author overseas
*/
function getRootPath_web() {
//获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
var curWwwPath = window.document.location.href;
//获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
//获取主机地址,如: http://localhost:8083
var localhostPaht = curWwwPath.substring(0, pos);
//获取带"/"的项目名,如:/uimcardprj
var projectName = pathName.substring(0, pathName.substr(1).indexOf(‘/‘) + 1);
return (localhostPaht + projectName);
}

/**
* Get top most element by z-index .
*
* @Author overseas
*/
$.fn.topmost = function () {
var positionedDivs = this.filter( function() {
return !isNaN( parseInt( $(this).css("z-index"), 10 ) );
});
var topElem = positionedDivs.first();

positionedDivs.each( function() {
if ( $(this).css(‘z-index‘) > +topElem.css("z-index") ) {
topElem = $(this);
}
});

return topElem.get(0) || this.get(0);
};

时间: 2024-10-15 10:29:09

translation.js的相关文章

大转盘抽奖css3+js(简单书写)

今天花了一段时间简单写了下抽奖大转盘,这里写的只是自己想到的简单的写了下(也希望收获其他想法),后续,再写的话会更新. 大体思路:页面加载完成后,通过监听开始按钮的点击事件.然后会根据产生的随机数,通过控制旋转针对象的transform属性,然后进行旋转,最后在结束后获取存储来数组中对应的抽奖内容最后弹出. 知识点:transform, translation,js数组,Math等等 先看下效果,没有素材,只是用css简单的布了下局.不要喷我比较简陋,嘿嘿. 接下来是基本代码结构: 1 <div

自己动手,丰衣足食.

时下grunt非常的火啊,用着虽然很爽,但是它的配置确实很烦.如果之前没有用过,想要一下子熟练驾驭它,有一定的学习成本,而且还要装node这个大家伙,项目之初我们选择了compiler.jar这个轻量的工具进行打包.我一直在寻思着,如何编写一键打包工具.之前呢是手工的拼接好有的js文件,做成符合compiler.jar打包文件所要求的批处理文件,然后运行这个批处理,生成我们需要的js和css文件.随着js文件数量的增长,纯手工拼接这些文件的地址就变得非常考验人的耐心了,而且还容易漏掉或重复某些文

修改allure测试报告名称

1.从github获取allure代码 https://github.com/allure-framework/allure2 2.安装gradle,用于打包jar brew install gradle 3.配置gradle环境变量 vim ~/.bash_profile export GRADLE_HOME=/usr/local/Cellar/gradle/5.5.1 export PATH=${GRADLE_HOME}/bin 4.生效环境变量 source ~/.bash_profile

Vue.js 系列教程 5:动画

原文:intro-to-vue-5-animations 译者:nzbin 译者的话:经过两周的努力,终于完成了这个系列的翻译,由于时间因素及个人水平有限,并没有详细的校对,其中仍然有很多不易理解的地方.我和原作者的初衷一样,希望大家能够通过这个系列文章有所收获,至少可以增加学习的乐趣,我也在学习的路上,所学心得必将与大家共勉. 这是 JavaScript 框架 Vue.js 五篇教程的第五部分.在这个系列的最后一部分,我们将学习动画(如果你了解我,你知道这一章迟早会来).这不是一个完整的指南,

利用OpenShift托管Node.js Web服务进行微信公众号开发

最近写了一个微信的翻译机器人.用户只要关注该微信号,发送英文的消息,就能收到中文翻译的回复.后台是用Node.js写的,托管在OpenShift的Paas平台上.翻译过程实际上是调用微软的Bing translation API做的,代码中用到了alexu84的bing-translate和JacksonTian的wechat这两个npm模块.下面把做的过程详细说一下. 1. 微信公众号开发 首先是要到https://mp.weixin.qq.com 申请一个公众号,并申请成为开发者.目前个人只

three.js 源码注释(七十四)extras/geometries/ExtrudeGeometry.js

商域无疆 (http://blog.csdn.net/omni360/) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:商域无疆 -  本博客专注于 敏捷开发及移动和物联设备研究:数据可视化.GOLANG.Html5.WEBGL.THREE.JS,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 俺也是刚开始学,好多地儿肯定不对还请见谅. 以下代码是THREE.JS 源码文件中extras/geometries/ExtrudeGeometry.js文件的注释.

impress.js 源码解析系列(2)

1 /** 2 * [impress description] 定义 impress 函数 3 * @param {[type]} rootId [description] 4 * @return {[type]} [description] 5 */ 6 var impress = window.impress = function( rootId ) { 7 // 如果浏览器不支持,则退出 8 if ( !impressSupported ) { 9 return { 10 init: em

js中的this(二)

在上一篇文章 掌握JS中的“this” (一) 里面, 我们学会了如何正确使用JavaScript中的 this 关键字及其基本原理.我们也知道决定 this 指向哪个对象的关键因素, 是找出当前的执行上下文(execution context).但如果执行上下文不按正常的方式进行设置,问题可能就会变得很棘手.在本文中,我会着重提示在哪些地方会发生这种情况, 以及用什么方式可以弥补. 解决常见问题 在本节中,我们将探讨一些使用 this 关键字时最常见的问题, 并了解如何处理这种情况. 1. 在

Three.js typescript definitely typed 文件

最近学习three.js,想用typescript编写代码,去http://definitelytyped.org/找了一圈没有发现three.js的definitely typed文件. 好吧,花了2天时间自己简单写了一份: declare module THREE { export class BoxHelper extends Line { constructor(object: Object3D); public update(object: Object3D); } export cl