Add mailpoet translations

[MAILPOET-2450]
This commit is contained in:
Rostislav Wolny
2019-11-04 12:17:05 +01:00
committed by Jack Kitterhing
parent 34a81dd2f8
commit 776cd01e20
7 changed files with 28 additions and 13 deletions

View File

@@ -1,13 +1,10 @@
import React from 'react'; import React from 'react';
import { import {
Panel, Panel,
PanelBody,
} from '@wordpress/components'; } from '@wordpress/components';
export default () => ( export default () => (
<Panel> <Panel>
<PanelBody title="Block Settings"> <p>TODO Block Settings</p>
<p>TODO Block Settings</p>
</PanelBody>
</Panel> </Panel>
); );

View File

@@ -3,21 +3,22 @@ import {
Panel, Panel,
PanelBody, PanelBody,
} from '@wordpress/components'; } from '@wordpress/components';
import MailPoet from 'mailpoet';
export default () => ( export default () => (
<> <>
<Panel> <Panel>
<PanelBody title="Settings"> <PanelBody title={MailPoet.I18n.t('formSettings')}>
<p>TODO Basic Settings</p> <p>TODO Basic Settings</p>
</PanelBody> </PanelBody>
</Panel> </Panel>
<Panel> <Panel>
<PanelBody title="From placement" initialOpen={false}> <PanelBody title={MailPoet.I18n.t('formPlacement')} initialOpen={false}>
<p>TODO Form placement</p> <p>TODO Form placement</p>
</PanelBody> </PanelBody>
</Panel> </Panel>
<Panel> <Panel>
<PanelBody title="Custom CSS" initialOpen={false}> <PanelBody title={MailPoet.I18n.t('customCss')} initialOpen={false}>
<p>TODO Custom CSS</p> <p>TODO Custom CSS</p>
</PanelBody> </PanelBody>
</Panel> </Panel>

View File

@@ -1,6 +1,7 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useDispatch, useSelect } from '@wordpress/data'; import { useDispatch, useSelect } from '@wordpress/data';
import classnames from 'classnames'; import classnames from 'classnames';
import MailPoet from 'mailpoet';
export default () => { export default () => {
const [isSelected, setIsSelected] = useState(false); const [isSelected, setIsSelected] = useState(false);
@@ -18,12 +19,12 @@ export default () => {
<div className={titleClass}> <div className={titleClass}>
<div> <div>
<label htmlFor="post-title" className="screen-reader-text"> <label htmlFor="post-title" className="screen-reader-text">
Add form name {MailPoet.I18n.t('addFormName')}
</label> </label>
<textarea <textarea
id="form-title" id="form-title"
className="editor-post-title__input" className="editor-post-title__input"
placeholder="Add form name" placeholder={MailPoet.I18n.t('addFormName')}
rows="1" rows="1"
style={{ style={{
overflow: 'hidden', overflow: 'hidden',

View File

@@ -2,6 +2,7 @@ import React from 'react';
import { IconButton, Button } from '@wordpress/components'; import { IconButton, Button } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data'; import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import MailPoet from 'mailpoet';
export default () => { export default () => {
const sidebarOpened = useSelect( const sidebarOpened = useSelect(
@@ -30,7 +31,7 @@ export default () => {
</Button> </Button>
<IconButton <IconButton
icon="admin-generic" icon="admin-generic"
label="Settings" label={MailPoet.I18n.t('formSettings')}
labelPosition="down" labelPosition="down"
onClick={() => toggleSidebar(!sidebarOpened)} onClick={() => toggleSidebar(!sidebarOpened)}
isToggled={sidebarOpened} isToggled={sidebarOpened}

View File

@@ -3,6 +3,7 @@ import { IconButton } from '@wordpress/components';
import { useDispatch } from '@wordpress/data'; import { useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import MailPoet from 'mailpoet';
import BlockSettings from './block_settings.jsx'; import BlockSettings from './block_settings.jsx';
import FormSettings from './form_settings.jsx'; import FormSettings from './form_settings.jsx';
@@ -41,7 +42,7 @@ export default () => {
className={`edit-post-sidebar__panel-tab ${activeTab === 'form' ? 'is-active' : ''}`} className={`edit-post-sidebar__panel-tab ${activeTab === 'form' ? 'is-active' : ''}`}
type="button" type="button"
> >
Form {MailPoet.I18n.t('form')}
</button> </button>
</li> </li>
<li> <li>

View File

@@ -1,5 +1,5 @@
import { select, dispatch } from '@wordpress/data'; import { select, dispatch } from '@wordpress/data';
import MailPoet from '../../mailpoet'; import MailPoet from 'mailpoet';
export default { export default {
SAVE_FORM() { SAVE_FORM() {
@@ -11,7 +11,7 @@ export default {
data: formData, data: formData,
}).done(() => { }).done(() => {
dispatch('mailpoet-form-editor').saveFormDone(); dispatch('mailpoet-form-editor').saveFormDone();
dispatch('mailpoet-form-editor').addNotice('Form saved.', 'success', true, 'save-form'); dispatch('mailpoet-form-editor').addNotice(MailPoet.I18n.t('formSaved'), 'success', true, 'save-form');
}).fail((response) => { }).fail((response) => {
let errorMessage = null; let errorMessage = null;
if (response.errors.length > 0) { if (response.errors.length > 0) {

View File

@@ -17,5 +17,19 @@
var mailpoet_form_data = <%= json_encode(form) %>; var mailpoet_form_data = <%= json_encode(form) %>;
<% endautoescape %> <% endautoescape %>
</script> </script>
<% endblock %>
<% block translations %>
<%= localize({
'addFormName': _x('Add form name', 'A placeholder for form name input'),
'form': __('Form'),
'formSettings': _x('Settings', 'A settings section heading'),
'formPlacement': _x('Form Placement', 'A settings section heading'),
'customCss': _x('Custom CSS', 'A settings section heading'),
'formSaved': __('Form saved.'),
}) %>
<% endblock %>
<% block after_javascript %>
<%= javascript('form_editor.js')%> <%= javascript('form_editor.js')%>
<% endblock %> <% endblock %>