Giter Club home page Giter Club logo

batch_translations's Introduction

Batch translation

Helper that renders globalize_translations fields on a per-locale basis, so you can use them separately in the same form and still saving them all at once in the same request.

Installation

Batch translation supports Globalize 3 and is not backward compatible.

rails plugin install git://github.com/fidel/batch_translations.git

Model configuration

In model, which uses Globalize after definition

translates :title, :teaser, :body # or any other fields, which you translate

place

accepts_nested_attributes_for :translations

so it’ll look like

class Post < ActiveRecord::Base
  translates :title, :teaser, :body
  accepts_nested_attributes_for :translations
end

It’s necessary for proper working.

Usage

Now, use it in your view file, like in these below:

<h1>Editing post</h1>

<% form_for(@post) do |f| %>
  <%= f.error_messages %>

  <h2>English (default locale)</h2>
  <p><%= f.text_field :title %></p>
  <p><%= f.text_field :teaser %></p>
  <p><%= f.text_field :body %></p>

  <hr/>

  <h2>Spanish translation</h2>
  <% f.globalize_fields_for :es do |g| %>
    <p><%= g.text_field :title %></p>
    <p><%= g.text_field :teaser %></p>
    <p><%= g.text_field :body %></p>
  <% end %>

  <hr/>

  <h2>French translation</h2>
  <% f.globalize_fields_for :fr do |g| %>
    <p><%= g.text_field :title %></p>
    <p><%= g.text_field :teaser %></p>
    <p><%= g.text_field :body %></p>
  <% end %>

  <%= f.submit "Save" %>
<% end %>

License

Copyright © 2010 Szymon Fiedler github.com/fidel, released under MIT License.

batch_translations's People

Contributors

fidel avatar fruell avatar webervin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.