Rename translation functions

This commit is contained in:
Amine Ben hammou
2019-05-21 08:59:11 +00:00
committed by M. Shull
parent 934119f5dd
commit 879a36e0f2
7 changed files with 24 additions and 24 deletions

View File

@ -84,7 +84,7 @@ class API {
// throw exception when none of the segments exist // throw exception when none of the segments exist
$found_segments = Segment::whereIn('id', $segments_ids)->findMany(); $found_segments = Segment::whereIn('id', $segments_ids)->findMany();
if (!$found_segments) { if (!$found_segments) {
$exception = WPFunctions::get()->n('This list does not exist.', 'These lists do not exist.', count($segments_ids), 'mailpoet'); $exception = WPFunctions::get()->_n('This list does not exist.', 'These lists do not exist.', count($segments_ids), 'mailpoet');
throw new \Exception($exception); throw new \Exception($exception);
} }
@ -104,7 +104,7 @@ class API {
if (count($found_segments_ids) !== count($segments_ids)) { if (count($found_segments_ids) !== count($segments_ids)) {
$missing_ids = array_values(array_diff($segments_ids, $found_segments_ids)); $missing_ids = array_values(array_diff($segments_ids, $found_segments_ids));
$exception = sprintf( $exception = sprintf(
WPFunctions::get()->n('List with ID %s does not exist.', 'Lists with IDs %s do not exist.', count($missing_ids), 'mailpoet'), WPFunctions::get()->_n('List with ID %s does not exist.', 'Lists with IDs %s do not exist.', count($missing_ids), 'mailpoet'),
implode(', ', $missing_ids) implode(', ', $missing_ids)
); );
throw new \Exception(sprintf($exception, implode(', ', $missing_ids))); throw new \Exception(sprintf($exception, implode(', ', $missing_ids)));
@ -152,7 +152,7 @@ class API {
// throw exception when none of the segments exist // throw exception when none of the segments exist
$found_segments = Segment::whereIn('id', $segments_ids)->findMany(); $found_segments = Segment::whereIn('id', $segments_ids)->findMany();
if (!$found_segments) { if (!$found_segments) {
$exception = WPFunctions::get()->n('This list does not exist.', 'These lists do not exist.', count($segments_ids), 'mailpoet'); $exception = WPFunctions::get()->_n('This list does not exist.', 'These lists do not exist.', count($segments_ids), 'mailpoet');
throw new \Exception($exception); throw new \Exception($exception);
} }
@ -172,7 +172,7 @@ class API {
if (count($found_segments_ids) !== count($segments_ids)) { if (count($found_segments_ids) !== count($segments_ids)) {
$missing_ids = array_values(array_diff($segments_ids, $found_segments_ids)); $missing_ids = array_values(array_diff($segments_ids, $found_segments_ids));
$exception = sprintf( $exception = sprintf(
WPFunctions::get()->n('List with ID %s does not exist.', 'Lists with IDs %s do not exist.', count($missing_ids), 'mailpoet'), WPFunctions::get()->_n('List with ID %s does not exist.', 'Lists with IDs %s do not exist.', count($missing_ids), 'mailpoet'),
implode(', ', $missing_ids) implode(', ', $missing_ids)
); );
throw new \Exception($exception); throw new \Exception($exception);

View File

@ -156,7 +156,7 @@ class Menu {
// add limit per page to screen options // add limit per page to screen options
$this->wp->addAction('load-' . $newsletters_page, function() { $this->wp->addAction('load-' . $newsletters_page, function() {
$this->wp->addScreenOption('per_page', [ $this->wp->addScreenOption('per_page', [
'label' => $this->wp->x( 'label' => $this->wp->_x(
'Number of newsletters per page', 'Number of newsletters per page',
'newsletters per page (screen options)', 'newsletters per page (screen options)',
'mailpoet' 'mailpoet'
@ -194,7 +194,7 @@ class Menu {
// add limit per page to screen options // add limit per page to screen options
$this->wp->addAction('load-' . $forms_page, function() { $this->wp->addAction('load-' . $forms_page, function() {
$this->wp->addScreenOption('per_page', [ $this->wp->addScreenOption('per_page', [
'label' => $this->wp->x( 'label' => $this->wp->_x(
'Number of forms per page', 'Number of forms per page',
'forms per page (screen options)', 'forms per page (screen options)',
'mailpoet' 'mailpoet'
@ -232,7 +232,7 @@ class Menu {
// add limit per page to screen options // add limit per page to screen options
$this->wp->addAction('load-' . $subscribers_page, function() { $this->wp->addAction('load-' . $subscribers_page, function() {
$this->wp->addScreenOption('per_page', [ $this->wp->addScreenOption('per_page', [
'label' => $this->wp->x( 'label' => $this->wp->_x(
'Number of subscribers per page', 'Number of subscribers per page',
'subscribers per page (screen options)', 'subscribers per page (screen options)',
'mailpoet' 'mailpoet'
@ -283,7 +283,7 @@ class Menu {
// add limit per page to screen options // add limit per page to screen options
$this->wp->addAction('load-' . $segments_page, function() { $this->wp->addAction('load-' . $segments_page, function() {
$this->wp->addScreenOption('per_page', [ $this->wp->addScreenOption('per_page', [
'label' => $this->wp->x( 'label' => $this->wp->_x(
'Number of segments per page', 'Number of segments per page',
'segments per page (screen options)', 'segments per page (screen options)',
'mailpoet' 'mailpoet'

View File

@ -243,7 +243,7 @@ class Populator {
if (empty($woocommerce_optin_on_checkout)) { if (empty($woocommerce_optin_on_checkout)) {
$this->settings->set('woocommerce.optin_on_checkout', [ $this->settings->set('woocommerce.optin_on_checkout', [
'enabled' => empty($settings_db_version), // enable on new installs only 'enabled' => empty($settings_db_version), // enable on new installs only
'message' => WPFunctions::get()->x('Yes, I would like to be added to your mailing list', "default email opt-in message displayed on checkout page for ecommerce websites"), 'message' => WPFunctions::get()->_x('Yes, I would like to be added to your mailing list', "default email opt-in message displayed on checkout page for ecommerce websites"),
]); ]);
} }

View File

@ -10,32 +10,32 @@ use MailPoet\WP\Functions as WPFunctions;
class DefaultForm { class DefaultForm {
public function getName() { public function getName() {
return WPFunctions::get()->x('A GDPR friendly form', 'default name of form (GDPR friendly) to capture emails', 'mailpoet'); return WPFunctions::get()->_x('A GDPR friendly form', 'default name of form (GDPR friendly) to capture emails', 'mailpoet');
} }
public function getBody() { public function getBody() {
return [ return [
[ [
'type' => 'text', 'type' => 'text',
'name' => WPFunctions::get()->x('First name', 'Form label', 'mailpoet'), 'name' => WPFunctions::get()->_x('First name', 'Form label', 'mailpoet'),
'id' => 'first_name', 'id' => 'first_name',
'unique' => '1', 'unique' => '1',
'static' => '0', 'static' => '0',
'params' => ['label' => WPFunctions::get()->x('First name', 'Form label', 'mailpoet')], 'params' => ['label' => WPFunctions::get()->_x('First name', 'Form label', 'mailpoet')],
'position' => '1', 'position' => '1',
], ],
[ [
'type' => 'text', 'type' => 'text',
'name' => WPFunctions::get()->x('Email', 'Form label', 'mailpoet'), 'name' => WPFunctions::get()->_x('Email', 'Form label', 'mailpoet'),
'id' => 'email', 'id' => 'email',
'unique' => '0', 'unique' => '0',
'static' => '1', 'static' => '1',
'params' => ['label' => WPFunctions::get()->x('Email', 'Form label', 'mailpoet'), 'required' => 'true'], 'params' => ['label' => WPFunctions::get()->_x('Email', 'Form label', 'mailpoet'), 'required' => 'true'],
'position' => '2', 'position' => '2',
], ],
[ [
'type' => 'html', 'type' => 'html',
'name' => WPFunctions::get()->x('Custom text or HTML', 'Form label', 'mailpoet'), 'name' => WPFunctions::get()->_x('Custom text or HTML', 'Form label', 'mailpoet'),
'id' => 'html', 'id' => 'html',
'unique' => '0', 'unique' => '0',
'static' => '0', 'static' => '0',
@ -47,11 +47,11 @@ class DefaultForm {
], ],
[ [
'type' => 'submit', 'type' => 'submit',
'name' => WPFunctions::get()->x('Submit', 'Form label', 'mailpoet'), 'name' => WPFunctions::get()->_x('Submit', 'Form label', 'mailpoet'),
'id' => 'submit', 'id' => 'submit',
'unique' => '0', 'unique' => '0',
'static' => '1', 'static' => '1',
'params' => ['label' => WPFunctions::get()->x('Subscribe!', 'Form label', 'mailpoet')], 'params' => ['label' => WPFunctions::get()->_x('Subscribe!', 'Form label', 'mailpoet')],
'position' => '4', 'position' => '4',
], ],
]; ];

View File

@ -200,7 +200,7 @@ EOL;
// get forms list // get forms list
$forms = Form::getPublished()->orderByAsc('name')->findArray(); $forms = Form::getPublished()->orderByAsc('name')->findArray();
?><p> ?><p>
<label for="<?php $this->get_field_id( 'title' ) ?>"><?php WPFunctions::get()->e('Title:', 'mailpoet'); ?></label> <label for="<?php $this->get_field_id( 'title' ) ?>"><?php WPFunctions::get()->_e('Title:', 'mailpoet'); ?></label>
<input <input
type="text" type="text"
class="widefat" class="widefat"
@ -220,7 +220,7 @@ EOL;
</select> </select>
</p> </p>
<p> <p>
<a href="javascript:;" onClick="createSubscriptionForm()" class="mailpoet_form_new"><?php WPFunctions::get()->e('Create a new form', 'mailpoet'); ?></a> <a href="javascript:;" onClick="createSubscriptionForm()" class="mailpoet_form_new"><?php WPFunctions::get()->_e('Create a new form', 'mailpoet'); ?></a>
</p> </p>
<script type="text/javascript"> <script type="text/javascript">
function createSubscriptionForm() { function createSubscriptionForm() {

View File

@ -51,8 +51,8 @@ class ImportExportFactory {
$fields = array_merge( $fields = array_merge(
$fields, $fields,
[ [
'list_status' => WPFunctions::get()->x('List status', 'Subscription status', 'mailpoet'), 'list_status' => WPFunctions::get()->_x('List status', 'Subscription status', 'mailpoet'),
'global_status' => WPFunctions::get()->x('Global status', 'Subscription status', 'mailpoet'), 'global_status' => WPFunctions::get()->_x('Global status', 'Subscription status', 'mailpoet'),
'subscribed_ip' => WPFunctions::get()->__('IP address', 'mailpoet'), 'subscribed_ip' => WPFunctions::get()->__('IP address', 'mailpoet'),
] ]
); );

View File

@ -54,15 +54,15 @@ class Functions {
return __($text, $domain); return __($text, $domain);
} }
function e($text, $domain = 'default') { function _e($text, $domain = 'default') {
return _e($text, $domain); return _e($text, $domain);
} }
function n($single, $plural, $number, $domain = 'default') { function _n($single, $plural, $number, $domain = 'default') {
return _n($single, $plural, $number, $domain); return _n($single, $plural, $number, $domain);
} }
function x($text, $context, $domain = 'default') { function _x($text, $context, $domain = 'default') {
return _x($text, $context, $domain); return _x($text, $context, $domain);
} }