8000 GitHub - GaggleUp/i18nify: An alternate way to I18n in Ruby applications.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

GaggleUp/i18nify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

In your Gemfile: gem 'i18nify', :git => "git://github.com/GaggleUp/i18nify.git"

If you want I18nify to magically attach to all ActiveRecord models, create an initializer in config/initializers/active_record_extensions.rb with this:

require 'i18nify'

Include I18nify and call has_strings in your classes. Call tr to look up a translation:

class Foo::Bar
  include I18nify

  has_strings({
    :thing => "A thing that has value %{value}",
    :error => "I am error."
  })

  def do_something
    if error_occurs
      raise tr(:error)
    else
      tr(:thing, :value => 5)
    end
  end
end

You can then localize these strings in your config/locale/files, eg:

config/locale/se.yml
se:
  foo:
    bar:
      thing: "A theeng hes felooe-a %{value}"
      error: "I em irrur"

TODO

  1. Support custom key prefixes
  2. Rake task to collect all known strings to be localised, and add them to a config/locale/*.yml file.

About

An alternate way to I18n in Ruby applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0