Am使用nopCommerce,版本3.50。我的网站是多语言的:俄语,英语,西班牙语。有一个显示产品图像的脚本--放大弹出窗口。
所以,当你点击照片时,它会出现在一个脚本框中(比如fancybox),并且有一些标题,比如"Loading..,Close(Esc),Next,Previous,1/2"。他们总是用英语,这与网站上选择的语言无关。我希望它是一种选定的语言。
如何做到这一点?
可以用不同的语言创建字符串进行翻译,并将它们放在jquery.magnific-popup.js文件中。字符串看起来像这样--@T("amplifcpopup.right")。但是JS忽略字符串,可能是因为它是一个单独的脚本,不涉及这个CMS。
options: {
enabled: false,
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
preload: [0,2],
navigateByImgClick: true,
arrows: true,
tPrev: 'Previous (Left arrow key)',
tNext: '@T("magnificpopup.right")',
tCounter: '%curr% of %total%'
}
如何在JS文件中正确设置这些字符串?我该如何解决我的问题?
谢谢你的帮助。
以下是Magnific弹出窗口l18n的文档:http://dimsemenov.com/plugins/magnific-popup/documentation.html#translating
根据它,您应该在页面的JS代码中中加载amplificpopup.JS脚本的行之后。
var language = //you should get it from browser settings/cookies or server side
if(language == 'ru_RU'){
$.extend(true, $.magnificPopup.defaults, {
tClose: 'Закрыть (Esc)', // Alt text on close button
tLoading: 'Загрузка...', // Text that is displayed during loading. Can contain %curr% and %total% keys
//other lines
});
} else if (language == 'en_US'){
$.extend(true, $.magnificPopup.defaults, {
tClose: 'Close (Esc)', // Alt text on close button
tLoading: 'Loading...', // Text that is displayed during loading. Can contain %curr% and %total% keys
//other lines
});
} else if ( // other languages
您必须在网站标题中创建一个简单的对象,例如:
<script>
var mysite_lang = {
button_title: "<?php echo $lang['button_title'];?>",
box_title: "<?php echo $lang['box_title'];?>"
..etc..
};
</script>
添加js文件后。
现在你可以使用
options: {
enabled: false,
arrowMarkup: '<button title="'+mysite_lang.button_title+'" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>'};