MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

I18nAudit

MMO\admin\helpers · 1 symbole · générée le 30 Nov 2026

class

I18nAudit

I18nAudit.php:38

The translation audit of one package (a library of libs/, an application, one of its modules): what the root hub's php tools/mmo.php i18n and a monitoring hub's local project report.

class MMO\admin\helpers\I18nAudit use MMO\admin\helpers\tIgnoreFile
Espace de noms
MMO\admin\helpers
Utilise les traits
tIgnoreFile
- **missing**: a text written for translation (an English key) that no dictionary of the language translates. PHP side: `I18n::_('…')`, `$t('…')`, `->translate('…')`, the `@title`/`@label`/`@description` of a docblock (not a template made only of `{placeholders}`), the `title`/`label`/`description` of an `ArrayProperty` schema, the `group`/`label`/`title`/`description` of a pages `index.json`, the `title`/`text` of a `*.tour.json` and its steps, the `label`/`description`/`analysis`/`read` of a metrics definition (a `.json` of a `metrics` or `presets` folder). They are looked up in the package's `src/i18n/<lang>.php` (the mmo.json `i18n` folder), then in the other dictionaries (every library, the application of a module, the modules of an application): all of them are merged at run time, so a key found there is not missing, but it is reported as such. JS side: `MMO.i18n.$('…')`, the `label`/`text` of a `workflow.json`. They are looked up in the `MMO.i18n.load('<lang>', {…})` of the package's `<lang>*.js` files, and of every other package's (the bundle merges them all). - **conflicts**: the same English key translated differently by two dictionaries, one of them the package's. - **french**: a French text left in the code: a string literal, a text node or an attribute of a template, with an accented letter ([`ACCENTS`](https://mmoframework.fr/fr/documentation/mmo.admin/php/helpers/I18nAudit.md#i18naudit-accents)) or at least two French stop words ([`STOP_WORDS`](https://mmoframework.fr/fr/documentation/mmo.admin/php/helpers/I18nAudit.md#i18naudit-stop-words)). Not the comments, not the `value=`/`enum=`/`class=`/`data-*`... attributes ([`SKIP_ATTRIBUTES`](https://mmoframework.fr/fr/documentation/mmo.admin/php/helpers/I18nAudit.md#i18naudit-skip-attributes)), not an enum or switch `case`, not an array key, not the arguments of a log call, not a regular expression. Not scanned: the folders [`SKIP_FOLDERS`](https://mmoframework.fr/fr/documentation/mmo.admin/php/helpers/I18nAudit.md#i18naudit-skip-folders) anywhere, `www/bin`, a folder that is a package of its own (an `mmo.json`) or a symbolic link (an application's `libs`), and what the package's `i18n.ignore` lists: one entry a line, `path[:line|:from-to|:regex] # reason`, the path relative to the package (a glob), the regex matched against the line's text (`/…/flags` or a bare pattern). It is regex and token based: pragmatic, made to have few false positives rather than to miss nothing.
$audit = new I18nAudit('/home/me/dev/src/my.oviepro', 'fr', 'src/pages'); $audit->addDictionaries('mmo.client', '/home/me/dev/src/MMO/master/libs/client'); $report = $audit->run(); // ['missing' => [...], 'french' => [...], ...]

Index

ACCENTSan accented letter, a French quote or apostrophe: French text
JSON_FIELDSthe fields holding a text, by kind of json file: [php or js, fields]
LOG_FUNCTIONSthe log calls, whose texts are English and never translated
SKIP_ATTRIBUTESthe attributes of a template whose value is data or code, never a text
SKIP_FOLDERSthe folders never scanned, at any depth
STOP_WORDSFrench words that English does not use: two of them make a text French
dictionaries
files readonly
folder readonly
french
ignore
ignored
jsKeys
lang readonly
lines
manifest readonly
name readonly
phpKeys
scanned
addDictionaries($name, $folder)Add the dictionaries of another package: what the run time merges with the package's.
addModules($folder, $manifest)
addRelatedPackages()The application of a module (<app>/modules/<module>), and the modules of an application (its mmo.json urls).
Callee($tokens, $i) static
docComment($doc, $file, $line)The @title/@label/@description of a docblock: keys, unless a template made only of placeholders.
isIgnored($file, $line)
IsText($text) static
jsonKind($file)
key($side, $key, $file, $line)A text written for translation: French, it is a French literal; English, a key to find in a dictionary.
LooksFrench($text) static
matchesFilter($rel)
ParseJsDictionary($content, $lang) static
PhpString($literal) static
readDictionaries($folder, $manifest)
readIgnore($name)
ReadManifest($folder) static
run()Scan the package and check its keys.
scanFile($file, $rel)
scanHtml($html, $file, $lines, $lineOffset)Scan markup: its scripts (<script>, on*= attributes, {= … } expressions) as js, its text nodes and its attributes (but SKIP_ATTRIBUTES) for French.
scanJs($content, $start, $end, $file, $lines, $untilBrace)Scan the script between two offsets of a file: its keys and its strings.
scanJson($content, $file, $kind)
scanPhp($content, $file, $lines)
Significant($tokens, $i, $dir) static
sources($folder, $manifest)
text($text, $file, $line, $lines, $base)A text shown as is: French, it is reported (a template's markup is looked into: scanHtml).
Walk($folder, $withI18n) staticEvery file below a folder, but the folders never scanned, a symbolic link, a package of its own.
withLineOffset($lineOffset, $fn)Run a scan whose lines are shifted (markup inside a php string).
__construct($folder, $lang, $files)

Constantes6

ACCENTS

an accented letter, a French quote or apostrophe: French text

const ACCENTS = '/[éèêëàâùûçôîïœÉÈÀÇ«»’]/u'

JSON_FIELDS

the fields holding a text, by kind of json file: [php or js, fields]

const JSON_FIELDS = […4 items]

LOG_FUNCTIONS

the log calls, whose texts are English and never translated

const LOG_FUNCTIONS = […8 items]

SKIP_ATTRIBUTES

the attributes of a template whose value is data or code, never a text

const SKIP_ATTRIBUTES = […125 items]

SKIP_FOLDERS

the folders never scanned, at any depth

const SKIP_FOLDERS = […11 items]

STOP_WORDS

French words that English does not use: two of them make a text French

const STOP_WORDS = […44 items]

Propriétés13

dictionaries

protected array $dictionaries = []
Type
array

files

readonly
readonly ?string $files
Type
null | string

folder

readonly
readonly string $folder
Type
string

french

protected array $french = []
Type
array

ignore

protected array $ignore = []
Type
array

ignored

protected int $ignored = 0
Type
int

jsKeys

protected array $jsKeys = []
Type
array

lang

readonly
readonly string $lang
Type
string

lines

protected array $lines = []
Type
array

manifest

readonly
readonly array $manifest
Type
array

name

readonly
readonly string $name
Type
string

phpKeys

protected array $phpKeys = []
Type
array

scanned

protected int $scanned = 0
Type
int

Méthodes28

addDictionaries($name, $folder)

I18nAudit.php:124

Add the dictionaries of another package: what the run time merges with the package's.

function addDictionaries(string $name, string $folder): void
$namestring
$folderstringits folder (its mmo.json)
retournevoid

addRelatedPackages()

I18nAudit.php:130

The application of a module (<app>/modules/<module>), and the modules of an application (its mmo.json urls).

protected function addRelatedPackages(): void
retournevoid

Callee($tokens, $i)

staticI18nAudit.php:457
protected static function Callee(array $tokens, int $i): string
$tokensarray
$iint
retournestringthe name of what a ( calls: I18n::_, $t, ->info, \MMO\info, if, new eInvalid...

docComment($doc, $file, $line)

I18nAudit.php:486

The @title/@label/@description of a docblock: keys, unless a template made only of placeholders.

protected function docComment(string $doc, string $file, int $line): void
$docstring
$filestring
$lineint
retournevoid

isIgnored($file, $line)

tIgnoreFile.php:38
protected function isIgnored(string $file, int $line): bool
$filestring
$lineint
retourneboolwhether the ignore file leaves out a finding of this file (relative to the package) and line

IsText($text)

staticI18nAudit.php:344
protected static function IsText(string $text): bool
$textstring
retourneboolwhether a text is a key worth checking: letters, not only {placeholders}

key($side, $key, $file, $line)

I18nAudit.php:349

A text written for translation: French, it is a French literal; English, a key to find in a dictionary.

protected function key(string $side, string $key, string $file, int $line): void
$sidestring
$keystring
$filestring
$lineint
retournevoid

LooksFrench($text)

staticI18nAudit.php:331
static function LooksFrench(string $text): bool
$textstring
retourneboolwhether a text is French: an accented letter, or two French stop words (or elisions)

ParseJsDictionary($content, $lang)

staticI18nAudit.php:183
static function ParseJsDictionary(string $content, string $lang): array
$contentstring
$langstring
retournearraystring> the key: value pairs of the MMO.i18n.load('<lang>', {…}) of a script

PhpString($literal)

staticI18nAudit.php:477
static function PhpString(string $literal): string
$literalstring
retournestringthe value of a php string literal

readDictionaries($folder, $manifest)

I18nAudit.php:156
protected function readDictionaries(string $folder, array $manifest): array
$folderstring
$manifestarray
retournearrayarray<string, string>, js: array<string, string>, files: list<string>}

readIgnore($name)

tIgnoreFile.php:24
protected function readIgnore(string $name): void
$namestringthe ignore file, in the package's folder
retournevoid

ReadManifest($folder)

staticI18nAudit.php:113
static function ReadManifest(string $folder): ?array
$folderstring
retournenull | arraymixed>|null the mmo.json of a folder

run()

I18nAudit.php:244

Scan the package and check its keys.

function run(): array
retournearraymissing: array{php: list<array{0: string, 1: int, 2: string}>, js: list<array{0: string, 1: int, 2: string}>}, elsewhere: array{php: array<string, string>, js: array<string, string>}, conflicts: array<string, array<string, string>>, french: list<array{0: string, 1: int, 2: string}>, counts: array<string, int>, dictionaries: array<string, array{php: int, js: int, own: bool, files: list<string>}> }

scanHtml($html, $file, $lines, $lineOffset)

I18nAudit.php:528

Scan markup: its scripts (<script>, on*= attributes, {= … } expressions) as js, its text nodes and its attributes (but SKIP_ATTRIBUTES) for French.

protected function scanHtml( string $html, string $file, MMO\admin\helpers\LineIndex $lines, int $lineOffset = 0 ): void
$htmlstring
$filestring
$linesLineIndex
$lineOffset = 0intadded to the lines found (markup inside a string)
retournevoid

scanJs($content, $start, $end, $file, $lines, $untilBrace)

I18nAudit.php:502

Scan the script between two offsets of a file: its keys and its strings.

protected function scanJs( string $content, int $start, int $end, string $file, MMO\admin\helpers\LineIndex $lines, bool $untilBrace = false ): int
$contentstring
$startint
$endint
$filestring
$linesLineIndex
$untilBrace = falsebool
retourneint

Significant($tokens, $i, $dir)

staticI18nAudit.php:448
protected static function Significant(array $tokens, int $i, int $dir): int
$tokensarray
$iint
$dirint
retourneintthe index of the next (dir 1) or previous (dir -1) token that is not a space or a comment

sources($folder, $manifest)

I18nAudit.php:202
protected function sources(string $folder, array $manifest): array
$folderstring
$manifestarray
retournearraythe source folders of a package (its mmo.json sources)

text($text, $file, $line, $lines, $base)

I18nAudit.php:357

A text shown as is: French, it is reported (a template's markup is looked into: scanHtml).

protected function text( string $text, string $file, int $line, ?MMO\admin\helpers\LineIndex $lines = null, int $base = 0 ): void
$textstring
$filestring
$lineint
$lines = nullnull | LineIndex
$base = 0int
retournevoid

Walk($folder, $withI18n)

staticI18nAudit.php:215

Every file below a folder, but the folders never scanned, a symbolic link, a package of its own.

static function Walk(string $folder, bool $withI18n = false): Generator
$folderstring
$withI18n = falsebooltrue: the i18n folders too (where the dictionaries are)
retourneGenerator

withLineOffset($lineOffset, $fn)

I18nAudit.php:583

Run a scan whose lines are shifted (markup inside a php string).

protected function withLineOffset(int $lineOffset, callable $fn): mixed
$lineOffsetint
$fncallable
retournemixed

__construct($folder, $lang, $files)

I18nAudit.php:103
function __construct(string $folder, string $lang = 'fr', ?string $files = null)
$folderstringthe package's folder (its mmo.json)
$lang = 'fr'stringthe language audited
$files = nullnull | stringonly the files whose path (relative to the package) matches this glob, or is under this folder