make(Language::class, [ 'ini_array' => [ 'some.key' => 'Some value', 'language.dateformat' => 'IGNORED', 'language.timeformat' => 'IGNORED', ], '__' => fn (string $index) => $index === 'language.dateformat' ? 'm/d/Y' : 'H:i', ]); $payload = (new I18nService($language))->buildJsDictionary(); // The JS wrapper is present. $this->assertStringContainsString('leantime', $payload); $this->assertStringContainsString('i18n', $payload); $this->assertStringContainsString('dictionary:', $payload); // Extract the JSON dictionary and assert the overrides won. preg_match('/dictionary: (\{.*\}),/', $payload, $matches); $this->assertNotEmpty($matches, 'Could not find dictionary JSON in payload'); $decoded = json_decode($matches[1], true); $this->assertSame('Some value', $decoded['some.key']); $this->assertSame('m/d/Y', $decoded['language.dateformat']); $this->assertSame('H:i', $decoded['language.timeformat']); $this->assertArrayHasKey('usersettings.timezone', $decoded); } }