Skip to content

BrandyMint/localized_render

Folders and files

NameName
Last commit message
Last commit date

Latest commit

83004a0 · Oct 15, 2018

History

9 Commits
Oct 12, 2018
Oct 12, 2018
Oct 12, 2018
Oct 15, 2018
Oct 15, 2018
Oct 12, 2018
Oct 12, 2018
Oct 12, 2018
Oct 12, 2018
Oct 15, 2018
Oct 12, 2018
Oct 12, 2018

Repository files navigation

LocalizedRender

Build Status

Позволяет удобно редаткировать globalized-атрибуты моделей во вьюхах с поддержкой CSS от bootstrap 3

Usage

Имеем модель с атрибутом title подключенным через globalize

class Content < ApplicationRecord
  translates :title
end

Добавляем в контроллер:

class ApplicationController < ActionController::Base
  helper LocalizedRender.helpers
end

В представлении формы добавляем переключатель между доступными локалями:

= simple_form_for content do |f|
  = localized_render do |locale|
    = f.input localized_attribute(:title, locale)

Получаем:

Image of example

Доступные методы

Модуль представляет всего два публичных метода:

  • localized_render - рендерит несколько input-ов для разных локалей в виде bootstrap css nav-tabs
  • localied_attribute_title - отдает название атрибута с постфиксом в виде локали (_ru, /_en). Используйте для этого gem globalize-accessors

Installation

Add this line to your application's Gemfile:

gem 'localized_render'

And then execute:

$ bundle

Or install it yourself as:

$ gem install localized_render

Рекомендую использовать gem globalize-accessors

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

Releases

No releases published

Packages

No packages published