跨境商城多语言。我们拆分为几个主题。先从多语言开始,
多语言一般都是写的语言包,有的图省事是直接调用的翻译。这种不推荐。影响使用感受。那么不同的程序多语言应该怎么写呢?一组实例
<?php
/**
* address.php
*
* @copyright 2022 beikeshop.com - All Rights Reserved
* @link https://beikeshop.com
* @author Edward Yang <yangjin@guangda.work>
* @created 2022-08-22 18:18:59
* @modified 2022-08-22 18:18:59
*/
return [
'index' => 'Изменить адрес',
'name' => 'Имя',
'phone' => 'номер телефона',
'country_id' => 'Идентификатор страны',
'zone' => 'провинция',
'zone_id' => 'Идентификатор провинции',
'address_1' => 'адрес 1',
'address_2' => 'Адрес 2',
'address' => 'адрес',
'enter_city' => 'введите адрес',
'post_code' => 'почтовый индекс',
'default' => 'адрес по умолчанию',
];
这是PHP多语言写法。当然也可以用其他方法写语言包。
商家入驻,这个功能是跨境商城必备的功能。我们先要写首页的商家页面。下面是部分参考代码
@extends('layout.mail')
@section('content')
<tbody>
<tr style="font-weight:300">
<td style="width:3.2%;max-width:30px;"></td>
<td style="max-width:480px;text-align:left;">
<h1 style="font-size: 20px; line-height: 36px; margin: 0px 0px 22px;">
{{ __('mail.retrieve_password_title') }}
</h1>
<p style="line-height: 24px; margin: 6px 0px 0px; overflow-wrap: break-word; word-break: break-all;">
<span style="color: rgb(51, 51, 51); font-size: 14px;">{{ __('mail.retrieve_password_text') }}
<span style="font-weight: bold;">{{ __('mail.not_oneself') }}</span>
</span>
</p>
<p style="line-height: 24px; margin: 6px 0px 0px; overflow-wrap: break-word; word-break: break-all;">
<span style="color: rgb(51, 51, 51); font-size: 14px;">{{ __('shop/forgotten.verification_code') }}:
<span style="font-weight: bold;">{{ $code }}</span>
</span>
</p>
<p style="font-size: 14px; color: rgb(51, 51, 51); line-height: 24px; margin: 6px 0px 0px; word-wrap: break-word; word-break: break-all;">
<a href="{{ $is_admin ? admin_route('forgotten.index') : shop_route('forgotten.index') }}?code={{ $code }}&email={{ $email }}" title="" style="font-size: 16px; line-height: 45px; display: block; background-color: #fd560f; color: rgb(255, 255, 255); text-align: center; text-decoration: none; margin-top: 20px; border-radius: 3px;">
{{ __('mail.retrieve_password_btn') }}
</a>
</p>
<dl style="font-size: 14px; color: rgb(51, 51, 51); line-height: 18px;">
<dd style="margin: 0px 0px 6px; padding: 0px; font-size: 12px; line-height: 22px;">
<p style="font-size: 14px; line-height: 26px; word-wrap: break-word; word-break: break-all; margin-top: 32px;">
{{ __('mail.sincerely') }}
<br>
<strong>{{ config('app.name') }} {{ __('mail.team') }}</strong>
</p>
</dd>
其次就是商家上传添加商品功能。放出部分参考代码
@extends('layout.mail')
@section('content')
<tbody>
<tr style="font-weight:300">
<td style="width:3.2%;max-width:30px;"></td>
<td style="max-width:480px;text-align:left;">
<h1 style="font-size: 20px; line-height: 36px; margin: 0px 0px 22px;">
{{ __('mail.order_success') }}
</h1>
<p style="font-size:14px;color:#333; line-height:24px; margin:0;">
{{ __('mail.customer_name', ['name' => $order->customer_name]) }}!
</p>
<p style="line-height: 24px; margin: 6px 0px 0px; overflow-wrap: break-word; word-break: break-all;">
<span style="color: rgb(51, 51, 51); font-size: 14px;">{{ __('mail.order_success') }}
<span style="font-weight: bold;">{{ __('mail.not_oneself') }}</span>
</span>
</p>
<p style="font-size: 13px;font-weight:bold;margin-bottom:6px;color: #333;">{{ __('shop/account.order.order_info.order_details') }}:</p>
<table style="width:100%;font-weight:300;margin-top:10px; margin-bottom:10px;border-collapse:collapse; background-color:#f8f9fa">
<thead>
<tr>
<td style="font-size:13px;padding: 7px 6px">{{ __('shop/account.order.order_info.order_number') }}</td>
<td style="font-size:13px;padding: 7px 6px">{{ __('shop/account.order.order_info.order_date') }}</td>
<td style="font-size:13px;padding: 7px 6px">{{ __('shop/account.order.order_info.state') }}</td>
<td style="font-size:13px;padding: 7px 6px">{{ __('shop/account.order.order_info.order_amount') }}</td>
</tr>
</thead>
<tbody>
<tr>
<td style="padding:7px;font-size:13px;">{{ $order->number }}</td>
<td style="padding:7px;font-size:13px;">{{ $order->created_at }}</td>
<td style="padding:7px;font-size:13px;">
{{ __("common.order.{$order->status}") }}
</td>
核心功能商家一键铺货,这个功能很实用。方便有些卖家自己没有货源,帮平台卖货赚取佣金。参参考代码,基于php开发
extends('layout.mail')
@section('content')
<tbody>
<tr style="font-weight:300">
<td style="width:3.2%;max-width:30px;"></td>
<td style="max-width:480px;text-align:left;">
<h1 style="font-size: 20px; line-height: 36px; margin: 0px 0px 22px;">
{{ __('mail.order_update') }}
</h1>
<p style="font-size:14px;color:#333; line-height:24px; margin:0;">
{{ __('mail.customer_name', ['name' => $order->customer_name]) }}
</p>
<p style="line-height: 24px; margin: 6px 0px 0px; overflow-wrap: break-word; word-break: break-all;">
<span style="color: rgb(51, 51, 51); font-size: 14px;">{{ __('mail.order_update_status', ['number' => $order->number]) }}:
<span style="font-weight: bold;">{{ __("common.order.{$order->status}") }}</span>
</span>
</p>
<p style="font-size: 13px;font-weight:bold;margin-bottom:6px;color: #333;">{{ __('shop/account.order.order_info.order_items') }}:</p>
<table style="width:100%;font-weight:300;margin-top:10px; margin-bottom:10px;border-collapse:collapse; ">
<thead>
<tr>
支付页面,调用国际主流支付,paypal visa 等。启用沙盒模式 参考代码
@section('content')
<x-shop-breadcrumb type="static" value="products.search" />
<div class="container">
<div class="row">
@if (count($items))
@foreach ($items as $product)
<div class="col-6 col-md-3">@include('shared.product')</div>
@endforeach
@else
<x-shop-no-data />
@endif
</div>
{{ $products->links('shared/pagination/bootstrap-4') }}
</div>
@endsection
订单页面功能,参考代码
<div class="container">
<div class="row">
<div class="col-12 col-lg-3 pe-lg-4 left-column d-none d-lg-block">
<div class="x-fixed-top">@include('shared.filter_sidebar_block')</div>
</div>
<div class="col-12 col-lg-9 right-column">
<div class="filter-value-wrap mb-2 d-none">
<ul class="list-group list-group-horizontal">
@foreach ($filter_data['attr'] as $index => $attr)
@foreach ($attr['values'] as $value_index => $value)
@if ($value['selected'])
<li class="list-group-item me-1 mb-1" data-attr="{{ $index }}" data-attrval="{{ $value_index }}">
{{ $attr['name'] }}: {{ $value['name'] }} <i class="bi bi-x-lg ms-1"></i>
</li>
@endif
@endforeach
@endforeach
<li class="list-group-item me-1 mb-1 delete-all">{{ __('common.delete_all') }}</li>
</ul>
</div>
充值功能部分参考代码
</div>
@endifphp
<div class="row {{ request('style_list') == 'list' ? 'product-list-wrap' : ''}}">
@foreach ($products_format as $product)
<div class="{{ !request('style_list') || request('style_list') == 'grid' ? 'col-6 col-md-4' : 'col-12'}}">
@include('shared.product')
</div>
@endforeach
</div>
@else
<x-shop-no-data />
@endif
{{ $products->links('shared/pagination/bootstrap-4') }}
</div>
</div>
</div>
@endsection
@push('add-scripts')
<script>
根据以上参考代码开发出来的成品截图。
欢迎一起探讨交流。