'AUTO / WORDPRESS', 'en' => 'English', 'de' => 'Deutsch', 'es' => 'Español', 'fr' => 'Français', 'pt' => 'Português', 'it' => 'Italiano', 'tr' => 'Türkçe', 'ru' => 'Русский', ); } public static function catalog( $language = '' ) { $language = $language ?: self::current(); if ( 'en' === $language || ! in_array( $language, self::SUPPORTED, true ) ) { return array(); } $file = EDRAD_DIR . 'languages/' . $language . '.json'; if ( ! is_readable( $file ) ) { return array(); } $data = json_decode( (string) file_get_contents( $file ), true ); return is_array( $data ) ? $data : array(); } public static function t( $english, $language = '' ) { $catalog = self::catalog( $language ); if ( isset( $catalog[ $english ] ) && '' !== $catalog[ $english ] ) { return $catalog[ $english ]; } $patterns = array( '/^(\d+) signals share temporal or component proximity\.$/' => array( '{count} signals share temporal or component proximity.', 'count' ), '/^(\d+) no-change completion signal\(s\) were identified and excluded\.$/' => array( '{count} no-change completion signal(s) were identified and excluded.', 'count' ), '/^Signals resolve to the same component: (.+)\.$/' => array( 'Signals resolve to the same component: {component}.', 'component' ), '/^Impact and deployment reference the same component: (.+)\.$/' => array( 'Impact and deployment reference the same component: {component}.', 'component' ), '/^(\d+) attributable deployment signal\(s\) detected\. No unrelated system drift found\.(?: (\d+) no-change completion signal\(s\) neutralized\.)?$/' => array( '{count} attributable deployment signal(s) detected. No unrelated system drift found.{noops}', 'deployment' ), '/^Fatal impact followed a recorded change to the same component: (.+)\. Investigation recommended\.$/' => array( 'Fatal impact followed a recorded change to the same component: {component}. Investigation recommended.', 'component' ), '/^This capsule predates response-context capture\. It proves a PHP fatal in (.+), but cannot prove whether the visible request failed\.$/' => array( 'This capsule predates response-context capture. It proves a PHP fatal in {component}, but cannot prove whether the visible request failed.', 'component' ), '/^The fatal impact is attributed to (.+), but no exact version transition is preserved in this capsule\.$/' => array( 'The fatal impact is attributed to {component}, but no exact version transition is preserved in this capsule.', 'component' ), ); foreach ( $patterns as $pattern => $definition ) { if ( ! preg_match( $pattern, $english, $match ) ) { continue; } $template = $catalog[ $definition[0] ] ?? $definition[0]; if ( 'count' === $definition[1] ) { return str_replace( '{count}', $match[1], $template ); } if ( 'component' === $definition[1] ) { return str_replace( '{component}', $match[1], $template ); } $noops = empty( $match[2] ) ? '' : ' ' . ( $catalog['{count} no-change completion signal(s) neutralized.'] ?? '{count} no-change completion signal(s) neutralized.' ); $noops = str_replace( '{count}', $match[2] ?? '', $noops ); return str_replace( array( '{count}', '{noops}' ), array( $match[1], $noops ), $template ); } if ( 'de' === ( $language ?: self::current() ) ) { if ( preg_match( '/^(.+) begins at line (\d+); the parser stopped at line (\d+)\.$/', $english, $match ) ) { return $match[1] . ' beginnt in Zeile ' . $match[2] . '; der Parser stoppte in Zeile ' . $match[3] . '.'; } if ( preg_match( '/^Inspect the block beginning at line (\d+); do not mistake parser stop line (\d+) for the defect origin\.$/', $english, $match ) ) { return 'Den in Zeile ' . $match[1] . ' beginnenden Block prüfen; Parser-Stoppzeile ' . $match[2] . ' nicht mit dem Fehlerursprung verwechseln.'; } if ( preg_match( '/^(.+) changed from (.+) to (.+) before impact on the same component\.$/', $english, $match ) ) { return $match[1] . ' wurde vor der Auswirkung auf dieselbe Komponente von ' . $match[2] . ' auf ' . $match[3] . ' geändert.'; } if ( preg_match( '/^Restore (.+) to known-good version (.+) using a trusted package or backup\.$/', $english, $match ) ) { return $match[1] . ' mit einem vertrauenswürdigen Paket oder Backup auf die bekannte funktionierende Version ' . $match[2] . ' zurücksetzen.'; } if ( preg_match( '/^Isolate (.+) in a staging copy or recovery session; do not delete its files\.$/', $english, $match ) ) { return $match[1] . ' in einer Staging-Kopie oder Wiederherstellungssitzung isolieren; Dateien nicht löschen.'; } } return $english; } public static function tf( $english, array $values = array(), $language = '' ) { $text = self::t( $english, $language ); foreach ( $values as $name => $value ) { $text = str_replace( '{' . $name . '}', (string) $value, $text ); } return $text; } }