Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A rails 3/4 engine based interface for translating and writing translation files
JavaScript Ruby CSS
Branch: master
Failed to load latest commit information.
app tiny styling useless but cleaner improvements related to rubocop run
config tiny styling useless but cleaner improvements related to rubocop run
lib tiny styling useless but cleaner improvements related to rubocop run
spec tiny styling useless but cleaner improvements related to rubocop run
.coveralls.yml adding coveralls link
.gitignore janitoring
.rspec tests refactoring
.rubocop.yml
.ruby-gemset keys sort function fixed
.ruby-version
.travis.yml adding a travis conf for caching bundle
Gemfile adding config for selenium on saucelabs just out of curiosity
MIT-LICENSE preparing the migration to rspec
README.md some tuning on readme
Rakefile some more testing
changelog.md keys sort function fixed
config.ru adding config for selenium on saucelabs just out of curiosity
rails-i18nterface.gemspec update combustion gem version

README.md

Rails I18nterface

Dependency Status Build Status Coverage Status Code Climate Gem Version Selenium Test Status Changelog

rails-i18nterface

Usage

In Gemfile

gem 'rails-i18nterface'

In routes.rb

mount RailsI18nterface::Engine => "/translate", :as => "translate_engine"

Protect access

You may want to protect the translation engine to admin and create a constraint in your routes (note that you don't want to mount it when you launch tests):

constraints AdminConstraint.new do
  unless Rails.env.test?
    mount RailsI18nterface::Engine => "/translate", :as => "translate_engine"
  end
end
# this second route will be then used if the user is not an admin
get 'translate' => redirect do |p, req|
  req.flash['error'] = I18n.t('errors.permission_denied')
  "/signin"
end

Then create a config/initializers/admin_constraint.rb containing:

class AdminConstraint
  def matches?(request)
    current_user && current_user.is_admin?
  end
end

(this example is for devise users, but you can adjust it to return true or false according to your own context).

Configuration

You can configure from_locales and to_locales explicitly in your environments/development.rb by adding

config.from_locales = [:en]
config.to_locales = [:ja, :es, :fr]

Where [:en] and [:ja, :es, :fr] could be replaced by locale list of your choice.

Todo

  • fix the code smell reported by code climate (done)
    • extract code from the controller to a lib (done)
    • refactor the libs in a cleaner way (done)
    • apply rubocop and follow his law (done)
  • remove those damn global variables (done)
  • extend testing to refactored libs (done)
  • make the application thread-safe
  • change navigation to an ajax-driven reload
  • add a way to gather .one and .other and .few under same translation line (not sure actually)
  • add support for other i18n backends (gettext)

Note for upgrade 0.1.x to 0.2.x

The database is not used anymore, back to the good old way. So you can remove the table rails_i18nterface_translations (v0.1.7) or translations (< 0.1.7).

Project history

This is a fork of an overhaul of a fork of a fork of rails-translate.

It was originally created by Peter Marklund and Joakim Westerlund @ mynewsdesk and later adapted to rails 3.0 by Claudius Coenen. This version is a spin-off of Claudius Coenen's version by Larry Sprock. It was renamed, refactored and prepared for rails 3.1 as an Engine. Over this work Michal Hantl made a bunch of nice UI modifications on his fork. Since then it was more or less abandoned.

I took over the evolution with some new features:

  • testing using combustion and rspec
  • redesign of the layout
  • navigation overhaul, splitting the name-spaces in a foldable menu
  • gathering of first-level translations under a ROOT container
  • gemification and release of a version 0.1.0
  • (the 0.0.1 was the work from Larry Sprock but was not published as a gem)
  • compatibility with rails 4 and ruby 2

Check the Changelog for details about further changes.

License

Copyright 2009 Peter Marklund, Joakim Westerlund, Claudius Coenen
Copyright 2011 Larry Sprock, Artin Boghosain, Michal Hantl
Copyright 2013 Mose

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.