Add translation interface feature setting

Allow to enable/disable translation interface at frontend
This commit is contained in:
Senén Rodero Rodríguez
2018-12-23 19:19:36 +01:00
committed by voodoorai2000
parent 3176be43d9
commit 7e3f0b5c18
6 changed files with 52 additions and 25 deletions

View File

@@ -6,6 +6,14 @@ module TranslatableFormHelper
end
end
def translations_interface_enabled?
Setting["feature.translation_interface"].present? || backend_translations_enabled?
end
def backend_translations_enabled?
(controller.class.parents & [Admin, Management, Valuation]).any?
end
class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder
attr_accessor :translations

View File

@@ -116,6 +116,8 @@ en:
public_stats_description: "Display public stats in the Administration panel"
help_page: "Help page"
help_page_description: 'Displays a Help menu that contains a page with an info section about each enabled feature. Also custom pages and menus can be created in the "Custom pages" and "Custom content blocks" sections'
translation_interface: "Translation interface"
translation_interface_description: "Displays the manual translation interface that allows users to enter their content in all application available languages. This option only affects user application forms and independently will always be active in the administration panel."
valuation_comment_notification: "Valuation comment notification"
valuation_comment_notification_description: "Send an email to all associated users except valuation commenter to budget investment when a new valuation comment is created"
map:

View File

@@ -116,6 +116,8 @@ es:
public_stats_description: "Muestra las estadísticas públicas en el panel de Administración"
help_page: "Página de ayuda"
help_page_description: 'Muestra un menú Ayuda que contiene una página con una sección de información sobre cada funcionalidad habilitada. También se pueden crear páginas y menús personalizados en las secciones "Personalizar páginas" y "Personalizar bloques"'
translation_interface: "Interfaz de traducción"
translation_interface_description: "Muestra la interfaz de traducción manual permitiendo a los usuarios introducir sus contenidos en todos los idiomas disponibles de la aplicación si así lo desean. Esta opción solo afecta a las vistas de usuarios de la aplicación, en el panel de administración está activa siempre."
valuation_comment_notification: "Notificar comentarios de evaluación"
valuation_comment_notification_description: "Envía un email a todos los usuarios menos al que haya comentado asociados a un presupuesto participativo cuando se cree un nuevo comentario de evaluación"
map:

View File

@@ -24,11 +24,16 @@ describe "Budget Investments" do
context "Concerns" do
it_behaves_like "notifiable in-app", Budget::Investment
it_behaves_like "relationable", Budget::Investment
it_behaves_like "new_translatable",
"budget_investment",
"new_budget_investment_path",
%w[title],
{ "description" => :ckeditor }
context "Translatable at front end" do
before do
Setting["feature.translation_interface"] = true
end
it_behaves_like "new_translatable",
"budget_investment",
"new_budget_investment_path",
%w[title],
{ "description" => :ckeditor }
end
end
context "Load" do

View File

@@ -11,16 +11,21 @@ describe "Debates" do
context "Concerns" do
it_behaves_like "notifiable in-app", Debate
it_behaves_like "relationable", Debate
it_behaves_like "new_translatable",
"debate",
"new_debate_path",
%w[title],
{ "description" => :ckeditor }
it_behaves_like "edit_translatable",
"debate",
"edit_debate_path",
%w[title],
{ "description" => :ckeditor }
context "Translatable at front end" do
before do
Setting["feature.translation_interface"] = true
end
it_behaves_like "new_translatable",
"debate",
"new_debate_path",
%w[title],
{ "description" => :ckeditor }
it_behaves_like "edit_translatable",
"debate",
"edit_debate_path",
%w[title],
{ "description" => :ckeditor }
end
end
scenario "Index" do

View File

@@ -15,16 +15,21 @@ describe "Proposals" do
context "Concerns" do
it_behaves_like "notifiable in-app", Proposal
it_behaves_like "relationable", Proposal
it_behaves_like "new_translatable",
"proposal",
"new_proposal_path",
%w[title summary],
{ "description" => :ckeditor }
it_behaves_like "edit_translatable",
"proposal",
"edit_proposal_path",
%w[title summary],
{ "description" => :ckeditor }
context "Translatable at front end" do
before do
Setting["feature.translation_interface"] = true
end
it_behaves_like "new_translatable",
"proposal",
"new_proposal_path",
%w[title summary],
{ "description" => :ckeditor }
it_behaves_like "edit_translatable",
"proposal",
"edit_proposal_path",
%w[title summary],
{ "description" => :ckeditor }
end
end
context "Index" do