Shipeasy
ReferenceRuby

i18n (Rails view helpers)

This SDK has i18n. Although it's a server SDK, the gem ships server-side i18n view helpers for Rails (translated label rendering at SSR) plus loader tags…

Generated from the SDK's own /docs/ — also served raw at https://shipeasy-ai.github.io/sdk-ruby/pages/i18n.md.

This SDK has i18n. Although it's a server SDK, the gem ships server-side i18n view helpers for Rails (translated label rendering at SSR) plus loader tags for the browser SDK. The same Shipeasy.configure covers it — there is no separate i18n init.

Configure

i18n uses the public client key (not the server key) and a profile:

Shipeasy.configure do |c|
  c.api_key    = ENV.fetch("SHIPEASY_SERVER_KEY")
  c.public_key = ENV.fetch("SHIPEASY_CLIENT_KEY")   # for i18n
  c.profile    = "{{PROFILE}}"
end

Rails view helpers

When Rails is loaded, the Railtie auto-mounts these helpers — no include needed:

<%# Renders <script id="i18n-data" ...> inline data + the loader <script> tag: %>
<%= i18n_head_tags %>

<h1><%= i18n_t("hero.title", name: current_user.name) %></h1>
HelperPurpose
i18n_head_tags(profile:, chunk:)Inline label JSON + loader <script> tag for <head>.
i18n_inline_data(profile:, chunk:)Just the inline application/json label blob.
i18n_script_tag(hide_until_ready:)Just the loader <script> (uses config.public_key + config.profile).
i18n_t(key, variables = {}, profile:, chunk:)Render a translated label server-side, interpolating {{var}} placeholders. Falls back to the key if missing.

i18n_t resolves the label from the fetched label file for the configured profile/chunk and interpolates {{name}}-style variables. If the key is absent it returns the key verbatim.

SSR i18n loader tag (framework-agnostic)

Outside Rails, emit the loader tag with the package-level helper (it delegates to the engine configured by Shipeasy.configure). This tag carries the public client key, never the server key:

Shipeasy.i18n_script_tag(client_key, profile: "{{PROFILE}}")

Shipeasy.bootstrap_script_tag also takes an i18n_profile: so the browser hydrates the same profile (see advanced).

Cross-SDK story

The browser SDK loads translations via the loader <script> (data-key = the public client key, data-profile = the profile) and exposes t() client-side. The Ruby helpers render the same {{PROFILE}} profile server-side so the first paint is already translated.

Was this page helpful?
✎ Edit this page

On this page