From 6dd414f9b3b4b86ea503a2e6e99cd144ffacd16f Mon Sep 17 00:00:00 2001 From: Soare Robert Daniel Date: Wed, 27 Nov 2024 16:28:59 +0200 Subject: [PATCH] refactor: improve translation handling (#434) - Move HTML and spaces out of the translate strings. - Refactor untranslatable strings. - Add translator comments. - Remove some deadlines. --- backend/options.php | 2 +- backend/templates/admin-settings.php | 22 +- classes/admin.class.php | 38 +- classes/attach-popup/container-view.class.php | 2 +- classes/fields.class.php | 83 +- classes/form.class.php | 6 +- classes/freemium.class.php | 2 +- classes/frontend-scripts.class.php | 12 +- classes/inputs/input.audio.php | 4 +- classes/inputs/input.checkbox.php | 4 +- classes/inputs/input.color.php | 2 +- classes/inputs/input.cropper.php | 4 +- classes/inputs/input.date.php | 23 +- classes/inputs/input.daterange.php | 8 +- classes/inputs/input.divider.php | 4 +- classes/inputs/input.email.php | 4 +- classes/inputs/input.file.php | 6 +- classes/inputs/input.hidden.php | 2 +- classes/inputs/input.image.php | 4 +- classes/inputs/input.measure.php | 4 +- classes/inputs/input.number.php | 4 +- classes/inputs/input.palettes.php | 4 +- classes/inputs/input.pricematrix.php | 2 +- classes/inputs/input.quantities.php | 4 +- classes/inputs/input.radio.php | 4 +- classes/inputs/input.section.php | 2 +- classes/inputs/input.select.php | 4 +- classes/inputs/input.text.php | 6 +- classes/inputs/input.textarea.php | 6 +- classes/inputs/input.timezone.php | 5 +- classes/plugin.class.php | 38 +- inc/admin.php | 30 +- inc/arrays.php | 36 +- inc/files.php | 23 +- inc/functions.php | 16 +- inc/nmInput.class.php | 40 +- inc/prices.php | 7 +- inc/rest.class.php | 15 +- inc/woocommerce.php | 28 +- js/admin/ppom-admin.js | 38 +- languages/woocommerce-product-addon-da_DK.mo | Bin 23741 -> 0 bytes languages/woocommerce-product-addon-da_DK.po | 3870 ---------------- languages/woocommerce-product-addon-de_DE.mo | Bin 25443 -> 0 bytes languages/woocommerce-product-addon-de_DE.po | 3820 ---------------- languages/woocommerce-product-addon-es_ES.mo | Bin 21430 -> 0 bytes languages/woocommerce-product-addon-es_ES.po | 3810 ---------------- languages/woocommerce-product-addon-fr_FR.mo | Bin 21698 -> 0 bytes languages/woocommerce-product-addon-fr_FR.po | 3777 --------------- languages/woocommerce-product-addon-it_IT.mo | Bin 21231 -> 0 bytes languages/woocommerce-product-addon-it_IT.po | 3769 --------------- languages/woocommerce-product-addon-nl_BE.mo | Bin 20824 -> 0 bytes languages/woocommerce-product-addon-nl_BE.po | 3839 ---------------- languages/woocommerce-product-addon-nl_NL.mo | Bin 20810 -> 0 bytes languages/woocommerce-product-addon-nl_NL.po | 3814 ---------------- languages/woocommerce-product-addon-sv_SE.mo | Bin 40587 -> 0 bytes languages/woocommerce-product-addon-sv_SE.po | 3677 --------------- languages/woocommerce-product-addon-tr_TR.mo | Bin 39788 -> 0 bytes languages/woocommerce-product-addon-tr_TR.po | 4037 ----------------- languages/woocommerce-product-addon-zh_CN.mo | Bin 19152 -> 0 bytes languages/woocommerce-product-addon-zh_CN.po | 3765 --------------- languages/woocommerce-product-addon.mo | Bin 420 -> 0 bytes languages/woocommerce-product-addon.po | 2741 ----------- templates/admin/addons-list.php | 7 +- templates/admin/changelog.php | 10 +- templates/admin/existing-meta.php | 4 +- templates/admin/ppom-fields.php | 18 +- templates/frontend/component/form-data.php | 2 +- .../frontend/component/image/image-modals.php | 4 +- .../component/quantities/grid-layout.php | 8 +- .../quantities/horizontal-layout.php | 8 +- .../component/quantities/vertical-layout.php | 8 +- templates/frontend/inputs/cropper.php | 4 +- templates/frontend/inputs/divider.php | 10 +- templates/frontend/inputs/file.php | 8 +- templates/frontend/inputs/quantities.php | 12 +- templates/frontend/inputs/text.php | 8 +- templates/frontend/inputs/timezone.php | 2 +- templates/input/quantities.php | 6 +- templates/render-fields.php | 13 +- templates/v10/image-modals.php | 2 +- 80 files changed, 442 insertions(+), 41159 deletions(-) delete mode 100644 languages/woocommerce-product-addon-da_DK.mo delete mode 100644 languages/woocommerce-product-addon-da_DK.po delete mode 100644 languages/woocommerce-product-addon-de_DE.mo delete mode 100644 languages/woocommerce-product-addon-de_DE.po delete mode 100644 languages/woocommerce-product-addon-es_ES.mo delete mode 100644 languages/woocommerce-product-addon-es_ES.po delete mode 100644 languages/woocommerce-product-addon-fr_FR.mo delete mode 100644 languages/woocommerce-product-addon-fr_FR.po delete mode 100644 languages/woocommerce-product-addon-it_IT.mo delete mode 100644 languages/woocommerce-product-addon-it_IT.po delete mode 100644 languages/woocommerce-product-addon-nl_BE.mo delete mode 100644 languages/woocommerce-product-addon-nl_BE.po delete mode 100644 languages/woocommerce-product-addon-nl_NL.mo delete mode 100644 languages/woocommerce-product-addon-nl_NL.po delete mode 100644 languages/woocommerce-product-addon-sv_SE.mo delete mode 100644 languages/woocommerce-product-addon-sv_SE.po delete mode 100644 languages/woocommerce-product-addon-tr_TR.mo delete mode 100644 languages/woocommerce-product-addon-tr_TR.po delete mode 100644 languages/woocommerce-product-addon-zh_CN.mo delete mode 100644 languages/woocommerce-product-addon-zh_CN.po delete mode 100644 languages/woocommerce-product-addon.mo delete mode 100644 languages/woocommerce-product-addon.po diff --git a/backend/options.php b/backend/options.php index f9878f92..38e1e21c 100644 --- a/backend/options.php +++ b/backend/options.php @@ -487,7 +487,7 @@ function ppom_load_pro_options() { 'ppom-enf-btn-class' => array( 'type' => 'text', 'title' => __( 'Button Class', 'woocommerce-product-addon' ), - 'desc' => __( ' Add custom CSS classes to the enquiry form button, separated by commas.', 'woocommerce-product-addon' ), + 'desc' => __( 'Add custom CSS classes to the enquiry form button, separated by commas.', 'woocommerce-product-addon' ), ), 'ppom-enf-btn-text-color' => array( 'type' => 'color', diff --git a/backend/templates/admin-settings.php b/backend/templates/admin-settings.php index 7c15c818..849a8ca0 100644 --- a/backend/templates/admin-settings.php +++ b/backend/templates/admin-settings.php @@ -99,7 +99,16 @@ class="nmsf-label ">

- ', esc_url( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), '' ); ?> + %s', + esc_url( tsdk_translate_link( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), + __( 'Upgrade to the Pro', 'woocommerce-product-addon' ) + ) + ); ?>

@@ -142,7 +151,16 @@ class=""

- ', esc_url( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), '' ); ?> + %s', + esc_url( tsdk_translate_link( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), + __( 'Upgrade to the Pro', 'woocommerce-product-addon' ) + ) + ); ?>

diff --git a/classes/admin.class.php b/classes/admin.class.php index c8e99934..0eb2e6b4 100644 --- a/classes/admin.class.php +++ b/classes/admin.class.php @@ -150,7 +150,7 @@ function add_menu_pages() { $menu = add_submenu_page( $page ['parent_slug'], - __( $page ['page_title'], 'woocommerce-product-addon' ), + $page ['page_title'], __( 'PPOM Fields', 'woocommerce-product-addon' ), $cap, $page ['slug'], @@ -165,7 +165,7 @@ function add_menu_pages() { $cap = 'ppom_options_page'; // Menu page for roles set by PPOM Permission Settings $menu = add_menu_page( - __( $page ['page_title'], 'woocommerce-product-addon' ), + $page ['page_title'], __( 'PPOM Fields', 'woocommerce-product-addon' ), $cap, $page ['slug'], @@ -239,14 +239,14 @@ function product_meta() { // existing meta group tables show only ppom main page if ( $action != 'new' && $do_meta != 'edit' && $view != 'addons' && $view != 'changelog' ) { ppom_load_template( 'admin/existing-meta.php' ); - + // NOTE: Allow only for Tier 1 Plan or lower if license is present. $should_load_banner = NM_PersonalizedProduct::LICENSE_PLAN_1 >= NM_PersonalizedProduct::get_license_category( intval( apply_filters( 'product_ppom_license_plan', 0 ) ) ); - + if ( $should_load_banner ) { do_action( 'themeisle_sdk_load_banner', 'ppom' ); } - + } echo ''; @@ -270,7 +270,17 @@ function get_products() { $ppom_id = intval( $_GET['ppom_id'] ); $license_status = apply_filters( 'product_ppom_license_status', '' ); $current_saved_value = $this->get_db_field( $ppom_id ); - $pro_multiple_fields = ! ppom_pro_is_installed() || 'valid' !== $license_status ? '
' . sprintf( __( 'Your current plan supports adding one group of fields per product. To add multiple groups to the same product, please %supgrade%s your plan!', 'woocommerce-product-addon' ), '', '' ) . '' : ''; + $pro_multiple_fields = ! ppom_pro_is_installed() || 'valid' !== $license_status + ? '
' . sprintf( + // translators: %1$s: the link to the store with label 'upgrade'. + __( 'Your current plan supports adding one group of fields per product. To add multiple groups to the same product, please %1$s your plan!', 'woocommerce-product-addon' ), + sprintf( + '%2$s', + esc_url( tsdk_utmify( tsdk_translate_link( PPOM_UPGRADE_URL ), 'multiple-fields' ) ), + __( 'Upgrade to the Pro', 'woocommerce-product-addon' ) + ) + ) . '' + : ''; $select_products_id_component = ( new \PPOM\Attach\SelectComponent() ) ->set_id( 'attach-to-products' ) ->set_title( __( 'Display on Specific Products', 'woocommerce-product-addon' ) ) @@ -477,7 +487,7 @@ public function get_wc_categories( $current_values ) { * Retrieves WooCommerce product tags and checks if they are used in the current values. * * @param array $current_values The current values to check against. - * + * * @return array An array containing the options of product tags and a flag indicating if any category is used. */ function get_wc_tags( $current_values ) { @@ -635,7 +645,13 @@ function ppom_attach_ppoms() { self::save_categories_and_tags( $ppom_id, $categories_to_attach, $tags_to_attach ); $response = array( - 'message' => "PPOM updated for {$updated_products} Products, {$updated_cat} Categories and {$updated_tags} Tags.", + 'message' => sprintf( + // translators: %1$d: number of products, %2$d: number of categories, %3$d: number of tags. + __('PPOM updated for %1$d Products, %2$d Categories and %3$d Tags.', 'woocommerce-product-addon'), + $updated_products, + $updated_cat, + $updated_tags + ), 'status' => 'success', ); @@ -680,10 +696,8 @@ function validate_plugin() { echo '
'; echo '

' . __( 'Provide API key below:', 'woocommerce-product-addon' ) . '

'; - echo '

' . __( 'If you don\'t know your API key, please login into your: Member area', 'woocommerce-product-addon' ) . '

'; - echo '
'; - echo '


'; + echo '


'; wp_nonce_field(); echo '

'; echo '

'; @@ -873,7 +887,7 @@ public function ppom_create_db_tables() { ) { return; } - + NM_PersonalizedProduct::activate_plugin(); } } diff --git a/classes/attach-popup/container-view.class.php b/classes/attach-popup/container-view.class.php index 54bf2b61..eea5e2e2 100644 --- a/classes/attach-popup/container-view.class.php +++ b/classes/attach-popup/container-view.class.php @@ -12,7 +12,7 @@ class ContainerView { * @return string */ public function render() { - return 'Empty!'; + return ''; } /** diff --git a/classes/fields.class.php b/classes/fields.class.php index 434b6bf4..e2ae3f1c 100644 --- a/classes/fields.class.php +++ b/classes/fields.class.php @@ -170,7 +170,7 @@ function load_script( $hook ) { 'bulkActionsLabel'=>esc_html__( 'Bulk Actions', 'woocommerce-product-addon' ), 'deleteLabel'=>esc_html__( 'Delete', 'woocommerce-product-addon' ), 'exportLabel'=>esc_html__( 'Export', 'woocommerce-product-addon' ), - 'exportLockedLabel'=>esc_html__( 'Export (PRO)', 'woocommerce-product-addon' ), + 'exportLockedLabel'=> esc_html__( 'Export', 'woocommerce-product-addon' ) . ' (' . esc_html__( 'PRO', 'woocommerce-product-addon' ) . ')', 'importLabel'=>esc_html__( 'Import Field Groups ', 'woocommerce-product-addon' ), 'freemiumCFRContent' => \PPOM_Freemium::get_instance()->get_freemium_cfr_content(), 'freemiumCFRTab' => \PPOM_Freemium::TAB_KEY_FREEMIUM_CFR, @@ -181,7 +181,20 @@ function load_script( $hook ) { 'finishTitle' => __( 'Done', 'woocommerce-product-addon' ), 'errorTitle' => __( 'Error', 'woocommerce-product-addon' ), 'checkFieldTitle' => __( 'Please at least check one field!', 'woocommerce-product-addon' ), - ] + + ], + 'errorOccurred' => __( 'An error occurred. Please try again.', 'woocommerce-product-addon' ), + 'yes' => __( 'Yes', 'woocommerce-product-addon' ), + 'no' => __( 'No', 'woocommerce-product-addon' ), + 'updatedField' => __( 'Update Field', 'woocommerce-product-addon' ), + 'pricePlaceholder' => __( 'Price (fix or %)', 'woocommerce-product-addon' ), + 'choseFile' => __( 'Choose File', 'woocommerce-product-addon' ), + 'upload' => __( 'Upload', 'woocommerce-product-addon' ), + 'stock' => __( 'Stock', 'woocommerce-product-addon' ), + 'metaIds' => __( 'Meta IDs', 'woocommerce-product-addon' ), + 'cannotRemoveMoreOption' => __( 'Cannot Remove More Option', 'woocommerce-product-addon' ), + 'dataNameRequired' => __( 'Data Name must be required', 'woocommerce-product-addon' ), + 'dataNameExists' => __( 'Data Name already exists', 'woocommerce-product-addon' ) ] ); @@ -210,7 +223,7 @@ function render_field_settings() { // new model $html .= '
'; $html .= '
'; - $html .= '

' . sprintf( __( '%s', 'woocommerce-product-addon' ), $field_title ) . '

'; + $html .= '

' . esc_html( $field_title ) . '

'; $html .= '
'; $html .= '
'; @@ -298,11 +311,11 @@ function render_field_meta( $field_meta, $fields_type, $field_index = '', $save_ $html .= '
'; $html .= '
'; - $html .= '