| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ); |
| 3 |
|
| 4 |
/** |
| 5 |
* Get all translations we can use with wp_localize_script() |
| 6 |
* |
| 7 |
* @since 1.5 |
| 8 |
* @author Jonathan Buttigieg |
| 9 |
* |
| 10 |
* @param string $context The translation context |
| 11 |
* @return array $translations The translations |
| 12 |
*/ |
| 13 |
function get_imagify_localize_script_translations( $context ) { |
| 14 |
$translations = array(); |
| 15 |
|
| 16 |
switch( $context ) { |
| 17 |
case 'admin': |
| 18 |
$translations = array( |
| 19 |
'labels' => array( |
| 20 |
'signupTitle' => __( 'Let\'s get you started!', 'imagify' ), |
| 21 |
'signupText' => __( 'Enter your email to get an API key:', 'imagify' ), |
| 22 |
'signupConfirmButtonText' => __( 'Sign Up', 'imagify' ), |
| 23 |
'signupErrorEmptyEmail' => __( 'You need to specify an email!', 'imagify' ), |
| 24 |
'signupSuccessTitle' => __( 'Congratulations!', 'imagify' ), |
| 25 |
'signupSuccessText' => __( 'Your account has been succesfully created. Please check your mailbox, you are going to receive an email with API key.', 'imagify' ), |
| 26 |
'saveApiKeyTitle' => __( 'Connect to Imagify!', 'imagify' ), |
| 27 |
'saveApiKeyText' => __( 'Paste your API key below:', 'imagify' ), |
| 28 |
'saveApiKeyConfirmButtonText' => __( 'Connect me', 'imagify' ), |
| 29 |
'waitApiKeyCheckText' => __( 'Check in progress...', 'imagify' ), |
| 30 |
'ApiKeyCheckSuccessTitle' => __( 'Congratulations!', 'imagify' ), |
| 31 |
'ApiKeyCheckSuccessText' => __( 'Your API key is valid. You can now configure the Imagify settings to optimize your images.', 'imagify' ), |
| 32 |
'ValidApiKeyText' => __( 'Your API key is valid.', 'imagify' ), |
| 33 |
'swalCancel' => __( 'Cancel' ) |
| 34 |
) |
| 35 |
); |
| 36 |
break; |
| 37 |
|
| 38 |
case 'options': |
| 39 |
$translations = array( |
| 40 |
'noBackupTitle' => __( 'Don\'t Need a Parachute?', 'imagify' ), |
| 41 |
'noBackupText' => __( 'If you keep this option deactivated, you won\'t be able to re-optimize your images to another compression level and restore your original images in case of need.', 'imagify' ) |
| 42 |
); |
| 43 |
break; |
| 44 |
|
| 45 |
case 'upload': |
| 46 |
$translations = array( |
| 47 |
'bulkActionsLabels' => array( |
| 48 |
'optimize' => __( 'Optimize', 'imagify' ), |
| 49 |
'restore' => __( 'Restore Original', 'imagify' ), |
| 50 |
), |
| 51 |
); |
| 52 |
break; |
| 53 |
|
| 54 |
case 'twentytwenty': |
| 55 |
$translations = array( |
| 56 |
'labels' => array( |
| 57 |
'original_l' => esc_html__( 'Original Image', 'imagify' ), |
| 58 |
'optimized_l' => esc_html__( 'Optimized Image', 'imagify' ), |
| 59 |
'compare' => esc_html__( 'Compare Original VS Optimized', 'imagify' ), |
| 60 |
'close' => esc_html__( 'Close', 'imagify' ), |
| 61 |
'filesize' => esc_html__( 'File Size:', 'imagify' ), |
| 62 |
'saving' => esc_html__( 'Original Saving:', 'imagify' ), |
| 63 |
'optimize' => esc_html__( 'Optimize', 'imagify' ) |
| 64 |
) |
| 65 |
); |
| 66 |
break; |
| 67 |
|
| 68 |
case 'bulk': |
| 69 |
$user = get_imagify_user(); |
| 70 |
$translations = array( |
| 71 |
'labels' => array( |
| 72 |
'waitTitle' => __( 'Please wait...', 'imagify' ), |
| 73 |
'waitText' => __( 'We are trying to get your unoptimized images, it may take time depending on the number of images.', 'imagify' ), |
| 74 |
'waitImageUrl' => IMAGIFY_ASSETS_IMG_URL . 'popin-loader.svg', |
| 75 |
'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ), |
| 76 |
'getUnoptimizedImagesErrorText' => __( 'An unknow error occurred when we tried to get all your unoptimized images. Try again and if the issue still persist, please contact us!', 'imagify' ), |
| 77 |
'invalidAPIKeyTitle' => __( 'Your API key isn\'t valid!', 'imagify' ), |
| 78 |
'overviewChartLabels' => array( |
| 79 |
'optimized' => __( 'Optimized', 'imagify' ), |
| 80 |
'unoptimized' => __( 'Unoptimized', 'imagify' ), |
| 81 |
'error' => __( 'Error', 'imagify' ), |
| 82 |
), |
| 83 |
'overQuotaTitle' => __( 'Oops, It\'s Over!', 'imagify' ), |
| 84 |
'noAttachmentToOptimizeTitle' => __( 'Hold on!', 'imagify' ), |
| 85 |
'noAttachmentToOptimizeText' => __( 'All your images have been optimized by Imagify. Congratulations!', 'imagify' ), |
| 86 |
'pluginURL' => 'https://wordpress.org/plugins/imagify', |
| 87 |
'textToShare' => __( 'Discover @imagify, the new compression tool to optimize your images for free. I saved %1$s out of %2$s!', 'imagify' ), |
| 88 |
'totalOptimizedAttachments' => imagify_count_optimized_attachments(), |
| 89 |
'totalUnoptimizedAttachments' => imagify_count_unoptimized_attachments(), |
| 90 |
'totalErrorsAttachments' => imagify_count_error_attachments(), |
| 91 |
'processing' => __( 'Imagify is still processing. Are you sure you want to leave this page?', 'imagify' ) |
| 92 |
) |
| 93 |
); |
| 94 |
|
| 95 |
if ( imagify_valid_key() ) { |
| 96 |
if ( is_wp_error( $user ) ) { |
| 97 |
$translations['overQuotaText'] = sprintf( __( 'To continue to optimize your images, log in to your Imagify account to %sbuy a pack or subscribe to a plan%s.', 'imagify' ), '<a href="' . IMAGIFY_APP_MAIN . '/#/subscription' . '">', '</a>' ); |
| 98 |
} |
| 99 |
else { |
| 100 |
$translations['overQuotaText'] = sprintf( __( 'You have consumed all your credit for this month. You will have <strong>%s back on %s</strong>.', 'imagify' ), size_format( $user->quota * 1048576 ), date_i18n( __( 'F j, Y' ), strtotime( $user->next_date_update ) ) ) . '<br/><br/>' . sprintf( __( 'To continue to optimize your images, log in to your Imagify account to %sbuy a pack or subscribe to a plan%s.', 'imagify' ), '<a href="' . IMAGIFY_APP_MAIN . '/#/subscription' . '">', '</a>' ); |
| 101 |
} |
| 102 |
} |
| 103 |
break; |
| 104 |
} |
| 105 |
|
| 106 |
return $translations; |
| 107 |
} |