diff --git a/classes/fields.class.php b/classes/fields.class.php index 80e68ef1..c40072ce 100644 --- a/classes/fields.class.php +++ b/classes/fields.class.php @@ -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' ) ] ); diff --git a/js/admin/ppom-admin.js b/js/admin/ppom-admin.js index 61248b12..ce0844bc 100644 --- a/js/admin/ppom-admin.js +++ b/js/admin/ppom-admin.js @@ -1,4 +1,4 @@ -// @ts-check +/* global ppom_vars */ "use strict"; const FIELD_COMPATIBLE_WITH_SELECT_OPTIONS = [ 'select', 'radio', 'switcher', 'image', 'conditional_meta' ]; @@ -166,7 +166,9 @@ jQuery(function($) { } }) .catch(() => { - jQuery(".ppom-meta-save-notice").html("An error occurred. Please try again.").css({ 'background-color': '#ee8b94', 'padding': '8px', 'border-left': '5px solid #c00' }); + jQuery(".ppom-meta-save-notice") + .html( ppom_vars.i18n.errorOccurred ) + .css({ 'background-color': '#ee8b94', 'padding': '8px', 'border-left': '5px solid #c00' }); }); }); @@ -334,10 +336,10 @@ jQuery(function($) { // console.log(field_title); if (required == true) { - var _ok = 'Yes'; + var _ok = ppom_vars.i18n.yes; } else { - _ok = 'No'; + _ok = ppom_vars.i18n.no; } if (placeholder == null) { placeholder = '-'; @@ -387,7 +389,7 @@ jQuery(function($) { }); $(this).removeClass('ppom-add-field').addClass('ppom-update-field'); - $(this).html('Update Field'); + $(this).html( ppom_vars.i18n.updatedField ); }); @@ -415,10 +417,10 @@ jQuery(function($) { var type = $(this).attr('data-field-type'); if (required == true) { - var _ok = 'Yes'; + var _ok = ppom_vars.i18n.yes; } else { - _ok = 'No'; + _ok = ppom_vars.i18n.no; } var row = $('.ppom_field_table tbody').find('.row_no_' + id); @@ -723,7 +725,7 @@ jQuery(function($) { var option_index = parseInt($uploaded_image_container.find('#ppom-meta-opt-index').val()); var main_wrapper = $(this).closest('.ppom-slider'); var field_index = main_wrapper.find('.ppom-fields-actions').attr('data-field-no'); - var price_placeholder = 'Price (fix or %)'; + var price_placeholder = ppom_vars.i18n.pricePlaceholder; var wp_media_type = 'image'; if (meta_type == 'audio') { @@ -732,12 +734,12 @@ jQuery(function($) { var button = $(this), custom_uploader = wp.media({ - title: 'Choose File', + title: ppom_vars.i18n.choseFile, library: { type: wp_media_type }, button: { - text: 'Upload' + text: ppom_vars.i18n.upload }, multiple: true }).on('select', function() { @@ -762,7 +764,7 @@ jQuery(function($) { var price_metatype = 'price'; var stock_metatype = 'stock'; - var stock_placeholder = 'Stock'; + var stock_placeholder = ppom_vars.i18n.stock; // Set name key for imageselect addon if (meta_type == 'imageselect') { @@ -780,7 +782,7 @@ jQuery(function($) { meta_type = 'images'; var class_name = 'data-options ui-sortable-handle'; var condidtion_attr = 'image_options'; - price_placeholder = 'Meta IDs'; + price_placeholder = ppom_vars.i18n.metaIds; price_metatype = 'meta_id'; } else { @@ -834,7 +836,7 @@ jQuery(function($) { $uploaded_image_container.find('#ppom-meta-opt-index').val(option_index + 1); var main_wrapper = $(this).closest('.ppom-slider'); var field_index = main_wrapper.find('.ppom-fields-actions').attr('data-field-no'); - var price_placeholder = 'Price (fix or %)'; + var price_placeholder = ppom_vars.i18n.pricePlaceholder; wp.media.editor.send.attachment = function(props, attachment) { // console.log(attachment); var existing_images; @@ -850,7 +852,7 @@ jQuery(function($) { var price_metatype = 'price'; var stock_metatype = 'stock'; - var stock_placeholder = 'Stock'; + var stock_placeholder = ppom_vars.i18n.stock; // Set name key for imageselect addon if (meta_type == 'imageselect') { @@ -868,7 +870,7 @@ jQuery(function($) { meta_type = 'images'; var class_name = 'data-options ui-sortable-handle'; var condidtion_attr = 'image_options'; - price_placeholder = 'Meta IDs'; + price_placeholder = ppom_vars.i18n.metaIds; price_metatype = 'meta_id'; } else { @@ -1025,7 +1027,7 @@ jQuery(function($) { $(this).parents('.data-options:first').remove(); } else { - alert('Cannot Remove More Option'); + alert( ppom_vars.i18n.cannotRemoveMoreOption ); } e.preventDefault(); @@ -1126,10 +1128,10 @@ jQuery(function($) { return metaFieldId; }).get(); if (data_name == '') { - var msg = 'Data Name must be required'; + var msg = ppom_vars.i18n.dataNameRequired; var is_ok = false; } else if (('new'===context || ( 'update'===context && savedDataName !== data_name ) ) && $.inArray(data_name, allDataName) != -1) { - var msg = 'Data Name already exists'; + var msg = ppom_vars.i18n.dataNameExists; var is_ok = false; } else { diff --git a/templates/admin/existing-meta.php b/templates/admin/existing-meta.php index 21838571..c309abd9 100644 --- a/templates/admin/existing-meta.php +++ b/templates/admin/existing-meta.php @@ -133,6 +133,8 @@ class="button">

- + + + diff --git a/templates/frontend/component/image/image-modals.php b/templates/frontend/component/image/image-modals.php index 8e1b7cb5..31dd1fe2 100644 --- a/templates/frontend/component/image/image-modals.php +++ b/templates/frontend/component/image/image-modals.php @@ -27,7 +27,7 @@ diff --git a/templates/v10/image-modals.php b/templates/v10/image-modals.php index b5eecd43..64a4613c 100644 --- a/templates/v10/image-modals.php +++ b/templates/v10/image-modals.php @@ -17,7 +17,7 @@