Ruby on Rails
ShipEasyI18n integration for Ruby on Rails — i18n_t() view helper, layout script tag, Hotwire/Turbo compatibility, and i18n.config.json for ERB scanning.
No gem is required. ShipEasyI18n for Rails works via the CDN script tag and a small view helper you add to your application.
Script tag in application layout
Add the loader to app/views/layouts/application.html.erb:
<%# app/views/layouts/application.html.erb %>
<head>
<title><%= i18n_t('site.title') %></title>
<%# ... other head tags ... %>
<script
src="https://cdn.i18n.shipeasy.ai/v1/loader.js"
data-key="<%= ENV['ShipEasyI18n_KEY'] %>"
data-profile="en:prod"
async
></script>
</head>
i18n_t view helper
Add this helper to app/helpers/application_helper.rb:
# app/helpers/application_helper.rb
module ApplicationHelper
def i18n_t(key, variables = {})
content_tag(:span, key, data: { label: key, variables: variables.to_json })
end
end
This renders a <span data-label="key">key</span> that the ShipEasyI18n script rewrites in place.
Use it anywhere in your views:
<%# app/views/shared/_nav.html.erb %>
<nav>
<%= link_to i18n_t('nav.home'), root_path %>
<%= link_to i18n_t('nav.account'), account_path %>
<%= button_tag i18n_t('checkout.submit') %>
</nav>
Hotwire / Turbo compatibility
The ShipEasyI18n loader listens for turbo:render and turbo:frame-render events and re-applies labels after each Turbo navigation automatically. No extra configuration is needed.
For Turbo Streams, add the data-i18n-rewrite attribute to streamed content to trigger a re-apply:
<%# In a Turbo Stream template %>
<turbo-stream action="replace" target="cart-summary" data-i18n-rewrite>
<template>
<%= render 'cart/summary' %>
</template>
</turbo-stream>
Label scanning with i18n.config.json
Tell the ShipEasyI18n CLI which files to scan when extracting label keys:
{
"scan": {
"include": [
"app/views/**/*.erb",
"app/views/**/*.haml",
"app/javascript/**/*.{js,ts,jsx,tsx}"
],
"pattern": "i18n_t\\(['\"]([^'\"]+)['\"]"
}
}
Run npx i18n scan to generate or update the label catalog.
For the full implementation spec including package source code and edge cases, see plans/frameworks/rails.md in the repository.
Qwik / Qwik City
ShipEasyI18n integration for Qwik and Qwik City — useStore integration, Qwik City routeLoader$, and resumable hydration with zero client-side fetch.
React
ShipEasyI18n integration for React 18+ SPAs. ShipEasyI18nProvider, useShipEasyI18n hook, ShipEasyI18nString component. Works with Vite, CRA, and any React setup.