Skip to content

Commit

Permalink
chore: more strings handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Nov 14, 2024
1 parent 214792d commit d8d1d7f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
15 changes: 14 additions & 1 deletion classes/fields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
]
);

Expand Down
38 changes: 20 additions & 18 deletions js/admin/ppom-admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
/* global ppom_vars */
"use strict";

const FIELD_COMPATIBLE_WITH_SELECT_OPTIONS = [ 'select', 'radio', 'switcher', 'image', 'conditional_meta' ];
Expand Down Expand Up @@ -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' });
});
});

Expand Down Expand Up @@ -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 = '-';
Expand Down Expand Up @@ -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 );

});

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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') {
Expand All @@ -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() {
Expand All @@ -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') {
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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') {
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion templates/admin/existing-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class="button">
<p>
<?php esc_html_e( 'We\'re sorry, importing fields is not available on your plan. Please upgrade to the Pro plan to unlock all these features and enhance your product fields management capabilities.', 'woocommerce-product-addon' ); ?>
</p>
<a class="btn btn-success" href="<?php echo esc_url( tsdk_utmify( tsdk_translate_link( PPOM_UPGRADE_URL ), 'lockedimport' ) ); ?>" target="_blank"><?php esc_html_e( 'Upgrade to PRO', 'woocommerce-product-addon' ); ?></a>
<a class="btn btn-success" href="<?php echo esc_url( tsdk_utmify( tsdk_translate_link( PPOM_UPGRADE_URL ), 'lockedimport' ) ); ?>" target="_blank">
<?php esc_html_e( 'Upgrade to PRO', 'woocommerce-product-addon' ); ?>
</a>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/frontend/component/image/image-modals.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<img src="<?php echo esc_url( $image_full ); ?>">
</div>
<footer class="ppom-popup-footer">
<a href="#" class="ppom-popup-button ppom-popup-close-js">Close</a>
<a href="#" class="ppom-popup-button ppom-popup-close-js"><?php esc_html_e( 'Close', 'woocommerce-product-addon'); ?></a>
</footer>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/v10/image-modals.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<img src="<?php echo esc_url( $image_full ); ?>">
</div>
<footer class="ppom-popup-footer">
<a href="#" class="ppom-popup-button ppom-popup-close-js">Close</a>
<a href="#" class="ppom-popup-button ppom-popup-close-js"><?php esc_html_e( 'Close', 'woocommerce-product-addon'); ?></a>
</footer>
</div>
</div>

0 comments on commit d8d1d7f

Please sign in to comment.