Add context to 'Select' translation strings

This commit is contained in:
Tautvidas Sipavičius
2017-01-30 20:44:40 +02:00
parent af2a6b2559
commit bedfc4f80c
8 changed files with 24 additions and 16 deletions

View File

@@ -24,6 +24,7 @@ class I18n extends \Twig_Extension {
'localize' => 'localize', 'localize' => 'localize',
'__' => 'translate', '__' => 'translate',
'_n' => 'pluralize', '_n' => 'pluralize',
'_x' => 'translateWithContext',
'date' => 'date' 'date' => 'date'
); );
@@ -63,6 +64,12 @@ class I18n extends \Twig_Extension {
return call_user_func_array('_n', $this->setTextDomain($args)); return call_user_func_array('_n', $this->setTextDomain($args));
} }
function translateWithContext() {
$args = func_get_args();
return call_user_func_array('_x', $this->setTextDomain($args));
}
function date() { function date() {
$args = func_get_args(); $args = func_get_args();
$date = (isset($args[0])) ? $args[0] : null; $date = (isset($args[0])) ? $args[0] : null;
@@ -88,4 +95,4 @@ class I18n extends \Twig_Extension {
} }
return $args; return $args;
} }
} }

View File

@@ -260,6 +260,7 @@ class StringExtractor {
$function_patterns = array( $function_patterns = array(
'/(__)\((([\'"]).+?\3)\)/', '/(__)\((([\'"]).+?\3)\)/',
'/(_x)\(([\'"].+?[\'"],\s*[\'"].+?[\'"])\)/',
'/(_n)\(([\'"].+?[\'"],\s*[\'"].+?[\'"],\s*.+?)\)/' '/(_n)\(([\'"].+?[\'"],\s*[\'"].+?[\'"],\s*.+?)\)/'
); );

View File

@@ -34,7 +34,7 @@
</option> </option>
<option <option
{{#ifCond type '==' 'select'}}selected="selected"{{/ifCond}} {{#ifCond type '==' 'select'}}selected="selected"{{/ifCond}}
value="select"><%= __('Select') %> value="select"><%= _x('Select', 'Form input type') %>
</option> </option>
<option <option
{{#ifCond type '==' 'date'}}selected="selected"{{/ifCond}} {{#ifCond type '==' 'date'}}selected="selected"{{/ifCond}}
@@ -133,4 +133,4 @@
} }
} }
}); });
</script> </script>

View File

@@ -97,7 +97,7 @@
'mailpoetGuideTemplateDescription': __("This is the standard template that comes with MailPoet."), 'mailpoetGuideTemplateDescription': __("This is the standard template that comes with MailPoet."),
'confirmTemplateDeletion': __('You are about to delete the template named "%$1s".'), 'confirmTemplateDeletion': __('You are about to delete the template named "%$1s".'),
'delete': __('Delete'), 'delete': __('Delete'),
'select': __('Select'), 'select': _x('Select', 'Verb'),
'preview': __('Preview'), 'preview': __('Preview'),
'selectTemplateTitle': __('Select a responsive template'), 'selectTemplateTitle': __('Select a responsive template'),
@@ -203,13 +203,13 @@
'thursdayShort': __('Thu'), 'thursdayShort': __('Thu'),
'fridayShort': __('Fri'), 'fridayShort': __('Fri'),
'saturdayShort': __('Sat'), 'saturdayShort': __('Sat'),
'sundayMin': __('S'), 'sundayMin': _x('S', 'Sunday - one letter abbreviation'),
'mondayMin': __('M'), 'mondayMin': _x('M', 'Monday - one letter abbreviation'),
'tuesdayMin': __('T'), 'tuesdayMin': _x('T', 'Tuesday - one letter abbreviation'),
'wednesdayMin': __('W'), 'wednesdayMin': _x('W', 'Wednesday - one letter abbreviation'),
'thursdayMin': __('T'), 'thursdayMin': _x('T', 'Thursday - one letter abbreviation'),
'fridayMin': __('F'), 'fridayMin': _x('F', 'Friday - one letter abbreviation'),
'saturdayMin': __('S'), 'saturdayMin': _x('S', 'Saturday - one letter abbreviation'),
'next': __('Next'), 'next': __('Next'),
'previous': __('Previous'), 'previous': __('Previous'),
'newsletterBeingSent': __('The newsletter is being sent...'), 'newsletterBeingSent': __('The newsletter is being sent...'),

View File

@@ -49,7 +49,7 @@
</label> </label>
</th> </th>
<td> <td>
<select id="export_lists" data-placeholder="<%= __('Select') %>" multiple="multiple"></select> <select id="export_lists" data-placeholder="<%= _x('Select', 'Verb') %>" multiple="multiple"></select>
</td> </td>
</tr> </tr>
{{/if}} {{/if}}
@@ -60,7 +60,7 @@
</label> </label>
</th> </th>
<td> <td>
<select id="export_columns" data-placeholder="<%= __('Select') %>" multiple="multiple"></select> <select id="export_columns" data-placeholder="<%= _x('Select', 'Verb') %>" multiple="multiple"></select>
</td> </td>
</tr> </tr>
{{#if groupBySegmentOption}} {{#if groupBySegmentOption}}

View File

@@ -34,7 +34,7 @@
<%= localize({ <%= localize({
'noMailChimpLists': __('No active lists found'), 'noMailChimpLists': __('No active lists found'),
'serverError': __('Server error:'), 'serverError': __('Server error:'),
'select': __('Select'), 'select': __('Selecto', 'Form input type'),
'csvKBLink': csvKBLink, 'csvKBLink': csvKBLink,
'wrongFileFormat': __('Only comma-separated (CSV) file formats are supported.'), 'wrongFileFormat': __('Only comma-separated (CSV) file formats are supported.'),
'maxPostSizeNotice': __('Your CSV is over %s and is too big to process. Please split the file into two or more sections.')|replace({'%s': maxPostSize}), 'maxPostSizeNotice': __('Your CSV is over %s and is too big to process. Please split the file into two or more sections.')|replace({'%s': maxPostSize}),

View File

@@ -92,7 +92,7 @@
</label> </label>
</th> </th>
<td> <td>
<select class="mailchimp_lists_select" data-placeholder="<%= __('Select') %>" multiple="multiple"></select> <select class="mailchimp_lists_select" data-placeholder="<%= _x('Select', 'Verb') %>" multiple="multiple"></select>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -38,7 +38,7 @@
</label> </label>
</th> </th>
<td> <td>
<select id="mailpoet_segments_select" data-placeholder="<%= __('Select') %>" multiple="multiple"></select> <select id="mailpoet_segments_select" data-placeholder="<%= _x('Select', 'Verb') %>" multiple="multiple"></select>
<a href="javascript:;" class="mailpoet_create_segment"><%= __('Create a new list') %></a> <a href="javascript:;" class="mailpoet_create_segment"><%= __('Create a new list') %></a>
</td> </td>
</tr> </tr>