$value) { is_array($value) ? $flatten($value, $prefix.$key.'.') : $flat[$prefix.$key] = (string) $value; } }; $flatten($lines, ''); return $flat; } function placeholdersOf(string $text): array { // A placeholder starts a word: "ALV:n" (Finnish case ending) is not one. preg_match_all('/(? array_map('basename', glob(dirname(__DIR__, 2).'/lang/fi/*.php'))); it('has every Finnish text in English with the same placeholders', function (string $file) { expect(file_exists(dirname(__DIR__, 2)."/lang/en/{$file}"))->toBeTrue("lang/en/{$file} is missing"); $finnish = translationLines('fi', $file); $english = translationLines('en', $file); expect(array_keys($english))->toEqualCanonicalizing(array_keys($finnish)); foreach ($finnish as $key => $text) { expect(placeholdersOf($english[$key]))->toBe(placeholdersOf($text), "Placeholders differ in {$file}: {$key}"); } })->with('translation files');