我的主页面(index.php)看起来像:
<?php start_session();
... PHP CODE ...
?>
<html>
... HTML CODE ...
<script type="text/javascript">
var bscTexts =
{
signup: {
cropPicture: 'Crop your profile picture',
},
home: {
noFavorites: 'You haven´t added any profiles as favorites'
},
general: {
errorUploading: 'Error uploading, please try again',
successfulUploading: 'Votre photo a bien été obtenue',
chooseAnotherPicture: 'Choisir une autre photo',
loadingMore: 'Loading, please wait...'
},
notificationBubbles: {
/*InterestedInYou */ 1: {
Text: '[Name] has shown interest in you',
Url: "/match/interestedinme"
},
/*Match */ 2: {
Text: 'You and [Name] are now a match',
Url: "/match/matches"
},
/*WinkSent */ 3: {
Text: 'You have received a wink from [Name]',
Url: "/home/socialstream"
},
/*LovedPicture */ 4: {
Text: '[Name] loves one of your pictures',
Url: "/home/socialstream"
}
}
};
</script>
... OTHER HTML CODE ...
</html>
我想知道是否可以用jquery或其他(dom)替换文本(字符串语句)
例如:
如果我调用alert(bscTexts.signup.cropPicture);结果是弹出警告“播放你的个人资料图片”
我需要知道是否可以在页面加载jquery,javascript或其他后用法语翻译替换“裁剪您的个人资料图片”以获取此信息:
<script type="text/javascript">
var bscTexts =
{
signup: {
cropPicture: 'Redimensionnez votre photo',
}
</script>
这是例如我需要更改所有字符串。
感谢您的帮助!
答案 0 :(得分:0)
在文档就绪后,jquery中有一个函数用于重写变量:
jQuery(function($){
... rewrite your vars...
})
答案 1 :(得分:0)
如果要更改所有字符串,只需再次分配对象:
bscTexts = { ... };
如果只有字符串替换每一个:
bscTexts.signup.cropPicture = 'new value';
.
.
bscTexts.notificationBubbles.Text = 'new value';