Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
I18n for your Javascript in Rails. Based on jQuery and Mustache.
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
vendor/assets/javascripts
.gitignore
Gemfile
README.textile
Rakefile
internashunalize-js.gemspec

README.textile

Intro

This gem takes an other approach to Javascript internationalization than most others do.
I use this in production but you might want to look at it as a proof of concept.
The goal is to build a lightweight, unobtrusive and powerful translation solution for Frontend applications by using standard libraries.

Right now, you’ll have to manually provide the following depencencies: Rails, jQuery and Mustache.

Installation

Add the gem to your Gemfile

gem 'internashunalize-js'

Run the generator

rails g internashunalize:js:install

Don’t forget to include the javascript in your Html.

Mark translations you want to use in your scripts

<% t(:yml_key, :javascript => true) %>

Place the view helper somewhere in your layout / views

<%= javascript_translations %>

Usage

Start using the marked translations in your Javascript

I18n.t('yml_key')

For interpolating values, you can pass a Json object as second argument

I18n.t('yml_key_with_variable', { your_variable: 'Variable content' })
Something went wrong with that request. Please try again.