Skip to content

Commit

Permalink
Improve I18N Issues based on 1.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexclassroom authored Jan 17, 2025
1 parent 1c9b006 commit d89a593
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 64 deletions.
46 changes: 25 additions & 21 deletions src/class-jetpack-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,66 @@ public function show_page(): void
<div class="wrap" style="max-width: 820px;">

<?php if (isset($_GET['success']) && $_GET['success'] == 0) { ?>
<div class="notice notice-error is-dismissible"><p>Sorry, something went wrong in trying to retrieve your stats from WordPress.com. Please check whether your API key and blog URL are correct.</p></div>
<div class="notice notice-error is-dismissible"><p><?php esc_html_e( 'Sorry, something went wrong in trying to retrieve your stats from WordPress.com. Please check whether your API key and blog URL are correct.', 'koko-analytics' ); ?></p></div>
<?php } ?>

<?php if (isset($_GET['success']) && $_GET['success'] == 1) { ?>
<div class="notice notice-success is-dismissible"><p>Big success! Your stats are now imported into Koko Analytics.</p></div>
<div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'Big success! Your stats are now imported into Koko Analytics.', 'koko-analytics' ); ?></p></div>
<?php } ?>

<h1>Import analytics from JetPack Stats</h1>
<p>To import your historical analytics data from JetPack Stats into Koko Analytics, provide your WordPress.com API key and blog URL in the field below.</p>
<h1><?php esc_html_e( 'Import analytics from JetPack Stats', 'koko-analytics' ); ?></h1>
<p><?php esc_html_e( 'To import your historical analytics data from JetPack Stats into Koko Analytics, provide your WordPress.com API key and blog URL in the field below.', 'koko-analytics' ); ?></p>

<form method="post" onsubmit="return confirm('Are you sure you want to import statistics between ' + this['date-start'].value + ' and ' +this['date-end'].value + '? This will overwrite any existing data in your Koko Analytics database tables.');" action="<?php echo esc_attr(get_admin_url(null, '/index.php?page=koko-analytics&tab=jetpack_importer')); ?>">
<form method="post" onsubmit="return confirm('<?php esc_attr_e('Are you sure you want to import statistics between', 'koko-analytics'); ?> ' + this['date-start'].value + '<?php esc_attr_e(' and ', 'koko-analytics'); ?>' + this['date-end'].value + '<?php esc_attr_e('? This will overwrite any existing data in your Koko Analytics database tables.', 'koko-analytics'); ?>');" action="<?php echo esc_url(admin_url('index.php?page=koko-analytics&tab=jetpack_importer')); ?>">

<input type="hidden" name="koko_analytics_action" value="start_jetpack_import">
<?php wp_nonce_field('koko_analytics_start_jetpack_import'); ?>

<table class="form-table">
<tr>
<th><label for="wpcom-api-key">WordPress.com API key</label></th>
<th><label for="wpcom-api-key"><?php esc_html_e( 'WordPress.com API key', 'koko-analytics' ); ?></label></th>
<td>
<input id="wpcom-api-key" type="text" class="regular-text" name="wpcom-api-key" required>
<p class="description">You can <a href="https://apikey.wordpress.com/">find your WordPress.com API key here</a>.</p>
<p class="description"><?php printf(esc_html__( 'You can %1$sfind your WordPress.com API key here%2$s.', 'koko-analytics' ),'<a href="https://apikey.wordpress.com/" target="_blank">','</a>'); ?></p>
</td>
</tr>

<tr>
<th><label for="wpcom-blog-uri">Blog URL</label></th>
<th><label for="wpcom-blog-uri"><?php esc_html_e( 'Blog URL', 'koko-analytics' ); ?></label></th>
<td>
<input id="wpcom-blog-uri" type="text" class="regular-text" name="wpcom-blog-uri" value="<?php echo esc_attr(get_site_url()); ?>" required>
<p class="description">The full URL to the root directory of your blog. Including the full path.</p>
<p class="description"><?php esc_html_e( 'The full URL to the root directory of your blog. Including the full path.', 'koko-analytics' ); ?></p>
</td>
</tr>

<tr>
<th><label for="date-start">Start date</label></th>
<th><label for="date-start"><?php esc_html_e( 'Start date', 'koko-analytics' ); ?></label></th>
<td>
<input id="date-start" name="date-start" type="date" value="<?php echo esc_attr(date('Y-m-d', strtotime('-1 year'))); ?>" required>
<p class="description">The earliest date for which to import data. You should probably set this to the date that you installed and activated Jetpack Stats.</p>
<p class="description"><?php esc_html_e( 'The earliest date for which to import data. You should probably set this to the date that you installed and activated Jetpack Stats.', 'koko-analytics' ); ?></p>

</td>
</tr>

<tr>
<th><label for="date-end">End date</label></th>
<th><label for="date-end"><?php esc_html_e( 'End date', 'koko-analytics' ); ?></label></th>
<td>
<input id="date-end" name="date-end" type="date" value="<?php echo esc_attr(date('Y-m-d')); ?>" required>
<p class="description">The last date for which to import data. You should probably set this to just before the date that you installed and activated Koko Analytics.</p>
<p class="description"><?php esc_html_e( 'The last date for which to import data. You should probably set this to just before the date that you installed and activated Koko Analytics.', 'koko-analytics' ); ?></p>

</td>
</tr>
</table>

<p>
<button type="submit" class="button">Import analytics data</button>
<button type="submit" class="button"><?php esc_html_e( 'Import analytics data', 'koko-analytics' ); ?></button>
</p>
</form>

<div class="ka-margin-m">
<h3>Things to know before running the import</h3>
<p>Importing data for a given date range will add to any existing data. The import process can not be reverted unless you reinstate a back-up of your database in its current state.</p>
<p>It's also important to know that JetPack doesn't provide data for the distinct number of visitors, so the data imported will only import the total number of pageviews for each post and therefore differ slightly from data collected by Koko Analytics itself.</p>
<h3><?php esc_html_e( 'Things to know before running the import', 'koko-analytics' ); ?></h3>
<p><?php esc_html_e( 'Importing data for a given date range will add to any existing data. The import process can not be reverted unless you reinstate a back-up of your database in its current state.', 'koko-analytics' ); ?></p>
<p><?php esc_html_e( 'It\'s also important to know that JetPack doesn\'t provide data for the distinct number of visitors, so the data imported will only import the total number of pageviews for each post and therefore differ slightly from data collected by Koko Analytics itself.', 'koko-analytics' ); ?></p>
</div>
</div>
<?php
Expand Down Expand Up @@ -193,10 +193,14 @@ public function import_chunk(): void
?>
<style>body { background: #f0f0f1; color: #3c434a; font-family: sans-serif; font-size: 16px; line-height: 1.5; padding: 32px; }</style>
<meta http-equiv="refresh" content="1; url=<?php echo esc_attr($url); ?>">
<h1>Liberating your data... Please wait.</h1>
<p>Importing stats between <strong><?php echo $chunk_start->format('Y-m-d'); ?></strong> and <strong><?php echo $chunk_end->format('Y-m-d'); ?></strong>.</p>
<p>Please do not close this browser tab while the importer is running.</p>
<p>Estimated time left: <?php echo round($chunks_left * 1.5); ?> seconds.</p>
<h1><?php esc_html_e( 'Liberating your data... Please wait.', 'koko-analytics' ); ?></h1>
<p><?php printf(
__('Importing stats between %1$s and %2$s.', 'koko-analytics'),
'<strong>' . $chunk_start->format('Y-m-d') . '</strong>',
'<strong>' . $chunk_end->format('Y-m-d') . '</strong>'
);?></p>
<p><?php esc_html_e( 'Please do not close this browser tab while the importer is running.', 'koko-analytics' ); ?></p>
<p><?php printf( __( 'Estimated time left: %s seconds.', 'koko-analytics' ), round($chunks_left * 1.5) ); ?></p>
<?php
exit;
}
Expand Down
10 changes: 5 additions & 5 deletions src/class-widget-most-viewed-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public function form($instance)
$post_types = get_post_types([ 'public' => true ], 'objects');
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>" style="display: block;"><?php echo esc_html__('Title:', 'koko-analytics'); ?></label>
<label for="<?php echo $this->get_field_id('title'); ?>" style="display: block;"><?php esc_html_e('Title:', 'koko-analytics'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($settings['title']); ?>" />
</p>

<p>
<label for="<?php echo $this->get_field_id('post_type'); ?>" style="display: block;"><?php echo esc_html__('Post type:', 'koko-analytics'); ?></label>
<label for="<?php echo $this->get_field_id('post_type'); ?>" style="display: block;"><?php esc_html_e('Post type:', 'koko-analytics'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('post_type'); ?>" name="<?php echo $this->get_field_name('post_type'); ?>">
<?php
foreach ($post_types as $post_type) {
Expand All @@ -108,18 +108,18 @@ public function form($instance)
</p>

<p>
<label for="<?php echo $this->get_field_id('days'); ?>" style="display: block;"><?php echo esc_html__('Number of days to use statistics for:', 'koko-analytics'); ?></label>
<label for="<?php echo $this->get_field_id('days'); ?>" style="display: block;"><?php esc_html_e('Number of days to use statistics for:', 'koko-analytics'); ?></label>
<input id="<?php echo $this->get_field_id('days'); ?>" name="<?php echo $this->get_field_name('days'); ?>" type="number" step="1" min="1" max="1975" value="<?php echo esc_attr($settings['days']); ?>" required class="tiny-text" size="3" />
</p>

<p>
<label for="<?php echo $this->get_field_id('number'); ?>" style="display: block;"><?php echo esc_html__('Number of posts to show:', 'koko-analytics'); ?></label>
<label for="<?php echo $this->get_field_id('number'); ?>" style="display: block;"><?php esc_html_e('Number of posts to show:', 'koko-analytics'); ?></label>
<input id="<?php echo $this->get_field_id('number'); ?>" class="tiny-text" name="<?php echo $this->get_field_name('number'); ?>" type="number" step="1" min="1" value="<?php echo esc_attr($settings['number']); ?>" size="3" />
</p>

<p>
<input class="checkbox" type="checkbox" <?php checked($settings['show_date']); ?> id="<?php echo $this->get_field_id('show_date'); ?>" name="<?php echo $this->get_field_name('show_date'); ?>" />
<label for="<?php echo $this->get_field_id('show_date'); ?>"><?php echo esc_html__('Display post date?', 'koko-analytics'); ?></label>
<label for="<?php echo $this->get_field_id('show_date'); ?>"><?php esc_html_e('Display post date?', 'koko-analytics'); ?></label>
</p>
<?php

Expand Down
24 changes: 12 additions & 12 deletions src/views/dashboard-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
} ?>

<div class="ka-datepicker--dropdown-content">
<label for="ka-date-presets"><?php echo esc_html__('Date range', 'koko-analytics'); ?></label>
<label for="ka-date-presets"><?php esc_html_e('Date range', 'koko-analytics'); ?></label>
<select id="ka-date-presets" name="view">
<option value="custom" <?php echo $range === 'custom' ? 'selected' : ''; ?> disabled><?php echo esc_html__('Custom', 'koko-analytics'); ?></option>
<option value="custom" <?php echo $range === 'custom' ? 'selected' : ''; ?> disabled><?php esc_html_e('Custom', 'koko-analytics'); ?></option>
<?php foreach ($this->get_date_presets() as $key => $label) {
?>
<option value="<?php echo $key; ?>"
Expand All @@ -64,13 +64,13 @@
</select>
<div style="display: flex; margin-top: 12px;">
<div>
<label for='ka-date-start'><?php echo esc_html__('Start date', 'koko-analytics'); ?></label>
<label for='ka-date-start'><?php esc_html_e('Start date', 'koko-analytics'); ?></label>
<input name="start_date" id='ka-date-start' type="date" size="10" placeholder="YYYY-MM-DD" min="2000-01-01" max="2100-01-01"
value="<?php echo $dateStart->format('Y-m-d'); ?>">
<span>&nbsp;&mdash;&nbsp;</span>
</div>
<div>
<label for='ka-date-end'><?php echo esc_html__('End date', 'koko-analytics'); ?></label>
<label for='ka-date-end'><?php esc_html_e('End date', 'koko-analytics'); ?></label>
<input name="end_date" id='ka-date-end' type="date" size="10" placeholder="YYYY-MM-DD" min="2000-01-01" max="2100-01-01"
value="<?php echo $dateEnd->format('Y-m-d'); ?>">
</div>
Expand Down Expand Up @@ -103,7 +103,7 @@
$change = $totals_previous->visitors == 0 ? 0 : ($totals->visitors / $totals_previous->visitors) - 1;
?>
<tr class="<?php echo $diff > 0 ? 'ka-up' : ''; ?> <?php echo $diff < 0 ? 'ka-down' : ''; ?>">
<th><?php echo esc_html__('Total visitors', 'koko-analytics'); ?></th>
<th><?php esc_html_e('Total visitors', 'koko-analytics'); ?></th>
<td class='ka-totals--amount'>
<span title="<?php echo esc_attr($totals->visitors); ?>"><?php echo number_format_i18n($totals->visitors); ?></span>
<span class="ka-totals--change">
Expand All @@ -130,7 +130,7 @@
$change = $totals_previous->pageviews == 0 ? 0 : ($totals->pageviews / $totals_previous->pageviews) - 1;
?>
<tr class="<?php echo $diff > 0 ? 'ka-up' : ''; ?> <?php echo $diff < 0 ? 'ka-down' : ''; ?>">
<th><?php echo esc_html__('Total pageviews', 'koko-analytics'); ?></th>
<th><?php esc_html_e('Total pageviews', 'koko-analytics'); ?></th>
<td class='ka-totals--amount'>
<span title="<?php echo esc_attr($totals->pageviews); ?>"><?php echo number_format_i18n($totals->pageviews); ?></span>
<span class="ka-totals--change">
Expand All @@ -152,10 +152,10 @@
</td>
</tr>
<tr id="ka-realtime">
<th><?php echo esc_html__('Realtime pageviews', 'koko-analytics'); ?></th>
<th><?php esc_html_e('Realtime pageviews', 'koko-analytics'); ?></th>
<td class='ka-totals--amount'><?php echo number_format_i18n($realtime); ?></td>
<td class='ka-totals--subtext'>
<?php echo esc_html__('pageviews in the last hour', 'koko-analytics'); ?>
<?php esc_html_e('pageviews in the last hour', 'koko-analytics'); ?>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -203,10 +203,10 @@
<?php if ($posts_offset >= $posts_limit || $posts_offset + $posts_limit < $posts_count) { ?>
<div class='ka-pagination'>
<?php if ($posts_offset >= $posts_limit) { ?>
<a class='ka-pagination--prev' href="<?php echo esc_attr(add_query_arg(['posts' => [ 'offset' => $posts_offset - $posts_limit, 'limit' => $posts_limit ]])); ?>"><?php echo esc_html__('Previous', 'koko-analytics'); ?></a>
<a class='ka-pagination--prev' href="<?php echo esc_attr(add_query_arg(['posts' => [ 'offset' => $posts_offset - $posts_limit, 'limit' => $posts_limit ]])); ?>"><?php esc_html_e('Previous', 'koko-analytics'); ?></a>
<?php } ?>
<?php if ($posts_offset + $posts_limit < $posts_count) { ?>
<a class='ka-pagination--next' href="<?php echo esc_attr(add_query_arg(['posts' => [ 'offset' => $posts_offset + $posts_limit, 'limit' => $posts_limit ]])); ?>"><?php echo esc_html__('Next', 'koko-analytics'); ?></a>
<a class='ka-pagination--next' href="<?php echo esc_attr(add_query_arg(['posts' => [ 'offset' => $posts_offset + $posts_limit, 'limit' => $posts_limit ]])); ?>"><?php esc_html_e('Next', 'koko-analytics'); ?></a>
<?php } ?>
</div>
<?php } ?>
Expand Down Expand Up @@ -244,10 +244,10 @@
<?php if ($referrers_offset >= $referrers_limit || $referrers_offset + $referrers_limit < $referrers_count) { ?>
<div class='ka-pagination'>
<?php if ($referrers_offset >= $referrers_limit) { ?>
<a class='ka-pagination--prev' href="<?php echo esc_attr(add_query_arg(['referrers' => [ 'offset' => $referrers_offset - $referrers_limit, 'limit' => $referrers_limit ]])); ?>"><?php echo esc_html__('Previous', 'koko-analytics'); ?></a>
<a class='ka-pagination--prev' href="<?php echo esc_attr(add_query_arg(['referrers' => [ 'offset' => $referrers_offset - $referrers_limit, 'limit' => $referrers_limit ]])); ?>"><?php esc_html_e('Previous', 'koko-analytics'); ?></a>
<?php } ?>
<?php if ($referrers_offset + $referrers_limit < $referrers_count) { ?>
<a class='ka-pagination--next' href="<?php echo esc_attr(add_query_arg(['referrers' => [ 'offset' => $referrers_offset + $referrers_limit, 'limit' => $referrers_limit ]])); ?>"><?php echo esc_html__('Next', 'koko-analytics'); ?></a>
<a class='ka-pagination--next' href="<?php echo esc_attr(add_query_arg(['referrers' => [ 'offset' => $referrers_offset + $referrers_limit, 'limit' => $referrers_limit ]])); ?>"><?php esc_html_e('Next', 'koko-analytics'); ?></a>
<?php } ?>
</div>
<?php } ?>
Expand Down
Loading

0 comments on commit d89a593

Please sign in to comment.