Skip to content

iurev/edit_i18n_database_translations

Repository files navigation

Live editing I18n texts and images for content managers

How it looks:

Text editing:

image

Images editing:

image

How to install:

At first, you need to install a gem i18n-active_record using instructions.

Install gem edit_i18n_database_translations from github

gem 'edit_i18n_database_translations', github: 'wwju/edit_i18n_database_translations'

Put

rails g edit_i18n_database_translations:install

in the project console

Add

    include EditI18nDatabaseTranslations::ControllerModule

in ApplicationController.rb

And add this line in application.html.erb layout

<%= i18n_editor %>

Restart your development server.

How to use

Now you can use helper method text in the application's views instead of t method.

Add i18n_editor=true into browser url.

Enter your very strong login and password (yes, there are http base auth).

Enjoy!!!

For texts

= text("pages.main_title")

For images

en.yml

pages:
	page1:
		image: 'http://example.org/example.png'

index.slim:

= image_tag_i18n('pages.page1.image')

It accepts all the options, which function image_tag

can accept. And an option default.

= image_tag_i18n('pages.page1.image', default: image_url('place.jpg'))

It will add

onerror="this.onerror=null;this.src='place.jpg'"

in the image tag.

or, even more, you can use sass-helper

background-image: image_url_i18n('pages.page1.image')

But it requires assets recompilation.

Admin panel

You can access admin panel with all texts by typing i18n_editor/admin after root url in your project.

[image

Be careful! You have to edit initializer initializers/edit_i18n_database_translations.rb to load specific keys:

  config.allowed_keys = [:questions_pages, :seo, :share,
                         :results_pages]
                         

If you didn't add keys here, them will not appear in admin panel.

Keybindings

Cmd(Ctrl) + Enter = Submit

Esc = Undo

License

This project rocks and uses MIT-LICENSE.

About

Live editing I18n texts for content managers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published