Use the plugin's slug as the textdomain

This commit is contained in:
Marco Castelluccio 2016-03-04 16:08:17 +00:00
Родитель 69cb0edcd4
Коммит 9364708532
1 изменённых файлов: 23 добавлений и 23 удалений

Просмотреть файл

@ -1,6 +1,6 @@
<?php
load_plugin_textdomain('wpswcache', false, dirname(plugin_basename(__FILE__)).'/lang');
load_plugin_textdomain('service-worker-cache', false, dirname(plugin_basename(__FILE__)).'/lang');
class SW_Cache_Admin {
private static $instance;
@ -49,16 +49,16 @@ class SW_Cache_Admin {
public function on_admin_notices() {
if(get_option('wp_sw_cache_enabled') && !count(get_option('wp_sw_cache_files'))) {
echo '<div class="update-nag"><p>', sprintf(__('Service Worker is enabled but no files have been selected for caching. To take full advantage of this plugin, <a href="%s">please select files to cache</a>.', 'swpswcache'), admin_url('options-general.php?page=wp-sw-cache-options')),'</p></div>';
echo '<div class="update-nag"><p>', sprintf(__('Service Worker is enabled but no files have been selected for caching. To take full advantage of this plugin, <a href="%s">please select files to cache</a>.', 'service-worker-cache'), admin_url('options-general.php?page=wp-sw-cache-options')),'</p></div>';
}
if(get_option('wp_sw_cache_enabled') && ($_SERVER['REQUEST_SCHEME'] != 'https' && strrpos(strtolower($_SERVER['HTTP_HOST']), 'localhost', -strlen($_SERVER['HTTP_HOST']) === false))) {
echo '<div class="update-nag"><p>', __('The ServiceWorker API requires a secure origin (HTTPS or localhost). Your Service Worker may not work.', 'swpswcache'), '</p></div>';
echo '<div class="update-nag"><p>', __('The ServiceWorker API requires a secure origin (HTTPS or localhost). Your Service Worker may not work.', 'service-worker-cache'), '</p></div>';
}
}
public function on_admin_menu() {
add_options_page(__('WP SW Cache', 'wpswcache'), __('WP SW Cache', 'wpswcache'), 'manage_options', 'wp-sw-cache-options', array($this, 'options'));
add_options_page(__('WP SW Cache', 'service-worker-cache'), __('WP SW Cache', 'service-worker-cache'), 'manage_options', 'wp-sw-cache-options', array($this, 'options'));
}
public function on_switch_theme() {
@ -70,14 +70,14 @@ class SW_Cache_Admin {
}
function show_switch_theme_message() {
echo '<div class="update-nag"><p>', sprintf(__('You\'ve changed themes; please update your <a href="%s">WP ServiceWorker Cache options</a>.', 'swpswcache'), admin_url('options-general.php?page=wp-sw-cache-options')), '</p></div>';
echo '<div class="update-nag"><p>', sprintf(__('You\'ve changed themes; please update your <a href="%s">WP ServiceWorker Cache options</a>.', 'service-worker-cache'), admin_url('options-general.php?page=wp-sw-cache-options')), '</p></div>';
}
function determine_file_recommendation($file_info, $all_files) {
if(SW_Cache_Recommender::has_min_file($file_info['name'], $all_files)) {
return array(
'verdict' => false,
'message' => __('A matching minified file was found, deferring to minified asset.', 'wpswcache')
'message' => __('A matching minified file was found, deferring to minified asset.', 'service-worker-cache')
);
}
@ -85,7 +85,7 @@ class SW_Cache_Admin {
if($file_info['name'] === 'style.css') {
return array(
'verdict' => true,
'message' => sprintf(__('%s is a standard WordPress theme file. __('.$regex.')__', 'wpswcache'), 'style.css')
'message' => sprintf(__('%s is a standard WordPress theme file. __('.$regex.')__', 'service-worker-cache'), 'style.css')
);
}
@ -96,7 +96,7 @@ class SW_Cache_Admin {
)) {
return array(
'verdict' => false,
'message' => sprintf(__('%s is a standard WordPress theme file only used in admin.', 'wpswcache'), $file_info['name'])
'message' => sprintf(__('%s is a standard WordPress theme file only used in admin.', 'service-worker-cache'), $file_info['name'])
);
}
@ -107,7 +107,7 @@ class SW_Cache_Admin {
)) {
return array(
'verdict' => false,
'message' => sprintf(__('%s is likely for legacy Internet Explorer browsers.', 'wpswcache'), $file_info['name'])
'message' => sprintf(__('%s is likely for legacy Internet Explorer browsers.', 'service-worker-cache'), $file_info['name'])
);
}
@ -116,7 +116,7 @@ class SW_Cache_Admin {
if(SW_Cache_Recommender::matches_any_regex($file_info['name'], array('/\.woff2?$/'))) {
return array(
'verdict' => true,
'message' => sprintf(__('woff2 is high performing and woff is a globally supported fallback', 'wpswcache'), $file_info['name'])
'message' => sprintf(__('woff2 is high performing and woff is a globally supported fallback', 'service-worker-cache'), $file_info['name'])
);
}
@ -124,7 +124,7 @@ class SW_Cache_Admin {
if(in_array($file_info['category'], array('css', 'js', 'image')) && substr_count($file_info['name'], '/') < 2) {
return array(
'verdict' => true,
'message' => __('Main or secondary level assets are likely important in most themes', 'wpswcache')
'message' => __('Main or secondary level assets are likely important in most themes', 'service-worker-cache')
);
}
@ -150,32 +150,32 @@ class SW_Cache_Admin {
</div>
<?php } ?>
<h1><?php _e('WordPress Service Worker Cache', 'wpswcache'); ?></h1>
<h1><?php _e('WordPress Service Worker Cache', 'service-worker-cache'); ?></h1>
<p><?php _e('WordPress Service Worker Cache is a utility that harnesses the power of the <a href="https://serviceworke.rs" target="_blank">ServiceWorker API</a> to cache frequently used assets for the purposes of performance and offline viewing.'); ?></p>
<form method="post" action="">
<input type="hidden" name="wpswcache_form_submitted" value="1">
<h2><?php _e('ServiceWorker Cache Settings', 'wpswcache'); ?></h2>
<h2><?php _e('ServiceWorker Cache Settings', 'service-worker-cache'); ?></h2>
<table class="form-table">
<tr>
<th scope="row"><label for="wp_sw_cache_enabled"><?php _e('Enable Service Worker', 'wpswcache'); ?></label></th>
<th scope="row"><label for="wp_sw_cache_enabled"><?php _e('Enable Service Worker', 'service-worker-cache'); ?></label></th>
<td>
<input type="checkbox" name="wp_sw_cache_enabled" id="wp_sw_cache_enabled" value="1" <?php if(intval(get_option('wp_sw_cache_enabled'))) echo 'checked'; ?> autofocus />
</td>
</tr>
<tr>
<th scope="row"><label for="wp_sw_cache_debug"><?php _e('Enable Debug Messages', 'wpswcache'); ?></label></th>
<th scope="row"><label for="wp_sw_cache_debug"><?php _e('Enable Debug Messages', 'service-worker-cache'); ?></label></th>
<td>
<input type="checkbox" name="wp_sw_cache_debug" id="wp_sw_cache_debug" value="1" <?php if(intval(get_option('wp_sw_cache_debug'))) echo 'checked'; ?> />
</td>
</tr>
</table>
<h2><?php _e('Theme Files to Cache', 'wpswcache'); ?> (<code><?php echo get_template(); ?></code>)</h2>
<h2><?php _e('Theme Files to Cache', 'service-worker-cache'); ?> (<code><?php echo get_template(); ?></code>)</h2>
<p>
<?php _e('Select theme assets (typically JavaScript, CSS, fonts, and image files) that are used on a majority of pages.', 'wpswcache'); ?>
<?php _e('Select theme assets (typically JavaScript, CSS, fonts, and image files) that are used on a majority of pages.', 'service-worker-cache'); ?>
<button type="button" class="button button-primary wp-sw-cache-toggle-all"><?php _e('Select All Files'); ?></button>
<button type="button" class="button button-primary wp-sw-cache-clear-all"><?php _e('Clear All Files'); ?></button>
<button type="button" class="button button-primary wp-sw-cache-suggest-file" data-suggested-text="<?php echo esc_attr__('Files Suggested: '); ?>"><?php _e('Suggest Files'); ?> <span>(<?php _e('beta'); ?>)</span></button>
@ -187,11 +187,11 @@ class SW_Cache_Admin {
$theme_files = wp_get_theme()->get_files(null, 10); // 10 is arbitrary
$categories = array(
array('key' => 'css', 'title' => __('CSS Files', 'wpswcache'), 'extensions' => array('css'), 'files' => array()),
array('key' => 'js', 'title' => __('JavaScript Files', 'wpswcache'), 'extensions' => array('js'), 'files' => array()),
array('key' => 'font', 'title' => __('Font Files', 'wpswcache'), 'extensions' => array('woff', 'woff2', 'ttf', 'eot'), 'files' => array()),
array('key' => 'image', 'title' => __('Image Files', 'wpswcache'), 'extensions' => array('svg', 'jpg', 'jpeg', 'gif', 'png', 'webp'), 'files' => array()),
array('key' => 'other', 'title' => __('Other Files', 'wpswcache'), 'extensions' => array('*'), 'files' => array()) // Needs to be last
array('key' => 'css', 'title' => __('CSS Files', 'service-worker-cache'), 'extensions' => array('css'), 'files' => array()),
array('key' => 'js', 'title' => __('JavaScript Files', 'service-worker-cache'), 'extensions' => array('js'), 'files' => array()),
array('key' => 'font', 'title' => __('Font Files', 'service-worker-cache'), 'extensions' => array('woff', 'woff2', 'ttf', 'eot'), 'files' => array()),
array('key' => 'image', 'title' => __('Image Files', 'service-worker-cache'), 'extensions' => array('svg', 'jpg', 'jpeg', 'gif', 'png', 'webp'), 'files' => array()),
array('key' => 'other', 'title' => __('Other Files', 'service-worker-cache'), 'extensions' => array('*'), 'files' => array()) // Needs to be last
);
// Sort the files and place them in their baskets
@ -257,7 +257,7 @@ class SW_Cache_Admin {
</tr>
<?php } ?>
</table>
<?php } else { ?><p><?php _e('No matching files found.', 'wpswcache'); ?></p><?php } ?>
<?php } else { ?><p><?php _e('No matching files found.', 'service-worker-cache'); ?></p><?php } ?>
<?php } ?>
</div>