Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asset_pipeline_i18n

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset_pipeline_i18n

  • 4.0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

= AssetPipelineI18n

Shortly: asset-pipeline + i18n

Some additional words: you would like to internationalize your javascript/css files the same way you do in the rest of application. For example you would like to write something like:

app/assets/file.js.erb

alert(<%= I18n.t('javascript.key.name') %>)

That works OK in development mode but with asset pipeline you have only one precompiled and (cached) application.js file translated with the default language. What you would need is a collection of language specific application.js files, like application-en.js, application-it.js, etc. This gem is exactly for that!

== Usage

If not already done, define all locales your application uses in an initializer:

I18n.available_locales = %w(de it en fr)

Add the gem to your Gemfile:

gem 'asset_pipeline_i18n'

In your application.rb add:

config.localized_assets = ["application-%{locale}.js"]

Now define all the application-xx.js files for every locale like that:

//= require application

And of course, in your layout, you also have to use something like:

javascript_include_tag "application-#{I18n.locale}"

Finally:

rake assets:precompile

== Known problems

=== Remove "require_tree ."

It is no more possible to write

//= require_tree .

in application.js because this will create a circular dependency now. One easy workaround is to move all the js files in a subdirectory (e.g. lib) and then:

//= require_tree ./lib

=== No proper i18n in development environment

This gem is intended for compiling translated assets for production environment. Unfortunately it does not provide proper translations when running in development environment due to assets caching.

== Versioning

The idea is to use the same version number of the Rails version the gem is compatible with. So asset_pipeline_i18n version 3.2.5 is for Rails 3.2.5 and so on. If the gem is broken and we have to release a fix, then we will use a forth level number, like 3.2.5.1 To keep things easy, the dependency of the gem if of the form ~> x.x.x, so we assume that it works also with new versions of Rails, until proved otherwise :)

== Contacts

Home page: https://github.com/simplificator/asset_pipeline_i18n

FAQs

Package last updated on 03 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc