magento2给网站添加日语导航跳转连接

给网站头部添加语言导航配置

vi app/design/frontend/Zemez/theme135/Magento_Theme/layout/default.xml

 <block class="Magento\Framework\View\Element\Template" name="smart.header.storelanguage.canvas" template="Magento_Theme::storelanguage-canvas.phtml"/>
        <move element="smart.header.storelanguage.canvas" destination="header.content" before="-"/>

 

新增布局文件

vi app/design/frontend/Zemez/theme135/Magento_Theme/templates/storelanguage-canvas.phtml

<div class="storelanguage-canvas" style="background:#f2f2f2; color:#777;">
<div class="container" style="text-align:right;">
<style>
@media only screen and (max-width: 767px){
  .storelanguage-canvas{display:none}}
</style>
<div class="switcher store switcher-storelanguage" id="switcher-storelanguage">
    <strong class="label switcher-label"><span>Language</span></strong>
    <div class="actions dropdown options switcher-options">
               <div class="action toggle switcher-trigger" role="button" tabindex="0" data-toggle="dropdown" data-trigger-keypress-button="true" id="switcher-storelanguage-trigger" aria-haspopup="true" aria-expanded="false">
                <strong>
                    <span>Language</span>
                </strong>
            </div>
                        <ul class="dropdown switcherdropdown" id="storelanguage-ul" data-target="dropdown" aria-hidden="true" style="min-width: 80px;">
                                <li class="switcher-option"> <a href="/" >English</a> </li>
                                <li class="switcher-option"> <a href="/japan/" >日本語</a> </li>
                        </ul>
    </div>
</div>


</div>
</div>
<script>
var switcherStorelanguage = document.getElementById("switcher-storelanguage")
    var storelanguageUl = document.getElementById("storelanguage-ul")
    switcherStorelanguage.onclick = function(){
      if(storelanguageUl.className=='dropdown switcherdropdown'){
        storelanguageUl.className="dropdown switcherdropdown active"
        storelanguageUl.style.display="block"
      }else{
        storelanguageUl.className="dropdown switcherdropdown"
        storelanguageUl.style.display="none"
      }
    }
</script>

给移动端添加多语言切换导航

 vi app/design/frontend/Zemez/theme135/Zemez_Megamenu/templates/html/topmenu.phtml

<style>
        .storelanguage_dl{padding-top: 10px; border-top: 5px solid #d1d1d1; display: none;}
.storelanguage_dl dt{font-size: 18px; padding: 0 15px; color: #575757;}
.storelanguage_dl dd{padding: 0 15px; color: #575757; font-size: 14px; margin-bottom: 5px;}
@media only screen and (max-width: 767px){
  .storelanguage_dl{display: block;}
}
        </style>
        <dl class="storelanguage_dl">
      <dt>Language</dt>
      <dd><a href="/">English</a></dd>
      <dd><a href="/japan/">日本語</a></dd>
    </dl>

日语翻译包下载地址

https://github.com/mageplaza/magento-2-japanese-language-pack

日语翻译文件添加内容

"Shop Now!","購入",lib,web
"Products not found.","お客様がお探しの商品は見つかりませんでした。",lib,web
"Get all the latest information on Events, Sales and Offers. Sign up for newsletter today.","新しい商品情報?セール、イベント情報などをいち早くお届けします。今日からニュースレターを購読しよう。",lib,web
"Current product is already in the comparison list.","比較リストにこの商品すでに追加されました。",module,Zemez_AjaxCompare
"注意","ご注意",module,Zemez_AjaxCompare
"Ajax Compare","比較リストについて",module,Zemez_AjaxCompare
"OK","確認",module,Zemez_AjaxCompare
"Cancel","キャンセル",module,Zemez_AjaxCompare
"Tap to close","閉じる",module,Zemez_AjaxCompare
"Enter your destination to get a shipping estimate.","配送住所によって送料が異なるため、配送先をご確認ください",module,Magento_Checkout
"Ajax Wishlist","ほしい物リスト",module,Zemez_AjaxWishlist
"OK","確認",module,Magento_Wishlist
"Cancel","キャンセル",module,Magento_Wishlist
"Please log in to be able add items to wishlist.","欲しい物リストの利用には、ログインが必要です。",module,Magento_Catalog
"Latest news","最新情報・お知らせ",module,Zemez_Blog
"Cancel","キャンセル",module,Magento_AdvancedCheckout
""Ok"","確認",module,Magento_AdvancedCheckout
"注意","ご注意",module,Magento_AdvancedCheckout

修改js文件中无法翻译文件

vi app/code/Zemez/AjaxCompare/view/frontend/web/js/compare-products-top-link.js +167 
$t('Ajax Compare')

vi app/code/Zemez/AjaxWishlist/view/frontend/web/js/ajaxwishlist.js +56  71  78
$.mage.__('Ajax Wishlist'),
58
 content: $.mage.__('Please log in to be able add items to wishlist.')


vi vendor/magento/module-ui/view/base/web/templates/modal/modal-popup.html +60 add
<script>
if(document.getElementsByTagName('html')[0].lang=="ja"){
        document.getElementsByClassName('module-ui-popup-button-span-ok')[0].innerText="キャンセル";
        document.getElementsByClassName('module-ui-popup-button-span-ok')[1].innerText="確認";
}
</script>

后台
<style>
.page-main > .page.messages .messages .message:not(.notice):not(.info) > div:after{content: '閉じる';}
media="screen and (min-width: 768px)"
.page-main > .page.messages .messages .message:not(.notice):not(.info) > div:after {content: '閉じる';}
</style>

更新缓存

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f

php bin/magento setup:static-content:deploy en_US ja_JP -f 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值