Allow translating the comments form

This commit is contained in:
Flavio Copes 2016-03-24 09:03:25 +01:00
parent 3919f7d764
commit 9d38761d44
4 changed files with 39 additions and 20 deletions

View File

@ -117,7 +117,6 @@ class CommentsPlugin extends Plugin
$this->enable([ $this->enable([
'onTwigTemplatePaths' => ['onTwigAdminTemplatePaths', 0], 'onTwigTemplatePaths' => ['onTwigAdminTemplatePaths', 0],
'onAdminMenu' => ['onAdminMenu', 0], 'onAdminMenu' => ['onAdminMenu', 0],
'onAdminTemplateNavPluginHook' => ['onAdminMenu', 0], //DEPRECATED
'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0], 'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0],
]); ]);

View File

@ -12,23 +12,23 @@ form:
name: comments name: comments
fields: fields:
- name: name - name: name
label: Name label: PLUGIN_COMMENTS.NAME_LABEL
placeholder: Enter your name placeholder: PLUGIN_COMMENTS.NAME_PLACEHOLDER
autocomplete: on autocomplete: on
type: text type: text
validate: validate:
required: true required: true
- name: email - name: email
label: Email label: PLUGIN_COMMENTS.EMAIL_LABEL
placeholder: Enter your email address placeholder: PLUGIN_COMMENTS.EMAIL_PLACEHOLDER
type: email type: email
validate: validate:
required: true required: true
- name: text - name: text
label: Message label: PLUGIN_COMMENTS.MESSAGE_LABEL
placeholder: Enter your message placeholder: PLUGIN_COMMENTS.MESSAGE_PLACEHOLDER
type: textarea type: textarea
validate: validate:
required: true required: true
@ -62,15 +62,15 @@ form:
buttons: buttons:
- type: submit - type: submit
value: Submit value: PLUGIN_COMMENTS.SUBMIT_COMMENT_BUTTON_TEXT
process: process:
- email: - email:
subject: "[New Comment] from {{ form.value.name|e }}" subject: PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT
body: "{% include 'forms/data.html.twig' %}" body: "{% include 'forms/data.html.twig' %}"
# - captcha: # - captcha:
# recatpcha_secret: ej32oiej23oiej32oijeoi32jeio32je # recatpcha_secret: ej32oiej23oiej32oijeoi32jeio32je
- addComment: - addComment:
- message: Thank you for writing your comment! - message: PLUGIN_COMMENTS.THANK_YOU_MESSAGE

View File

@ -10,6 +10,16 @@ en:
EMAIL: Email: EMAIL: Email:
WRITTEN_ON: Written on WRITTEN_ON: Written on
BY: by BY: by
NAME_LABEL: "Name"
NAME_PLACEHOLDER: "Enter your name"
EMAIL_LABEL: "Email"
EMAIL_PLACEHOLDER: "Enter your email address"
MESSAGE_LABEL: "Comment"
MESSAGE_PLACEHOLDER: "Enter your comment"
SUBMIT_COMMENT_BUTTON_TEXT: "Submit"
EMAIL_NEW_COMMENT_SUBJECT: "[New Comment] from {{ form.value.name|e }}"
THANK_YOU_MESSAGE: "Thank you for writing your comment!"
fr: fr:
PLUGIN_COMMENTS: PLUGIN_COMMENTS:
ADD_COMMENT: Ajouter un commentaire ADD_COMMENT: Ajouter un commentaire
@ -34,6 +44,16 @@ it:
EMAIL: Email: EMAIL: Email:
WRITTEN_ON: Scritto il WRITTEN_ON: Scritto il
BY: da BY: da
NAME_LABEL: "Nome"
NAME_PLACEHOLDER: "Inserisci il tuo nome"
EMAIL_LABEL: "Email"
EMAIL_PLACEHOLDER: "Inserisci il tuo indirizzo email"
MESSAGE_LABEL: "Messaggio"
MESSAGE_PLACEHOLDER: "Inserisci il tuo commento"
SUBMIT_COMMENT_BUTTON_TEXT: "Invia"
EMAIL_NEW_COMMENT_SUBJECT: "[Nuovo commento] da {{ form.value.name|e }}"
THANK_YOU_MESSAGE: "Grazie per il tuo commento!"
ru: ru:
PLUGIN_COMMENTS: PLUGIN_COMMENTS:
ADD_COMMENT: Добавить комментарий ADD_COMMENT: Добавить комментарий

View File

@ -5,20 +5,20 @@
<form name="{{ grav.config.plugins.comments.form.name }}" <form name="{{ grav.config.plugins.comments.form.name }}"
action="{{ grav.config.plugins.comments.form.action ? base_url ~ grav.config.plugins.comments.form.action : page.url }}" action="{{ grav.config.plugins.comments.form.action ? base_url ~ grav.config.plugins.comments.form.action : page.url }}"
method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}"> method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">
{% for field in grav.config.plugins.comments.form.fields %}
{% set value = form.value(field.name) %} {% for field in grav.config.plugins.comments.form.fields %}
{% if field.evaluateDefault %} {% set value = form.value(field.name) %}
{% set value = evaluate(field.evaluateDefault) %} {% if field.evaluateDefault %}
{% endif %} {% set value = evaluate(field.evaluateDefault) %}
<div> {% endif %}
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %} <div>
</div> {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
{% endfor %} </div>
{% endfor %}
<div class="buttons"> <div class="buttons">
{% for button in grav.config.plugins.comments.form.buttons %} {% for button in grav.config.plugins.comments.form.buttons %}
<button class="button" type="{{ button.type|default('submit') }}">{{ button.value|default('Submit') }}</button> <button class="button" type="{{ button.type|default('submit') }}">{{ button.value|t|default('Submit') }}</button>
{% endfor %} {% endfor %}
</div> </div>