Skip to content

Commit

Permalink
Merge branch 'develop' into fix/PIWOO-348
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Feb 23, 2024
2 parents 2cd2b2a + 44735ce commit 78d0cb4
Show file tree
Hide file tree
Showing 66 changed files with 16,410 additions and 6,694 deletions.
9 changes: 9 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,14 @@ patchwork.json
*.config.*
*.md
gulpfile.js
webpack.config.js
readme.md
changelog.txt
psalm.xml
node_modules/
.babelrc
.composer_compiled_assets
.editorconfig
.env.example
.idea/
.psalm/
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0']
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

name: PHP ${{ matrix.php-versions }}
steps:
Expand Down
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/*
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
required: true
jobs:
create_archive:
uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@main
uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@task/build-plugin-archive-without-dep-dependencies
with:
PLUGIN_VERSION: ${{ inputs.PACKAGE_VERSION }}
PHP_VERSION: 7.2
PLUGIN_MAIN_FILE: mollie-payments-for-woocommerce.php
ARCHIVE_NAME: mollie-payments-for-woocommerce
PRE_SCRIPT: |
echo 'hello world!';
POST_SCRIPT: |
mv dist/WooCommerce dist/mollie-payments-for-woocommerce
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
6 changes: 4 additions & 2 deletions inc/settings/mollie_advanced_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'{customer.company}' => _x('Customer\'s company name', 'Label {customer.company} description for payment description options', 'mollie-payments-for-woocommerce'),
];

return [
$mollieAdvancedSettings = [
[
'id' => $pluginName . '_title',
'title' => __('Mollie advanced settings', 'mollie-payments-for-woocommerce'),
Expand Down 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 @@ -204,3 +204,5 @@ class="mollie-settings-advanced-payment-desc-label button button-secondary butto
'type' => 'sectionend',
],
];

return apply_filters('inpsyde.mollie-advanced-settings', $mollieAdvancedSettings, $pluginName);
Loading

0 comments on commit 78d0cb4

Please sign in to comment.