Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translation support for the AltaPay Payment Actions grid #107

Merged
merged 11 commits into from
Jul 26, 2024
Merged
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.6.8]
- Add translation support for the AltaPay Payment Actions grid in the following WordPress-supported languages:

`Danish, German, Estonian, Finnish, French, Czech, German (Austria), German (Switzerland, informal), German (formal), German (Switzerland), French (Belgium), French (Canada), Italian, Lithuanian, Dutch, Dutch (Belgium), Dutch (Formal), Norwegian Nynorsk, Polish, Romanian, Swedish.`

## [3.6.7]
- Extend support to include all languages that the gateway supports.

Expand Down
31 changes: 23 additions & 8 deletions altapay.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* Description: Payment Gateway to use with WordPress WooCommerce
* Author: AltaPay
* Author URI: https://altapay.com
* Version: 3.6.7
* Text Domain: altapay
* Domain Path: /languages
* Version: 3.6.8
* Name: SDM_Altapay
* WC requires at least: 3.9.0
* WC tested up to: 9.0.2
* WC tested up to: 9.1.2
*
* @package Altapay
*/
Expand Down Expand Up @@ -39,7 +41,7 @@
}

if ( ! defined( 'ALTAPAY_PLUGIN_VERSION' ) ) {
define( 'ALTAPAY_PLUGIN_VERSION', '3.6.7' );
define( 'ALTAPAY_PLUGIN_VERSION', '3.6.8' );
}

// Include the autoloader, so we can dynamically include the rest of the classes.
Expand Down Expand Up @@ -81,6 +83,10 @@ function init_altapay_settings() {
if ( empty( $altapay_terminal_classes_recreated ) ) {
Core\AltapaySettings::recreateTerminalData( $settings );
}

load_plugin_textdomain( 'altapay', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );


}

/**
Expand Down Expand Up @@ -270,6 +276,9 @@ function altapayAddMetaBoxes() {
* @return void
*/
function altapay_meta_box_side( $post_or_order_object ) {
global $post;
$order_post = $post;

$order = ( $post_or_order_object instanceof WP_Post ) ? wc_get_order( $post_or_order_object->ID ) : $post_or_order_object;

if ( ! $order ) {
Expand Down Expand Up @@ -344,6 +353,8 @@ function altapay_meta_box_side( $post_or_order_object ) {
wp_reset_postdata();
}

$post = $order_post;

if ( $payments ) {
foreach ( $payments as $pay ) {
$reserved = $pay->ReservedAmount;
Expand All @@ -353,7 +364,7 @@ function altapay_meta_box_side( $post_or_order_object ) {
$type = $pay->AuthType;

if ( $status === 'released' ) {
echo '<strong>' . __( 'Payment released', 'altapay' ) . '</strong>';
echo '<strong>' . __( 'Payment Released.', 'altapay' ) . '</strong>';
} else {
$charge = $reserved - $captured - $refunded;
if ( $charge <= 0 ) {
Expand Down Expand Up @@ -701,6 +712,7 @@ function altapayCaptureCallback() {
'refunded' => $refunded,
'chargeable' => round( $charge, 2 ),
'note' => $noteHtml,
'message' => __( 'Payment Captured.', 'altapay' )
)
);
}
Expand Down Expand Up @@ -824,9 +836,10 @@ function altapayRefundPayment( $orderID, $amount, $reason, $isAjax ) {
$reconciliation = new Core\AltapayReconciliation();
$reconciliation->saveReconciliationIdentifier( (int) $orderID, $transaction['TransactionId'], $reconciliationId, 'refunded' );
} elseif ( strtolower( $response->Result ) === 'open' ) {
$order->add_order_note( __( 'Payment refund is in progress.', 'altapay' ) );
$note = __( 'Payment refund is in progress.', 'altapay' );
$order->add_order_note( $note );
return array(
'message' => 'Payment refund is in progress.',
'message' => $note,
'success' => true,
);
} else {
Expand Down Expand Up @@ -906,7 +919,7 @@ function altapayRefundPayment( $orderID, $amount, $reason, $isAjax ) {
'refunded' => $refunded,
'chargeable' => round( $charge, 2 ),
'note' => $noteHtml,
'message' => __( 'Payment refunded.', 'altapay' ),
'message' => __( 'Payment Refunded.', 'altapay' ),
'success' => true,
);
}
Expand Down Expand Up @@ -962,7 +975,7 @@ function altapayReleasePayment() {
$order->update_meta_data( '_released', true );
$order->add_order_note( __( 'Order released: "The order has been released"', 'altapay' ) );
$order->save();
wp_send_json_success( array( 'message' => 'Payment Released' ) );
wp_send_json_success( array( 'message' => __ ( 'Payment Released.', 'altapay') ) );
}
} else {
$order->add_order_note( __( 'Release failed: ' . $response->MerchantErrorMessage, 'altapay' ) );
Expand Down Expand Up @@ -1069,6 +1082,8 @@ function altapay_checkout_blocks_style() {
plugin_dir_url( __FILE__ ) . 'assets/css/blocks.css',
);
}


add_action( 'wp_enqueue_scripts', 'altapay_checkout_blocks_style' );
add_action( 'woocommerce_blocks_loaded', 'altapay_wc_checkout_block_support' );
add_filter( 'woocommerce_payment_gateways', 'altapay_add_gateway' );
Expand Down
2 changes: 1 addition & 1 deletion assets/js/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jQuery( document ).ready(
function (response) {
var result = response.data;
if (response.success === true) {
jQuery( '.capture-status' ).html( '<strong class="green">Payment captured.</strong>' );
jQuery( '.capture-status' ).html( '<strong class="green">' + result.message + '</strong>' );
jQuery( '.payment-reserved' ).text( result.reserved );
jQuery( '.payment-captured' ).text( result.captured );
jQuery( '.payment-refunded' ).text( result.refunded );
Expand Down
5 changes: 2 additions & 3 deletions assets/js/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ jQuery( document ).ready(
function (response) {
var result = response.data;
if (response.success === true) {
jQuery( '.release-status' ).html( '<strong class="green">Payment released.</strong>' );
alert( 'Payment released' );
location.reload();
jQuery( '.release-status' ).html( '<strong class="green">' + result.message + '</strong>' );
window.setTimeout(function(){location.reload()}, 1000);
} else {
jQuery( '.release-status' ).html( '<strong class="red">Release failed: ' + result.error + '</strong>' );
}
Expand Down
11 changes: 0 additions & 11 deletions classes/core/AltapaySettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class AltapaySettings {
* AltapaySettings constructor.
*/
public function __construct() {
// Load localization files
add_action( 'init', array( $this, 'altapayLocalizationInit' ) );
add_action( 'init', array( $this, 'altapayCapturesPostInit' ) );
// Add admin menu
add_action( 'admin_menu', array( $this, 'altapaySettingsMenu' ), 60 );
Expand Down Expand Up @@ -247,15 +245,6 @@ public function addActionLinks( $links ) {
}


/**
* Loads language file with language specifics
*
* @return void
*/
public function altapayLocalizationInit() {
load_plugin_textdomain( 'altapay', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}

/**
* Add AltaPay settings option in plugins menu
*
Expand Down
Binary file added languages/altapay-cs_CZ.mo
Binary file not shown.
152 changes: 152 additions & 0 deletions languages/altapay-cs_CZ.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Copyright (C) 2024 AltaPay
# This file is distributed under the same license as the AltaPay for WooCommerce - Payments less complicated plugin.
msgid ""
msgstr ""
"Project-Id-Version: AltaPay for WooCommerce - Payments less complicated 3.6.8\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/altapay-for-woocommerce\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: cs_CZ\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-07-18T10:05:00+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.10.0\n"
"X-Domain: altapay\n"


#: altapay.php:254
msgid "AltaPay Payment Actions"
msgstr "Akce platby AltaPay"

#: altapay.php:297
#: classes/core/AltapayOrderStatus.php:52
#: classes/core/AltapaySettings.php:63
#: classes/core/AltapaySettings.php:437
#: helpers/traits/AltapayMaster.php:69
#: terminals/Altapay_Test_Terminal.class.php:418
msgid "Could not connect to AltaPay!"
msgstr "Nepodařilo se připojit k AltaPay!"

#: altapay.php:311
#: classes/core/AltapayOrderStatus.php:62
msgid "Could not fetch Payments from AltaPay!"
msgstr "Nepodařilo se načíst platby z AltaPay!"

#: altapay.php:360
#: altapay.php:971
msgid "Payment Released."
msgstr "Platba uvolněna."

#: altapay.php:385
msgid "Order got no transaction"
msgstr "Objednávka nemá žádnou transakci"

#: altapay.php:708
msgid "Payment Captured."
msgstr "Platba zachycena."

#: altapay.php:832
msgid "Payment refund is in progress."
msgstr "Vrácení platby probíhá."

#: altapay.php:915
msgid "Payment Refunded."
msgstr "Platba vrácena."

#: views/tables/capture.blade.php:16
#: views/tables/refund.blade.php:16
msgid "Product name"
msgstr "Název produktu"

#: views/tables/capture.blade.php:17
#: views/tables/refund.blade.php:17
msgid "Price with tax"
msgstr "Cena s daní"

#: views/tables/capture.blade.php:18
#: views/tables/refund.blade.php:18
msgid "Price without tax"
msgstr "Cena bez daně"

#: views/tables/capture.blade.php:19
#: views/tables/refund.blade.php:19
msgid "Ordered"
msgstr "Objednáno"

#: views/tables/capture.blade.php:20
#: views/tables/refund.blade.php:20
msgid "Discount Percent"
msgstr "Procento slevy"

#: views/tables/capture.blade.php:21
#: views/tables/refund.blade.php:21
msgid "Quantity"
msgstr "Množství"

#: views/tables/capture.blade.php:22
#: views/tables/refund.blade.php:22
msgid "Total amount"
msgstr "Celková částka"

#: views/tables/index.blade.php:59
#: views/tables/index.blade.php:95
msgid "Send order lines"
msgstr "Odeslat řádky objednávky"

#: views/tables/index.blade.php:66
#: views/tables/index.blade.php:101
msgid "Amount"
msgstr "Částka"

#: views/tables/index.blade.php:68
#: views/tables/index.blade.php:139
#: views/tables/index.blade.php:143
msgid "Capture"
msgstr "Zachytit"

#: views/tables/index.blade.php:103
#: views/tables/index.blade.php:144
#: views/tables/index.blade.php:148
msgid "Refund"
msgstr "Vrátit"

#: views/tables/index.blade.php:113
msgid "Transaction ID"
msgstr "ID transakce"

#: views/tables/index.blade.php:118
msgid "Reserved"
msgstr "Rezervováno"

#: views/tables/index.blade.php:123
#: views/tables/index.blade.php:124
msgid "Chargeable"
msgstr "Zpoplatnitelné"

#: views/tables/index.blade.php:128
#: views/tables/index.blade.php:130
msgid "Captured"
msgstr "Zachyceno"

#: views/tables/index.blade.php:133
#: views/tables/index.blade.php:136
msgid "Refunded"
msgstr "Vráceno"

#: views/tables/index.blade.php:138
#: views/tables/index.blade.php:142
msgid "Capture Payment"
msgstr "Zachytit platbu"

#: views/tables/index.blade.php:143
#: views/tables/index.blade.php:147
msgid "Refund Payment"
msgstr "Vrátit platbu"

#: views/tables/index.blade.php:149
#: views/tables/index.blade.php:153
msgid "Release Payment"
msgstr "Uvolnit platbu"

Binary file added languages/altapay-da_DK.mo
Binary file not shown.
Loading
Loading