【问题标题】:Replace text to translate替换要翻译的文本
【发布时间】:2012-08-10 22:47:56
【问题描述】:

我开了一家网上商店。在结帐页面,我需要替换“您的购物车”字样,因为我会有不同的翻译。我找不到任何改变它的代码。

这是我在 Firebug 中看到的:

<table id="v65-cart-moreItems" border="0" align="center" width="96%" cellspacing="0" cellpadding="1">
<h2 class="v65-your-cart-title">Your Cart</h2>

使用 Firebug,我可以检查脚本:

<script type="text/javascript">
    function formatCart() {
        jQuery(function () {
            var path = '/a/c/shoppingcart.css';
            if (document.createStyleSheet) {
                document.createStyleSheet(path);
            } else {
                cssTag = '<link rel="stylesheet" type="text/css" href="' + path + '"  />';
                jQuery(document.getElementsByTagName('head')[0]).append(cssTag);
            }
            VJS.v65Cart.Layout.moveRemoveButtons().moveArticleText().dividerAfterItems().swapCheckoutPaths().swapQTYandPrice().moveCouponForm().moveRecalcTotal().addHeader('Your Cart').formatCellSpacing(2).zebraStripes().init();
            if (jQuery('#v65-cart-shipping-details-wrapper').length > 0) {
                VJS.v65Cart.Layout.formatShipping();
            }
        });
    }
    if (typeof jQuery == 'function') {
        if (VJS.v65Toolkit.checkPage('shoppingcart.asp')) {
            var $layoutSettings = jQuery('#v65-layout-mode');
            if ($layoutSettings.length > 0) {
                if ($layoutSettings.attr('data-cart') == 'storedot') {
                    VJS.v65Toolkit.injectTag({
                        'type': 'script',
                        'url': 'a/j/vjs-shoppingcart.js',
                        'callback': formatCart,
                        'cache': false,
                        'node': 'script'
                    });
                }
            }
        }
    }
</script>

请帮帮我。

【问题讨论】:

    标签: javascript jquery text replace


    【解决方案1】:

    已编辑。应该这样做。

    <script type="text/javascript">
        $(function(){
            $('.v65-your-cart-title').text('new text here');
        }
    </script>
    

    【讨论】:

    • 问题是我无法访问此脚本..所以我无法更改文本..他们告诉我我需要一个自定义脚本来更改它..
    • 这就是您要放入自定义脚本的内容。
    • 只要把它放在$(document).ready 中就可以了
    • @ngmiceli 你能把整个自定义脚本准备好吗..对不起,我不太熟悉它..谢谢!
    【解决方案2】:

    在这行代码

    VJS.v65Cart.Layout.moveRemoveButtons().moveArticleText().dividerAfterItems().swapCheckoutPaths().swapQTYandPrice().moveCouponForm().moveRecalcTotal().addHeader('Your Cart').formatCellSpacing(2).zebraStripes().init(); 
    

    方法从一个链接到另一个。这意味着,每个方法都会继续影响同一个对象,因为每个方法都返回对该对象的引用。

    这些都在修改layout,所以看起来很有希望。此外,在接近尾声时,您会看到

    .addHeader('Your Cart')
    

    我建议更新那里的文本以供您翻译。

    编辑:如果找不到代码行,请按 Ctrl + F 并搜索“addHeader

    【讨论】:

    • 问题是我无法访问此脚本..所以我无法更改文本..他们告诉我我需要一个自定义脚本来更改它..
    • 那么@idor_brad 的解决方案看起来不错。
    【解决方案3】:

    我不熟悉 volusion,但看起来你可以像这样使用 jquery 来定位标题:

    $('.v65-your-cart-title')
    

    只需将其更改为 .html('Your new title')

    原来如此

    $('.v65-your-cart-title').html('Your new title')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-19
      • 1970-01-01
      相关资源
      最近更新 更多