API / Minn\I18n / ScriptTranslations

ScriptTranslations final class

Minn\I18n\ScriptTranslations · public/minn/src/Minn/I18n/ScriptTranslations.php · 60 lines

Where a script's JSON translations are found, and how they reach the page. A script is placed by its URL: inside a plugin or a theme, its path there; elsewhere on the site, its path from the site root; off the site, nowhere. The JSON files are named by the md5 of that path (with ".min.js" read as ".js"), or by the script's handle in a folder a plugin names.

Uses 1

Public

staticplace(string $src, string $siteUrl, string $pluginsUrl, string $themesUrl): array#

A script's path inside its plugin, theme or site, and the languages subfolder for it ("plugins", "themes", or "" for the site); the path is false for a script off the site.

@return array{0: string|false, 1: string}
staticabsolute(string $src, string $siteUrl): string#

The script made absolute the way place() reads it, for the filter that may move it.

staticfileHash(string $relative): string#

The md5 a translation file is named by: a minified script shares its source's file.

staticprefix(string $domain, string $locale): string#

The start of a translation file's name: the core domain goes by locale alone.

staticblock(string $domain, string $json): string#

The inline script that hands a script's translations to wp.i18n before the script runs.

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateorigin(string $siteUrl): string#