$lang_name ) { $af_locale_case_map[ strtolower( $strict_code ) ] = $strict_code; } } // --- STEP 1: RESOLVE SANDBOX ENVIRONMENTAL PATHS --- $af_translate_allowed_core_types = array( 'wordpress', 'core', 'default', 'admin', 'admin-network', 'continents-cities', 'network', 'continents', 'cities' ); $af_translate_is_core = in_array( $type, $af_translate_allowed_core_types, true ); $af_translate_sub_folder = $af_translate_is_core ? 'core' : ( ( 'plugin' === $type ) ? 'plugins' : 'themes' ); $af_translate_upload_info = wp_upload_dir(); $af_translate_safe_upload_dir = wp_normalize_path( trailingslashit( $af_translate_upload_info['basedir'] ) . "af-translate/{$af_translate_sub_folder}" ); $af_translate_is_main_core = ( $af_translate_is_core && ( empty( $slug ) || 'default' === $slug || 'core' === $slug || 'wordpress' === $slug ) ); $af_translate_matrix = array(); // 1a. Parse original files compiled from Vendor structures if ( ! empty( $summary['po_collection'] ) && is_array( $summary['po_collection'] ) ) { foreach ( $summary['po_collection'] as $af_translate_file ) { $af_translate_filename = basename( $af_translate_file ); if ( $af_translate_is_main_core ) { $af_translate_locale_code = str_replace( '.po', '', $af_translate_filename ); } else { if ( 0 === strpos( $af_translate_filename, $slug . '-' ) ) { $af_translate_locale_code = substr( $af_translate_filename, strlen( $slug . '-' ), -3 ); } else { $af_translate_locale_code = str_replace( '.po', '', $af_translate_filename ); } } $af_translate_locale_code = preg_replace( '/[^A-Za-z0-9_-]/', '', $af_translate_locale_code ); // Force clean casing map conversion matching strict locale rules $af_lower_locale = strtolower( $af_translate_locale_code ); if ( isset( $af_locale_case_map[ $af_lower_locale ] ) ) { $af_translate_locale_code = $af_locale_case_map[ $af_lower_locale ]; } $af_matrix_key = strtolower( $af_translate_locale_code ); $af_translate_matrix[ $af_matrix_key ] = array( 'locale_code' => $af_translate_locale_code, 'file_path' => $af_translate_file, 'filename' => $af_translate_filename, 'is_sandbox' => false, ); } } // 1b. Scan and overlay custom Sandboxed items from the Target Uploads directory if ( is_dir( $af_translate_safe_upload_dir ) ) { $af_translate_sandbox_files = glob( trailingslashit( $af_translate_safe_upload_dir ) . '*.po' ); if ( ! empty( $af_translate_sandbox_files ) && is_array( $af_translate_sandbox_files ) ) { foreach ( $af_translate_sandbox_files as $af_translate_file ) { $af_translate_filename = basename( $af_translate_file ); if ( $af_translate_is_main_core ) { $af_translate_locale_code = str_replace( '.po', '', $af_translate_filename ); } else { if ( 0 !== strpos( $af_translate_filename, $slug . '-' ) ) { continue; } $af_translate_locale_code = substr( $af_translate_filename, strlen( $slug . '-' ), -3 ); } $af_translate_locale_code = preg_replace( '/[^A-Za-z0-9_-]/', '', $af_translate_locale_code ); $af_lower_locale = strtolower( $af_translate_locale_code ); if ( isset( $af_locale_case_map[ $af_lower_locale ] ) ) { $af_translate_locale_code = $af_locale_case_map[ $af_lower_locale ]; } // Injecting cleanly via lowercased tracking matrix index to guarantee sandbox item overrides vendor item $af_matrix_key = strtolower( $af_translate_locale_code ); $af_translate_matrix[ $af_matrix_key ] = array( 'locale_code' => $af_translate_locale_code, 'file_path' => $af_translate_file, 'filename' => $af_translate_filename, 'is_sandbox' => true, ); } } } // --- STEP 2: RENDER COMPREHENSIVE LOCALIZATION LINES --- if ( empty( $af_translate_matrix ) ) { echo ''; } else { foreach ( $af_translate_matrix as $af_matrix_key => $af_translate_data ) { $af_translate_locale_code = $af_translate_data['locale_code']; $af_translate_target_file = $af_translate_data['file_path']; $af_translate_filename = $af_translate_data['filename']; $af_translate_is_sandbox = $af_translate_data['is_sandbox']; $af_translate_lang_name = isset( $af_translate_all_locales[ $af_translate_locale_code ] ) ? $af_translate_all_locales[ $af_translate_locale_code ] : $af_translate_locale_code; $af_translate_metrics = AF_Translate_Analyzer::analyze_po_file( $af_translate_target_file ); $af_translate_mod_time = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), filemtime( $af_translate_target_file ) ); $af_translate_total = isset( $af_translate_metrics['total'] ) ? (int) $af_translate_metrics['total'] : 0; $af_translate_trans = isset( $af_translate_metrics['translated'] ) ? (int) $af_translate_metrics['translated'] : 0; $af_translate_pct_val = isset( $af_translate_metrics['percentage'] ) ? (int) $af_translate_metrics['percentage'] : 0; $af_translate_pending = $af_translate_total - $af_translate_trans; $af_translate_edit_url = add_query_arg( array( 'action' => 'edit', 'lang' => $af_translate_locale_code ), $base_action_url ); ?>
' . esc_html__( 'No translations found. Click "Add New Language" above to start.', 'af-translate' ) . '
[]
| | | |
%