Skip to content

Commit

Permalink
Merge branch 'release/7.4.1'
Browse files Browse the repository at this point in the history
# Conflicts:
#	mollie-payments-for-woocommerce.php
  • Loading branch information
mmaymo committed Oct 30, 2023
2 parents 995d23e + e1ca262 commit 625041c
Show file tree
Hide file tree
Showing 52 changed files with 25,042 additions and 6,503 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/languages-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Languages-diff

on:
workflow_dispatch:
inputs:
PACKAGE_VERSION:
description: 'Package Version'
required: true
jobs:
languages-diff:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: "Create CSV of diff translations"
run: |
chmod +x ./convert_csv.sh
./convert_csv.sh
- name: Set artifact name
id: set-artifact-name
run: echo "artifact=mollie-payments-for-woocommerce-languages-${{ inputs.PACKAGE_VERSION }}" >> $GITHUB_OUTPUT

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.set-artifact-name.outputs.artifact }}
path: languages/*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/tools/
/build/
/tests/e2e/Shared/default.json

package-lock.json
.env
cypress.json
test-results/
Expand Down
35 changes: 34 additions & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions convert_csv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

cd languages || exit

POT_FILE="en_GB.pot"
CSV_DIR="untranslated_csv"

LANG_EXT=("-de_DE" "-de_DE_formal" "-es_ES" "-fr_FR" "-it_IT" "-nl_NL" "-nl_NL_formal" "-nl_BE" "-nl_BE_formal")

if [[ ! -e $POT_FILE ]]; then
echo "File $POT_FILE not found."
exit 1
fi

mkdir -p $CSV_DIR # Create the directory if it does not exist

# Loop through each language extension
for lang in "${LANG_EXT[@]}"; do
PO_FILE="mollie-payments-for-woocommerce${lang}.po"
CSV_FILE="$CSV_DIR/mollie-payments-for-woocommerce${lang}.csv"
UNTRANSLATED_FILE="$CSV_DIR/mollie-payments-for-woocommerce${lang}_untranslated.csv"

if [[ -e $PO_FILE ]]; then
msgmerge --update --no-wrap --backup=none "$PO_FILE" "$POT_FILE" # Update PO file with POT file
echo "Updated $PO_FILE with new strings from $POT_FILE"
else
echo "File $PO_FILE not found. Skipping..."
continue
fi

echo 'location,msgid,msgstr,msgctxt' > "$CSV_FILE"
echo 'line,msgid' > "$UNTRANSLATED_FILE"

# Initialize variables
location=""
msgid=""
msgstr=""
msgctxt=""
line_no=0

# Function to write to CSV
write_to_csv() {
echo "\"$location\",\"$msgid\",\"$msgstr\",\"$msgctxt\"" >> "$CSV_FILE"
if [[ -z "$msgstr" && -n "$msgid" ]]; then
echo "$line_no,\"$msgid\"" >> "$UNTRANSLATED_FILE"
fi
# Reset variables
location=""
msgid=""
msgstr=""
msgctxt=""
}

while IFS= read -r line || [[ -n "$line" ]]; do # also handle the last line
((line_no++))

if [[ "$line" =~ ^\#:\ (.+)$ ]]; then
location="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^msgid\ \"(.*)\"$ ]]; then
if [[ -n "$msgid" || -n "$msgstr" ]]; then
write_to_csv
fi
msgid="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^msgstr\ \"(.*)\"$ ]]; then
msgstr="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^msgctxt\ \"(.+)\"$ ]]; then
msgctxt="${BASH_REMATCH[1]}"
fi
done < "$PO_FILE"

# For the last msgid in the file
if [[ -n "$msgid" || -n "$msgstr" ]]; then
write_to_csv
fi

echo "Created CSV $CSV_FILE and $UNTRANSLATED_FILE for $PO_FILE"
done
30 changes: 30 additions & 0 deletions csv-to-po.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

CSV_DIR="languages/translated_csv"
PO_DIR="languages"
MO_DIR="languages"

for csv_file in "$CSV_DIR"/*.csv; do
[ -e "$csv_file" ] || continue

base_name=$(basename -- "$csv_file" .csv)
po_file="$PO_DIR/$base_name.po"
mo_file="$MO_DIR/$base_name.mo"

awk -F'"' '
BEGIN { OFS=""; print "msgid \"\""; print "msgstr \"\""; print "\"Content-Type: text/plain; charset=UTF-8\\n\""; }
NR > 1 {
gsub(/\\/, "\\\\", $2);
gsub(/\"/, "\\\"", $2);
gsub(/\\/, "\\\\", $4);
gsub(/\"/, "\\\"", $4);
print "\n#: " $2;
print "msgid \"" $4 "\"";
print "msgstr \"" $6 "\"";
}' "$csv_file" > "$po_file"

echo "Created PO file: $po_file"

msgfmt "$po_file" -o "$mo_file"
echo "Created MO file: $mo_file"
done
32 changes: 31 additions & 1 deletion inc/settings/mollie_advanced_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
/* translators: Placeholder 1: enabled or disabled */
'desc' => sprintf(
__(
'Should Mollie store customers name and email address for Single Click Payments? Default <code>%1$s</code>. Required if WooCommerce Subscriptions is being used! Read more about <a href="https://help.mollie.com/hc/en-us/articles/115000671249-What-are-single-click-payments-and-how-does-it-work-">%2$s</a> and how it improves your conversion.',
'Should Mollie store customers name and email address for Single Click Payments? Default <code>%1$s</code>. Required if WooCommerce Subscriptions is being used! Read more about <a href=\'https://help.mollie.com/hc/en-us/articles/115000671249-What-are-single-click-payments-and-how-does-it-work-\'>%2$s</a> and how it improves your conversion.',
'mollie-payments-for-woocommerce'
),
strtolower(__('Enabled', 'mollie-payments-for-woocommerce')),
Expand Down Expand Up @@ -199,6 +199,36 @@ class="mollie-settings-advanced-payment-desc-label button button-secondary butto
__('Clear now', 'mollie-payments-for-woocommerce')
) . '</a>)',
],
[
'id' => $pluginName . '_place_payment_onhold',
'title' => __('Placing payments on Hold', 'mollie-payments-for-woocommerce'),
'type' => 'select',
'desc_tip' => true,
'options' => [
'immediate_capture' => __('Capture payments immediately', 'mollie-payments-for-woocommerce'),
'later_capture' => __('Authorize payments for a later capture', 'mollie-payments-for-woocommerce'),
],
'default' => 'immediate_capture',
'desc' => sprintf(
__(
'Authorized payment can be captured or voided by changing the order status instead of doing it manually.',
'mollie-payments-for-woocommerce'
)
),
],
[
'id' => $pluginName . '_capture_or_void',
'title' => __(
'Capture or void on status change',
'mollie-payments-for-woocommerce'
),
'type' => 'checkbox',
'default' => 'no',
'desc' => __(
'Capture authorized payments automatically when setting the order status to Processing or Completed. Void the payment by setting the order status Canceled.',
'mollie-payments-for-woocommerce'
),
],
[
'id' => $pluginName . '_sectionend',
'type' => 'sectionend',
Expand Down
Loading

0 comments on commit 625041c

Please sign in to comment.