Shipeasy
ReferencePHP

i18n

Shipeasy i18n is rendered in the browser by the client SDK's t(). There is no server-side t() / label-render API in this PHP SDK — its i18n surface is the…

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

Shipeasy i18n is rendered in the browser by the client SDK's t(). There is no server-side t() / label-render API in this PHP SDK — its i18n surface is the SSR bootstrap: it emits the loader <script> tag so the browser fetches and renders translations on first paint.

Both helpers are package-level functions backed by the configured SDK, so call Shipeasy\configure() at startup first — see Installation.

What the PHP SDK provides

Shipeasy\i18nScriptTag($clientKey, $profile)

Returns the i18n loader <script> tag. The loader fetches translations for the profile using the PUBLIC client key (safe to embed in HTML) — never the server key:

use function Shipeasy\i18nScriptTag;

// In your document <head> — $clientKey is the PUBLIC client key:
$head = i18nScriptTag($clientKey, '{{PROFILE}}');

The $profile is a locale profile such as {{PROFILE}} (e.g. en:prod). A third $opts array accepts 'baseUrl' (defaults to https://cdn.shipeasy.ai).

Shipeasy\bootstrapScriptTag($user, $opts)

Emits the request's evaluated flags as a declarative <script> tag (no key) so the browser SDK has flags + the __se_anon_id cookie on first paint, bucketing identically to the server. Pair it with the i18n tag:

use function Shipeasy\bootstrapScriptTag;
use function Shipeasy\i18nScriptTag;

$user = ['user_id' => 'u_123'];

$head = bootstrapScriptTag($user, ['anonId' => $anonId])
      . i18nScriptTag($clientKey, '{{PROFILE}}');

$opts for bootstrapScriptTag also accepts 'i18nProfile' and 'baseUrl'.

The cross-SDK story

  1. Server (this SDK): render i18nScriptTag() (+ bootstrapScriptTag()) into the <head> with the public client key and the {{PROFILE}} profile.
  2. Browser (@shipeasy/sdk/client): the loader hydrates translations; your markup calls the client SDK's t("key") to render localized text.

Translations themselves are authored and published in the Shipeasy dashboard / CLI / MCP under the {{PROFILE}} profile. The PHP SDK does not author, fetch, or render label strings itself — it only wires the loader.

Was this page helpful?
✎ Edit this page

On this page