Project

hyper-i18n

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
HyperI18n seamlessly brings Rails I18n into your Hyperloop application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
= 0.99.6
= 0.99.6
~> 0.9.4
>= 0
>= 0
~> 10.0
>= 0
~> 0.51.0

Runtime

 Project Readme

HyperI18n

Build Status Gem Version

HyperI18n gem

HyperI18n seamlessly brings Rails I18n into your Hyperloop application.

Documentation and Help

Installation and Setup

  1. Add gem 'hyper-i18n', git: 'https://github.com/ruby-hyperloop/hyper-i18n.git' to your Gemfile
  2. Install the Gem: bundle install
  3. Add require 'hyper-i18n' to your components manifest

Note!

This gem is in it's very early stages, and only a handful of the API has been implemented. Contributions are very welcome!

Usage

Hyper-I18n brings in the standard ActiveSupport API.

ActiveRecord Models

The methods Model.model_name.human and Model.human_attribute_name are available:

# config/locales/models/en.yml
en:
  activerecord:
    models:
      user: 'Customer'
    attributes:
      name: 'Name'
User.model_name.human
# 'Customer'

User.human_attribute_name(:name)
# 'Name'

Views

Hyper-I18n makes available the method t to components, just as ActiveSupport does for views. It also implements the same lazy-loading pattern, so if you name space your locale file the same as your components, it will just work:

# config/locales/views/en.yml
en:
  users:
    show:
      title: 'Customer View'
module Users
  class Show < Hyperloop::Component
    render do
      H1 { t(:title) }
    end
  end
end

# <h1>Customer View</h1>

Server Rendering

HyperI18n is fully compatible with server rendering! All translations are also sent to the client, so as to bypass fetching/rendering again on the client.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-hyperloop/hyper-i18n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Code of Conduct code of conduct.

License

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