Skip to content

Commit

Permalink
added translations
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Nov 13, 2015
1 parent c2454e4 commit eba9f25
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .hidev/commits.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ hiqdev/yii2-cart commits history

## Under development

- Added local ShoppingCart component
- c2454e4 2015-11-13 added local ShoppingCart component with currency formatting and used all over (sol@hiqdev.com)
- Changed: redone to yii2-cart
- 879a12c 2015-11-12 php-cs-fixed (sol@hiqdev.com)
- 3dc05b9 2015-11-12 basically fixed (sol@hiqdev.com)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ hiqdev/yii2-cart changelog

## Under development

- Added local ShoppingCart component
- Changed: redone to yii2-cart
- Added basics

Expand Down
15 changes: 14 additions & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,22 @@ public function init()
parent::init();
if (!$this->has('cart')) {
$this->set('cart', [
'class' => 'hiqdev\yii2\cart\components\ShoppingCart',
'class' => 'hiqdev\yii2\cart\ShoppingCart',
]);
}
$this->registerTranslations();
}

public function registerTranslations()
{
Yii::$app->i18n->translations['cart'] = [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en-US',
'basePath' => '@hiqdev/yii2/cart/messages',
'fileMap' => [
'merchant' => 'cart.php',
],
];
}

public static $name = 'cart';
Expand Down
2 changes: 1 addition & 1 deletion src/components/ShoppingCart.php → src/ShoppingCart.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace hiqdev\yii2\cart\components;
namespace hiqdev\yii2\cart;

use Yii;

Expand Down
6 changes: 3 additions & 3 deletions src/actions/AddToCartAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public function run()
foreach ($collection->models as $position) {
if (!$cart->hasPosition($position->getId())) {
$cart->put($position);
Yii::$app->session->addFlash('success', Yii::t('app', 'Item is added to cart'));
Yii::$app->session->addFlash('success', Yii::t('cart', 'Item has been added to cart'));
} else {
Yii::$app->session->addFlash('warning', Yii::t('app', 'Item already exists in the cart'));
Yii::$app->session->addFlash('warning', Yii::t('cart', 'Item is in the cart already'));
}
}
} else {
Yii::$app->session->addFlash('warning', Yii::t('app', 'Item does not exists'));
Yii::$app->session->addFlash('warning', Yii::t('cart', 'Item does not exists'));
}

if ($request->isAjax) {
Expand Down
49 changes: 49 additions & 0 deletions src/messages/ru/cart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
* Yii2 extension for payment processing with Omnipay, Payum and more later
*
* @link https://github.com/hiqdev/yii2-merchant
* @package yii2-merchant
* @license BSD-3-Clause
* @copyright Copyright (c) 2015, HiQDev (http://hiqdev.com/)
*/

/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Sum' => 'Сумма',
'Date' => 'Дата',
'Cart' => 'Корзина',
'Your cart' => 'Ваша корзина',
'View cart' => 'Показать корзину',
'Clear cart' => 'Очистить корзину',
'Your cart is empty' => 'Ваша корзина пуста',
'Price' => 'Цена',
'Quantity' => 'Количество',
'Description' => 'Описание',
'Subtotal' => 'Итого',
'Discount' => 'Скидка',
'Total' => 'К оплате',
'Make order' => 'Сделать заказ',
'Item has been added to cart' => 'Товар добавлен в корзину',
'Item is in the cart already' => 'Товар уже в корзине',
'Item does not exist' => 'Такого товара нет',
'I have read and agree to the' => 'Я прочел и согласен с',
'terms of use' => 'условиями предостовления услуг',
];
18 changes: 9 additions & 9 deletions src/views/cart/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use yii\grid\GridView;
use yii\helpers\Html;

$this->title = Yii::t('app', 'Cart');
$this->title = Yii::t('cart', 'Cart');
$this->params['breadcrumbs'][] = $this->title;

?>
Expand All @@ -15,8 +15,8 @@
<div class="row">
<div class="col-xs-12">
<h2 class="page-header">
<?= Yii::t('app', 'Your cart') ?>
<small class="pull-right"><?= Yii::t('app', 'Date') ?>: <?= date('Y-m-d') ?></small>
<?= Yii::t('cart', 'Your cart') ?>
<small class="pull-right"><?= Yii::t('cart', 'Date') ?>: <?= date('Y-m-d') ?></small>
</h2>
</div>
<!-- /.col -->
Expand All @@ -39,7 +39,7 @@
[
'attribute' => 'name',
'format' => 'raw',
'label' => ' ' . Yii::t('app', 'Description'),
'label' => ' ' . Yii::t('cart', 'Description'),
'contentOptions' => ['style' => 'vertical-align: middle'],
'value' => function ($model) {
return $model->icon . ' ' . $model->name . ' ' . Html::tag('span', $model->description, ['class' => 'text-muted']);
Expand Down Expand Up @@ -98,15 +98,15 @@
<table class="table">
<tbody>
<tr>
<th style="width:50%"><?= Yii::t('app', 'Subtotal') ?>:</th>
<th style="width:50%"><?= Yii::t('cart', 'Subtotal') ?>:</th>
<td><?= $cart->formatCurrency($cart->subtotal) ?></td>
</tr>
<tr>
<th><?= Yii::t('app', 'Discount') ?>:</th>
<th><?= Yii::t('cart', 'Discount') ?>:</th>
<td><?= $cart->formatCurrency($cart->discount) ?></td>
</tr>
<tr style="font-size:130%">
<th><?= Yii::t('app', 'Total') ?>:</th>
<th><?= Yii::t('cart', 'Total') ?>:</th>
<td><b><?= $cart->formatCurrency($cart->total) ?></b></td>
</tr>
</tbody>
Expand All @@ -120,8 +120,8 @@
<!-- this row will not appear when printing -->
<div class="row no-print">
<div class="col-xs-12">
<?= Html::a('<i class="fa fa-trash"></i> ' . Yii::t('app', 'Clear cart'), ['clear'], ['class' => 'btn btn-default']); ?>
<?= Html::a('<i class="fa fa-credit-card"></i> ' . Yii::t('app', 'Make order'), ['clear'], ['class' => 'btn btn-success pull-right']); ?>
<?= Html::a('<i class="fa fa-trash"></i> ' . Yii::t('cart', 'Clear cart'), ['clear'], ['class' => 'btn btn-default']); ?>
<?= Html::a('<i class="fa fa-credit-card"></i> ' . Yii::t('cart', 'Make order'), ['clear'], ['class' => 'btn btn-success pull-right']); ?>
</div>
</div>
</section>
8 changes: 4 additions & 4 deletions src/widgets/views/PanelTopCart_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<?php if ($cart->count) : ?>
<li class="header">
<div class="row">
<div class="col-md-6"><?= Html::a(Yii::t('app', 'Your cart'), $widget->module->buildUrl()) ?>:</div>
<div class="col-md-6 text-bold text-right"><?= Yii::t('app', 'Total') ?>: <?= $cart->formatCurrency($cart->total) ?></div>
<div class="col-md-6"><?= Html::a(Yii::t('cart', 'Your cart'), $widget->module->buildUrl()) ?>:</div>
<div class="col-md-6 text-bold text-right"><?= Yii::t('cart', 'Total') ?>: <?= $cart->formatCurrency($cart->total) ?></div>
</div>
</li>
<li>
Expand All @@ -28,11 +28,11 @@
<?php endforeach ?>
</ul>
</li>
<li class="footer"><?= Html::a(Yii::t('app', 'View Cart'), $widget->module->buildUrl()) ?></li>
<li class="footer"><?= Html::a(Yii::t('cart', 'View Cart'), $widget->module->buildUrl()) ?></li>
<?php else : ?>
<li class="header">
<div class="row">
<div class="col-md-6"><?= Yii::t('app', 'Your cart is empty') ?></div>
<div class="col-md-6"><?= Yii::t('cart', 'Your cart is empty') ?></div>
</div>
</li>
<?php endif ?>
Expand Down

0 comments on commit eba9f25

Please sign in to comment.