0.0
No release in over 3 years
Low commit activity in last 3 years
Supports loading translation files from views folder
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0
 Project Readme

FractualI18n

Co-locate Rails translation files alongside your views. Instead of maintaining a single large config/locales/en.yml, place small .yml files next to the templates they belong to. The gem automatically namespaces translation keys based on the file path.

How it works

Given this structure:

app/views/users/index.html.erb
app/views/users/index.yml
app/views/users/_form.html.erb
app/views/users/_form.yml

And index.yml:

en:
  title: "Users"

The translation is accessible via t(".title") in index.html.erb, which resolves through the key users.index.title. Partial prefixes (underscores) are stripped automatically — _form.yml maps to users.form.

Installation

Add to your Gemfile:

gem "fractual_i18n"

Usage

Include the backend in a Rails initializer:

# config/initializers/fractual_i18n.rb
I18n::Backend::Simple.include(FractualI18n::Backend)

Add view translation files to the I18n load path:

# config/application.rb
config.i18n.load_path += Dir[Rails.root.join("app/views/**/*.yml")]

That's it. The gem's railtie automatically detects app/views as a fractual path. In development, newly added .yml files are picked up without a server restart.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests.

License

The gem is available as open source under the terms of the MIT License.