1
0
mirror of https://github.com/dwaxweiler/connector-mobilizon synced 2025-02-17 20:21:05 +01:00

improve translatability

This commit is contained in:
Daniel Waxweiler 2021-05-06 09:22:13 +02:00
parent a3a980d6db
commit 2d2b1b9293
8 changed files with 13 additions and 17 deletions

View File

@ -6,6 +6,7 @@
#### Deprecated #### Deprecated
#### Removed #### Removed
#### Fixed #### Fixed
- Improve translatability
#### Security #### Security
### [0.4.0] - 2021-04-20 ### [0.4.0] - 2021-04-20

View File

@ -9,4 +9,3 @@ if (!defined('ABSPATH')) {
const DEFAULT_EVENTS_COUNT = 5; const DEFAULT_EVENTS_COUNT = 5;
const NAME = '<wordpress-name>'; const NAME = '<wordpress-name>';
const NICE_NAME = '<wordpress-nice-name>'; const NICE_NAME = '<wordpress-nice-name>';
const TEXT_DOMAIN = '<wordpress-name>';

View File

@ -29,7 +29,6 @@ class EventsListShortcut {
$locale = str_replace('_', '-', get_locale()); $locale = str_replace('_', '-', get_locale());
$groupName = $atts_with_overriden_defaults['group-name']; $groupName = $atts_with_overriden_defaults['group-name'];
$url = Settings::getUrl(); $url = Settings::getUrl();
$textDomain = TEXT_DOMAIN;
$timeZone = get_option('timezone_string'); $timeZone = get_option('timezone_string');
ob_start(); ob_start();

View File

@ -11,9 +11,9 @@ class EventsListWidget extends \WP_Widget {
public function __construct() { public function __construct() {
parent::__construct( parent::__construct(
NAME . '-events-list', NAME . '-events-list',
NICE_NAME . ' ' . esc_html__('Events List', TEXT_DOMAIN), NICE_NAME . ' ' . __('Events List', 'connector-mobilizon'),
array( array(
'description' => __('A list of the upcoming events of the connected Mobilizon instance.', TEXT_DOMAIN), 'description' => __('A list of the upcoming events of the connected Mobilizon instance.', 'connector-mobilizon'),
), ),
); );
} }
@ -30,7 +30,6 @@ class EventsListWidget extends \WP_Widget {
$locale = str_replace('_', '-', get_locale()); $locale = str_replace('_', '-', get_locale());
$groupName = isset($options['groupName']) ? $options['groupName'] : ''; $groupName = isset($options['groupName']) ? $options['groupName'] : '';
$url = Settings::getUrl(); $url = Settings::getUrl();
$textDomain = TEXT_DOMAIN;
$timeZone = get_option('timezone_string'); $timeZone = get_option('timezone_string');
require dirname(__DIR__) . '/view/events-list.php'; require dirname(__DIR__) . '/view/events-list.php';
@ -39,10 +38,9 @@ class EventsListWidget extends \WP_Widget {
} }
public function form($options) { public function form($options) {
$title = !empty($options['title']) ? $options['title'] : esc_html__('Events', TEXT_DOMAIN); $title = !empty($options['title']) ? $options['title'] : __('Events', 'connector-mobilizon');
$eventsCount = !empty($options['eventsCount']) ? $options['eventsCount'] : DEFAULT_EVENTS_COUNT; $eventsCount = !empty($options['eventsCount']) ? $options['eventsCount'] : DEFAULT_EVENTS_COUNT;
$groupName = !empty($options['groupName']) ? $options['groupName'] : ''; $groupName = !empty($options['groupName']) ? $options['groupName'] : '';
$textDomain = TEXT_DOMAIN;
require dirname(__DIR__) . '/view/events-list-widget/form.php'; require dirname(__DIR__) . '/view/events-list-widget/form.php';
} }

View File

@ -29,14 +29,14 @@ class Settings {
add_settings_section( add_settings_section(
self::$SETTINGS_SECTION_NAME, self::$SETTINGS_SECTION_NAME,
__('General Settings', TEXT_DOMAIN), __('General Settings', 'connector-mobilizon'),
'', '',
self::$PAGE_NAME self::$PAGE_NAME
); );
add_settings_field( add_settings_field(
self::$SETTING_FIELD_NAME_URL, self::$SETTING_FIELD_NAME_URL,
__('URL', TEXT_DOMAIN), __('URL', 'connector-mobilizon'),
'MobilizonConnector\Settings::output_field_url', 'MobilizonConnector\Settings::output_field_url',
self::$PAGE_NAME, self::$PAGE_NAME,
self::$SETTINGS_SECTION_NAME, self::$SETTINGS_SECTION_NAME,
@ -47,7 +47,6 @@ class Settings {
} }
public static function output_field_url($args) { public static function output_field_url($args) {
$textDomain = TEXT_DOMAIN;
$url = self::getUrl(); $url = self::getUrl();
require dirname(__DIR__) . '/view/settings/url-field.php'; require dirname(__DIR__) . '/view/settings/url-field.php';
} }
@ -58,7 +57,7 @@ class Settings {
add_settings_error( add_settings_error(
self::$OPTION_NAME_URL, self::$OPTION_NAME_URL,
'wordpress_mobilizon_field_url_error', 'wordpress_mobilizon_field_url_error',
__('The URL is invalid.', TEXT_DOMAIN), __('The URL is invalid.', 'connector-mobilizon'),
'error' 'error'
); );
} }
@ -70,7 +69,7 @@ class Settings {
public static function register_settings_page() { public static function register_settings_page() {
add_options_page( add_options_page(
NICE_NAME . ' ' . __('Settings', TEXT_DOMAIN), NICE_NAME . ' ' . __('Settings', 'connector-mobilizon'),
NICE_NAME, NICE_NAME,
'manage_options', 'manage_options',
NAME . '-settings', NAME . '-settings',

View File

@ -5,14 +5,14 @@ if (!defined('ABSPATH')) {
} }
?> ?>
<p> <p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title', $textDomain); ?>:</label> <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title', 'connector-mobilizon'); ?>:</label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>"> <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>">
</p> </p>
<p> <p>
<label for="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>"><?php esc_attr_e('Number of events to show', $textDomain); ?>:</label> <label for="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>"><?php esc_html_e('Number of events to show', 'connector-mobilizon'); ?>:</label>
<input class="tiny-text" id="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>" name="<?php echo esc_attr($this->get_field_name('eventsCount')); ?>" type="number" value="<?php echo esc_attr($eventsCount); ?>" min="1"> <input class="tiny-text" id="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>" name="<?php echo esc_attr($this->get_field_name('eventsCount')); ?>" type="number" value="<?php echo esc_attr($eventsCount); ?>" min="1">
</p> </p>
<p> <p>
<label for="<?php echo esc_attr($this->get_field_id('groupName')); ?>"><?php esc_attr_e('Group name (optional)', $textDomain); ?>:</label> <label for="<?php echo esc_attr($this->get_field_id('groupName')); ?>"><?php esc_html_e('Group name (optional)', 'connector-mobilizon'); ?>:</label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('groupName')); ?>" name="<?php echo esc_attr($this->get_field_name('groupName')); ?>" type="text" value="<?php echo esc_attr($groupName); ?>"> <input class="widefat" id="<?php echo esc_attr($this->get_field_id('groupName')); ?>" name="<?php echo esc_attr($this->get_field_name('groupName')); ?>" type="text" value="<?php echo esc_attr($groupName); ?>">
</p> </p>

View File

@ -10,5 +10,5 @@ if (!defined('ABSPATH')) {
data-maximum="<?php echo esc_attr($eventsCount); ?>" data-maximum="<?php echo esc_attr($eventsCount); ?>"
data-group-name="<?php echo esc_attr($groupName); ?>" data-group-name="<?php echo esc_attr($groupName); ?>"
data-time-zone="<?php echo esc_attr($timeZone); ?>"> data-time-zone="<?php echo esc_attr($timeZone); ?>">
<li style="display: none;"><?php echo esc_html_e('The events could not be loaded!', $textDomain); ?></li> <li style="display: none;"><?php esc_html_e('The events could not be loaded!', 'connector-mobilizon'); ?></li>
</ul> </ul>

View File

@ -10,5 +10,5 @@ if (!defined('ABSPATH')) {
type="url" type="url"
value="<?php echo esc_attr($url); ?>"> value="<?php echo esc_attr($url); ?>">
<p class="description"> <p class="description">
<?php esc_html_e('The URL of the Mobilizon instance whose events you want to list, e.g. https://example.net', $textDomain); ?> <?php esc_html_e('The URL of the Mobilizon instance whose events you want to list, e.g. https://example.net', 'connector-mobilizon'); ?>
</p> </p>