From 8648e708c4f19cd3e0993dcac2c60687062190c0 Mon Sep 17 00:00:00 2001 From: AlexanderDmitriev Date: Sun, 4 Nov 2018 14:06:33 +0300 Subject: [PATCH] added I18n translation --- README.md | 16 ++++++++++++++++ app/views/admin/configurables/show.html.erb | 4 ++-- .../configurables_controller.rb | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1af8fc0..f65f5a1 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,22 @@ To style the web interface you are advised to use Sass. Here's an example scss f Just save this into your rails assets and you're ready to go. +## I18n ## + +For using I18n translation add this config to your locale file: + +```yaml +#config/en.yml + +en: + configurable: + save_button: "Save config" + title: "Config my site" + success: + save: "Saved!" +``` + + ## Running the Tests ## The tests for this rails engine are in the `spec` and `features` directories. They use the dummy rails app in `spec/dummy` diff --git a/app/views/admin/configurables/show.html.erb b/app/views/admin/configurables/show.html.erb index aa55959..0a6ad4a 100644 --- a/app/views/admin/configurables/show.html.erb +++ b/app/views/admin/configurables/show.html.erb @@ -1,7 +1,7 @@
-

Config

+

<%= I18n.t('configurable.title', default: 'Config' ) %>

@@ -25,7 +25,7 @@
<%- end -%> - <%= submit_tag 'Save' %> + <%= submit_tag I18n.t('configurable.save_button', default: 'Save'), class: 'configurable button' %> <%- end -%>
diff --git a/lib/configurable_engine/configurables_controller.rb b/lib/configurable_engine/configurables_controller.rb index d16c6e8..b491973 100644 --- a/lib/configurable_engine/configurables_controller.rb +++ b/lib/configurable_engine/configurables_controller.rb @@ -15,11 +15,11 @@ def update end if failures.empty? - redirect_to admin_configurable_path, :notice => "Changes successfully updated" + redirect_to admin_configurable_path, :notice => I18n.t('configurable.success.save', default: "Changes successfully updated") else flash[:error] = failures.flat_map(&:errors).flat_map(&:full_messages).join(',') redirect_to admin_configurable_path end end end -end \ No newline at end of file +end