Giter VIP home page Giter VIP logo

asset_translate's Introduction

AssetTranslate

An I18n extension for translating - "localizing" assets (e.g. images, css). Supports locale fallback thru I18n.fallbacks (aka Globalize2) if available.

Install

as a (plain-old) rails plugin :

ruby script/plugin install git://github.com/kares/asset_translate.git

Example

I18n.asset_translate('images/test.gif')
# "/images/test.gif"
# assuming the file exists and default locale (e.g. :en)
# if there existed a "/images/locales/en/test.gif" file
# than it would be preffered over the "/images/test.gif"

I18n.locale = :hu
...
I18n.asset_translate('images/test.gif')
# "/images/locales/hu/test.gif"
# assuming the file exists

I18n.asset_translate('images/test.gif', :locale => :hu)
# "/images/locales/hu/test.gif"
# assuming the file exists (regardless of the I18n.locale)

Configuration

Assets directory (points to Your rails public folder by default).

I18n::AssetTranslate.assets_dir = './myAssets'

The subdirectory name with locale specific assets, 'locales' by default. Example dir layout: 'myAssets/flag.png', 'myAssets/locales/hu/flag.png', ...

I18n::AssetTranslate.locales_dirname = '_localized'

Assets directory mapping by extension. By default (in a rails env) setup as :

ext_map = { '.css' => "public/stylesheets", '.js' => "public/javascripts" }
%w{.gif .jpg .jpeg .png .bmp}.each { |ext| ext_map[ext] = "public/images" }

I18n::AssetTranslate.ext_mappings = ext_map

asset_translate's People

Contributors

kares avatar

Stargazers

 avatar

Watchers

 avatar  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.