<?php 
defined('ABSPATH') or die("You can't access this file directly.");

require_once( qcld_seohelp_PLUGIN_DIRNAME. '/autoload.php');

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
use MrMySQL\YoutubeTranscript\Exception\NoTranscriptFoundException;
use MrMySQL\YoutubeTranscript\TranscriptListFetcher;



if ( ! function_exists( 'qcld_seohelp_youtube_subtitle_to_content_page' ) ) {
    function qcld_seohelp_youtube_subtitle_to_content_page() {

?>
<div class="wrap fs-section wrap-img-Generator Single-content-wrap">
    <?php $seo_help_url = esc_url(admin_url('admin.php?page=qcld-seo-other-features')); ?>
    <div style="margin: 15px 0 25px 0;">
        <a href="<?php echo esc_url($seo_help_url); ?>" class="button button-secondary">
            <span class="dashicons dashicons-arrow-left-alt"></span>
            <?php esc_html_e('Back to SEO Help Page', 'seo-help'); ?>
        </a>
    </div>
    <h2><?php esc_html_e('YouTube Subtitle to Article Generator', "seo-help" ); ?></h2>
    <div>
        <div class="qcld-seohelp-outer">
            <div class="qcld-seohelp qcld_seohelp_ai_single_content">
                <div class="qcld-seohelp-input">
                    <div class="qcld-seohelp-input-field qcld-seohelp-input-video-wrap">
                        <p class="qcld_youtube_article_msg"><?php esc_html_e( "This is a new and unique feature. If you have any feedback to improve this feature or if you are facing any issues,", "seo-help" ); ?> <a href="<?php echo esc_url('https://www.dna88.com/support-free/'); ?>" target="_blank"><?php esc_html_e( "please let us know.", "seo-help" ); ?></a> <?php esc_html_e( "We will take actions ASAP.", "seo-help" ); ?></p>
                        <p class="qcld_youtube_article_msg"><?php esc_html_e( "YouTube has rate limit feature. The limit is based on the speed of your requests. If you are blocked, the duration is typically temporary, often lasting from a few hours to 24 hours.", "seo-help" ); ?></p>
                        <label for="qcld_youtube_video_id" class="form-label"><?php esc_html_e('YouTube Video ID', 'seo-help'); ?> <span class="qcld_youtube_ex">( <?php echo esc_attr( "EX: https://www.youtube.com/watch?v=" ); ?><b><?php echo esc_attr( "20eebO8zBYk"); ?></b> )</span> </label><br>
                        
                        <input type="text" id="qcld_youtube_video_id" class="form-control" placeholder="<?php esc_html_e( "Write YouTube Video ID", "seo-help" ); ?>"><br>
                        <p><?php esc_html_e( "Ex: YouTube Subtitle Generate from YouTube Video ID", "seo-help" ); ?></p>
                        <input type="hidden" id="qcld_youtube_language" value="<?php echo esc_attr( "en"); ?>">
                        <div class="qcld_subtitle_language_section"></div>

                        <button id="qcld_youtube_subtitle_generate" class="btn btn-info" ><?php esc_html_e('Generate Subtitle', 'seo-help'); ?></button>
                   
                    </div>
                </div>

                <hr/>
                <div class="qcld_youtube_subtitle_field"> 
                    <div class="qcld_youtube_subtitle_data" style="display: none">
                        <div class="qcld_youtube_subtitle_copied-content">
                            <div class="qcld_subtitle_copied-content btn d-none link-success">Copied</div>
                            <a class="btn btn-sm btn-secondary qcld_subtitle-copied-content"><span class="dashicons dashicons-admin-page"></span></a>
                        </div>
                        <textarea id="qcld_youtube_subtitle_result" class="form-control"></textarea>
                        <div class="qcld_youtube_subtitle_count_wrap"><span class="qcld_youtube_subtitle_count">1</span></div>
                            <p><div class="qcld_seohelp_pro_feature_text qcld_seohelp_pro_feature_btn"><?php esc_html_e('Pro Features', 'seo-help'); ?></div></p>
                            <div class="qcld-seohelp qcld_youtube_pro_feature_wrap">
                                <div class="qcld-seohelp-input qcld_seohelp_pro_feature_content">
                                    <div class="qcld-seohelp-input-field qcld-seohelp-input-field_ai_wrap">
                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_number_of_heading"><?php esc_html_e( "How many headings?", "seo-help" ); ?> </label>
                                            <input type="number" placeholder="e.g. 5" id="qcld_youtube_article_number_of_heading" class="qcld_youtube_article_number_of_heading" name="qcld_youtube_article_number_of_heading" value="" disabled>
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_tag"><?php esc_html_e( "Heading Tag", "seo-help" ); ?> </label>
                                            <select name="qcld_youtube_article_heading_tag" id="qcld_youtube_article_heading_tag" disabled>
                                                <option value="h1"><?php esc_html_e( "h1", "seo-help" ); ?></option>
                                                <option value="h2"><?php esc_html_e( "h2", "seo-help" ); ?></option>
                                                <option value="h3"><?php esc_html_e( "h3", "seo-help" ); ?></option>
                                                <option value="h4"><?php esc_html_e( "h4", "seo-help" ); ?></option>
                                                <option value="h5"><?php esc_html_e( "h5", "seo-help" ); ?></option>
                                                <option value="h6"><?php esc_html_e( "h6", "seo-help" ); ?></option>
                                            </select>
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_language"><?php esc_html_e( "Language", "seo-help" ); ?> </label>
                                            <select name="qcld_youtube_article_language" id="qcld_youtube_article_language" disabled>
                                                <option value="en"><?php esc_html_e( "English", "seo-help" ); ?> </option>
                                                <option value="ar"><?php esc_html_e( "Arabic", "seo-help" ); ?> </option>
                                                <option value="bg"><?php esc_html_e( "Bulgarian", "seo-help" ); ?> </option>
                                                <option value="zh"><?php esc_html_e( "Chinese", "seo-help" ); ?> </option>
                                                <option value="cs"><?php esc_html_e( "Czech", "seo-help" ); ?> </option>
                                                <option value="nl"><?php esc_html_e( "Dutch", "seo-help" ); ?> </option>
                                                <option value="fr"> <?php esc_html_e( "French", "seo-help" ); ?> </option>
                                                <option value="de"> <?php esc_html_e( "German", "seo-help" ); ?> </option>
                                                <option value="el"> <?php esc_html_e( "Greek", "seo-help" ); ?> </option>
                                                <option value="hi"> <?php esc_html_e( "Hindi", "seo-help" ); ?> </option>
                                                <option value="hu"> <?php esc_html_e( "Hungarian", "seo-help" ); ?> </option>
                                                <option value="id"> <?php esc_html_e( "Indonesian", "seo-help" ); ?> </option>
                                                <option value="it"> <?php esc_html_e( "Italian", "seo-help" ); ?> </option>
                                                <option value="ja"> <?php esc_html_e( "Japanese", "seo-help" ); ?> </option>
                                                <option value="ko"> <?php esc_html_e( "Korean", "seo-help" ); ?> </option>
                                                <option value="pl"> <?php esc_html_e( "Polish", "seo-help" ); ?> </option>
                                                <option value="pt"> <?php esc_html_e( "Portuguese", "seo-help" ); ?> </option>
                                                <option value="ro"> <?php esc_html_e( "Romanian", "seo-help" ); ?> </option>
                                                <option value="ru"> <?php esc_html_e( "Russian", "seo-help" ); ?> </option>
                                                <option value="es"> <?php esc_html_e( "Spanish", "seo-help" ); ?> </option>
                                                <option value="sv"> <?php esc_html_e( "Swedish", "seo-help" ); ?> </option>
                                                <option value="tr"> <?php esc_html_e( "Turkish", "seo-help" ); ?> </option>
                                                <option value="uk"> <?php esc_html_e( "Ukranian", "seo-help" ); ?> </option>
                                            </select>
                                        </div>

                                    </div>
                                </div>
                                <div class="qcld-seohelp-input qcld_seohelp_pro_feature_content">
                                    <div class="qcld-seohelp-input-field qcld-seohelp-input-field_ai_wrap">

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_style"><?php esc_html_e( "Writing Style", "seo-help" ); ?> </label>
                                            <select name="qcld_youtube_article_heading_style" id="qcld_youtube_article_heading_style" disabled>
                                                <option value="infor"><?php esc_html_e( "Informative", "seo-help" ); ?></option>
                                                <option value="analy"><?php esc_html_e( "Analytical", "seo-help" ); ?></option>
                                                <option value="argum"><?php esc_html_e( "Argumentative", "seo-help" ); ?></option>
                                                <option value="creat"><?php esc_html_e( "Creative", "seo-help" ); ?></option>
                                                <option value="criti"><?php esc_html_e( "Critical", "seo-help" ); ?></option>
                                                <option value="descr"><?php esc_html_e( "Descriptive", "seo-help" ); ?></option>
                                                <option value="evalu"><?php esc_html_e( "Evaluative", "seo-help" ); ?></option>
                                                <option value="expos"><?php esc_html_e( "Expository", "seo-help" ); ?></option>
                                                <option value="journ"><?php esc_html_e( "Journalistic", "seo-help" ); ?></option>
                                                <option value="narra"><?php esc_html_e( "Narrative", "seo-help" ); ?></option>
                                                <option value="persu"><?php esc_html_e( "Persuasive", "seo-help" ); ?></option>
                                                <option value="refle"><?php esc_html_e( "Reflective", "seo-help" ); ?></option>
                                                <option value="simpl"><?php esc_html_e( "Simple", "seo-help" ); ?></option>
                                                <option value="techn"><?php esc_html_e( "Technical", "seo-help" ); ?></option>
                                                <option value="repor"><?php esc_html_e( "Report", "seo-help" ); ?></option>
                                                <option value="resea"><?php esc_html_e( "Research", "seo-help" ); ?></option>
                                            </select>
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_tone"><?php esc_html_e( "Writing Tone", "seo-help" ); ?> </label>
                                            <select name="qcld_youtube_article_heading_tone" id="qcld_youtube_article_heading_tone" disabled>
                                                <option value="formal"><?php esc_html_e( "Formal", "seo-help" ); ?></option>
                                                <option value="asser"><?php esc_html_e( "Assertive", "seo-help" ); ?></option>
                                                <option value="cheer"><?php esc_html_e( "Cheerful", "seo-help" ); ?></option>
                                                <option value="humor"><?php esc_html_e( "Humorous", "seo-help" ); ?></option>
                                                <option value="informal"><?php esc_html_e( "Informal", "seo-help" ); ?></option>
                                                <option value="inspi"><?php esc_html_e( "Inspirational", "seo-help" ); ?></option>
                                                <option value="neutr"><?php esc_html_e( "Neutral", "seo-help" ); ?></option>
                                                <option value="profe"><?php esc_html_e( "Professional", "seo-help" ); ?></option>
                                                <option value="sarca"><?php esc_html_e( "Sarcastic", "seo-help" ); ?></option>
                                                <option value="skept"><?php esc_html_e( "Skeptical", "seo-help" ); ?></option>
                                                <option value="curio"><?php esc_html_e( "Curious", "seo-help" ); ?></option>
                                                <option value="disap"><?php esc_html_e( "Disappointed", "seo-help" ); ?></option>
                                                <option value="encou"><?php esc_html_e( "Encouraging", "seo-help" ); ?></option>
                                                <option value="optim"><?php esc_html_e( "Optimistic", "seo-help" ); ?></option>
                                                <option value="surpr"><?php esc_html_e( "Surprised", "seo-help" ); ?></option>
                                                <option value="worry"><?php esc_html_e( "Worried", "seo-help" ); ?></option>

                                
                                            </select>
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_img_size" ><?php esc_html_e('Image Size', 'seo-help'); ?> </label>
                                            <select name="qcld_youtube_article_img_size" id="qcld_youtube_article_img_size" disabled>
                                              <option value="1024x1024"><?php esc_html_e( "1024x1024", "seo-help" ); ?> </option>
                                              <option value="1792x1024"><?php esc_html_e('1792x1024', 'seo-help'); ?></option>
                                              <option value="1024x1792"><?php esc_html_e('1024x1792', 'seo-help'); ?></option>
                                            </select>
                                        </div>
                                    </div>        
                                </div>  

                                <div class="qcld-seohelp-input qcld_seohelp_pro_feature_content">
                                    <div class="qcld-seohelp-input-field qcld-seohelp-input-field_ai_wrap">

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_label_keywords_bold"><?php esc_html_e( "Make Keywords Bold", "seo-help" ); ?> </label>
                                            <input type="checkbox" id="qcld_youtube_article_label_keywords_bold" class="qcld_youtube_article_label_keywords_bold" name="qcld_youtube_article_label_keywords_bold" value="1" disabled />
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_img"><?php esc_html_e( "Add Image", "seo-help" ); ?> </label>
                                            <input type="checkbox" name="qcld_youtube_article_heading_img" id="qcld_youtube_article_heading_img" class="qcld_youtube_article_heading_img" value="1" disabled />
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_tagline"><?php esc_html_e( "Add Tagline", "seo-help" ); ?> </label>
                                            <input type="checkbox" id="qcld_youtube_article_heading_tagline"  name="qcld_youtube_article_heading_tagline" class="qcld_youtube_article_heading_tagline" value="1" disabled />
                                        </div>


                                    </div>
                                </div>
                                <div class="qcld-seohelp-input qcld_seohelp_pro_feature_content">
                                    <div class="qcld-seohelp-input-field qcld-seohelp-input-field_ai_wrap">

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_intro"><?php esc_html_e( "Add Introduction", "seo-help" ); ?> </label>
                                            <input type="checkbox" id="qcld_youtube_article_heading_intro" name="qcld_youtube_article_heading_intro" class="qcld_youtube_article_heading_intro" value="1" disabled />
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_conclusion"><?php esc_html_e( "Add Conclusion", "seo-help" ); ?> </label>
                                            <input type="checkbox" id="qcld_youtube_article_heading_conclusion" name="qcld_youtube_article_heading_conclusion" class="qcld_youtube_article_heading_conclusion" value="1" disabled />
                                        </div>

                                        <div class="qcld_seohelp_ai_con">
                                            <label for="qcld_youtube_article_heading_faq"><?php esc_html_e( "Add Faq", "seo-help" ); ?> </label>
                                            <input type="checkbox" id="qcld_youtube_article_heading_faq" name="qcld_youtube_article_heading_faq" class="qcld_youtube_article_heading_faq" value="1" disabled />
                                        </div>

                                    </div>
                                </div>   
                            </div> 


                            <div class="qcld_seohelp_ai_con qcld_youtube_article_humanize_text_con">
                                <input type="checkbox" id="qcld_youtube_article_humanize_text" name="qcld_youtube_article_humanize_text" class="qcld_youtube_article_humanize_text" value="1" disabled />
                                <label for="qcld_youtube_article_humanize_text"><?php esc_html_e( "Humanize Text (Pro Feature)", "seo-help" ); ?> </label>
                            </div>    
                            <button id="qcld_youtube_subtitle_rewrite_article" class="btn btn-info" disabled><?php esc_html_e( 'Rewrite subtitle as a Blog article', 'seo-help' ); ?></button>

                        <div class="qcld_youtube_subtitle_rewrite_data" style="display: none">
                            <div id="qcld_youtube_subtitle_rewrite_result">
                                <div class="qcld_youtube_subtitle_rewrite_copied_wrap">
                                    <div class="qcld_youtube_subtitle_rewrite_copied_content btn d-none link-success"><?php esc_html_e("Copied", 'seo-help'); ?></div>
                                    <a class="btn btn-sm btn-secondary qcld_youtube_subtitle_rewrite_copied_icon"><span class="dashicons dashicons-admin-page"></span></a>
                                </div>
                                <?php
                                    wp_editor('','qcld_youtube_subtitle_rewrite_result_msg', array('media_buttons' => false, 'textarea_name' => 'qcld_youtube_subtitle_rewrite_result_msg', 'editor_height' => 400 ) );
                                ?>
                                <div class="qcld_youtube_subtitle_rewrite_count_wrap">
                                    <div class="qcld_youtube_subtitle_rewrite_result_count"></div>
                                </div>
                                <p class="qcld_youtube_article_msg"><?php esc_html_e("**We highly recommend you review the article and correct mistakes and polish up to reflect your own identity", 'seo-help'); ?></p>
                                
                            </div>
                        </div>

                    </div>

                    <div class="qcld_youtube-playground-buttons" style="display: none">
                        <button class="button button-primary qcld_youtube_article_playground_save" disabled><?php esc_html_e("Save as Blog Post Draft", 'seo-help'); ?> <div class="qcld_seohelp_pro_feature_text"><?php esc_html_e('Pro Feature', 'seo-help'); ?></div></button>
                        <button class="button qcld_youtube_article_playground_clear"><?php esc_html_e("Clear", 'seo-help'); ?></button>
                    </div>
                </div>
            </div>
           
        </div>

      
    </div>
</div>

<?php 

    }
}


add_action( 'wp_ajax_qcld_youtube_subtitle_generate_by_ajax', 'qcld_youtube_subtitle_generate_by_ajax' );
add_action( 'wp_ajax_qcld_youtube_subtitle_generate_by_ajax', 'qcld_youtube_subtitle_generate_by_ajax' );
if ( ! function_exists( 'qcld_youtube_subtitle_generate_by_ajax' ) ) {
    function qcld_youtube_subtitle_generate_by_ajax(){

        check_ajax_referer( 'seo-help', 'security');

        if ( ! current_user_can( 'manage_options' ) ) {
            wp_send_json_error( esc_html( 'Unauthorized', 'seo-help' ) );
            wp_die();
        }


        $qcld_video_result = array(
            'status' => 'error',
            'msg'    => 'Something went wrong',
        );

  
        $qcld_video_id  = isset($_POST['video_id']) ? sanitize_text_field(wp_unslash($_POST['video_id'])) : '';
        $language       = isset($_POST['language']) ? sanitize_text_field(wp_unslash($_POST['language'])) : 'en';


        if ( isset( $qcld_video_id ) && !empty( $qcld_video_id ) ) {

                $all_youtube_languages = qcld_youtube_subtitle_getAvailableLanguages($qcld_video_id, $language );

                //if(!empty($all_youtube_languages)){
                    $qcld_video_result['language'] = $all_youtube_languages['data'];

                    $language = $all_youtube_languages['language'];
                //}

                $html = '';

                $video_id = $qcld_video_id;

                try {
                    $http_client = new Client();
                    $request_factory = new HttpFactory();
                    $stream_factory = new HttpFactory();
                    $fetcher = new TranscriptListFetcher($http_client, $request_factory, $stream_factory);
                    
                    // Fetch the list of available transcripts
                    $transcript_list = $fetcher->fetch($video_id);
                    //$language 
                    // Find the transcript for a specific language (e.g., English)
                    $transcript = $transcript_list->findTranscript([$language]);
                    
                    // If a transcript is found, proceed with fetching and displaying
                    $data = $transcript->fetch();
                    
                    $full_cleaned_text = '';
                    $pattern = '/\[[^\]]*\]|\([^\)]*\)/'; 
                    
                    if(!empty($data)){

                        foreach ($data as $segment) {
                            $startTime = $segment['start'];
                            $text = $segment['text'] . ' ';
                            //$html .=$text;
                            $cleaned_segment_text = preg_replace($pattern, '', $text);
                            // Append the cleaned text to the full_cleaned_text string,
                            // adding a space for separation.
                            $full_cleaned_text .= $cleaned_segment_text . ' ';
                            
                        }
                        //$qcld_video_result['title']   =  $qcld_video_id;
                        $qcld_video_result['data'] =  htmlspecialchars(trim($full_cleaned_text));
                        $qcld_video_result['status']  = 'success';
                        $html .= 'Data Successfully Generated.';

                    }

                } catch (NoTranscriptFoundException $e) {
                    // Catch the specific exception for no transcripts found
                    $html .=  "No subtitles were found for this video.";
                } catch (\Exception $e) {
                    // Catch any other general exceptions
                    $html .=  "An unexpected error occurred: " . htmlspecialchars($e->getMessage());
                }

            $qcld_video_result['msg'] = $html;

            wp_send_json( $qcld_video_result );
            wp_die();

        
        }


        wp_send_json( $qcld_video_result );
        wp_die();
    
    }

}



function qcld_youtube_subtitle_getAvailableLanguages(string $videoId, $language ) {


    $qcld_seohelp_result = array(
        'data'          => '',
        'language'      => $language,
    );

    try {
        $httpClient     = new Client();
        $httpFactory    = new HttpFactory();
        $fetcher        = new TranscriptListFetcher($httpClient, $httpFactory, $httpFactory);
        $transcriptList = $fetcher->fetch($videoId);
        $lang_codes     = $transcriptList->getAvailableLanguageCodes();
        
        $languages = [];
        // The foreach loop will not run if the $transcriptList is empty
        if (!empty($lang_codes)) {
            foreach ($lang_codes as $lang_code) {
                if(!empty($lang_code) ) {
                    $languages[$lang_code] = $lang_code;
                }
            }
        }

        $languages;
        $html = '';
        if(!empty($languages)){
            $language_deault = '';

            $all_youtube_languages = qcld_youtube_subtitle_language_list();
            $available_language_codes = $languages;

            // Create a new array to store the matched languages.
            $matched_languages = [];

            // Loop through the comprehensive list of all languages.
            foreach ($all_youtube_languages as $language_item) {
                // Check if the language code exists in the array of available codes.
                if (in_array($language_item['code'], $available_language_codes)) {
                    // If it exists, add the entire language entry to the new array.
                    $matched_languages[] = $language_item;
                    
                }
            }
            
            $language_status = true;
            $html .= '<h4>'.esc_html('Available Language:').'</h4>';
            $html .= '<p>'.esc_html('You can generate a subtitle in that language by clicking available language button.').'</p>';
            $html .= '<ul class="qcld_subtitle_language">';
            foreach ($matched_languages as $lang) {
                if($language == $lang['code'] ){
                    $language_status = false;
                $html .= '<li class="qcld_subtitle_lang_check qcld_subtitle_lang_active"  data-param="language" data-value="'.$lang['code'].'" >' . htmlspecialchars($lang['language']) . '</li>' . PHP_EOL;
                }else{
                    $language_deault = $lang['code'];
                $html .= '<li class="qcld_subtitle_lang_check"  data-param="language" data-value="'.$lang['code'].'">' . htmlspecialchars($lang['language']) . '</li>' . PHP_EOL;
                }
            }
            $html .= '</ul>';


            if($language_status){
                $qcld_seohelp_result['language']    = $language_deault;
            }
            $qcld_seohelp_result['data']            = $html;

            return $qcld_seohelp_result;
        }

        return $qcld_seohelp_result;


    } catch (\Exception $e) {
        // Return an empty array on failure, e.g., if no transcripts are found.
        // This is the key part to handle when the video has no subtitles.
        error_log("Error fetching available languages: " . $e->getMessage());
        return [];
    }
}


function qcld_youtube_subtitle_language_list(){
    
    // The language list array from the previous response.
    $language_list = [
      [ "code" => "af", "language" => "Afrikaans" ],
      [ "code" => "sq", "language" => "Albanian" ],
      [ "code" => "am", "language" => "Amharic" ],
      [ "code" => "ar", "language" => "Arabic" ],
      [ "code" => "hy", "language" => "Armenian" ],
      [ "code" => "as", "language" => "Assamese" ],
      [ "code" => "az", "language" => "Azerbaijani" ],
      [ "code" => "eu", "language" => "Basque" ],
      [ "code" => "be", "language" => "Belarusian" ],
      [ "code" => "bn", "language" => "Bengali" ],
      [ "code" => "bs", "language" => "Bosnian" ],
      [ "code" => "bg", "language" => "Bulgarian" ],
      [ "code" => "my", "language" => "Burmese" ],
      [ "code" => "ca", "language" => "Catalan" ],
      [ "code" => "ceb", "language" => "Cebuano" ],
      [ "code" => "zh", "language" => "Chinese (Simplified)" ],
      [ "code" => "zh-Hant", "language" => "Chinese (Traditional)" ],
      [ "code" => "co", "language" => "Corsican" ],
      [ "code" => "hr", "language" => "Croatian" ],
      [ "code" => "cs", "language" => "Czech" ],
      [ "code" => "da", "language" => "Danish" ],
      [ "code" => "nl", "language" => "Dutch" ],
      [ "code" => "en", "language" => "English" ],
      [ "code" => "eo", "language" => "Esperanto" ],
      [ "code" => "et", "language" => "Estonian" ],
      [ "code" => "fil", "language" => "Filipino" ],
      [ "code" => "fi", "language" => "Finnish" ],
      [ "code" => "fr", "language" => "French" ],
      [ "code" => "gl", "language" => "Galician" ],
      [ "code" => "ka", "language" => "Georgian" ],
      [ "code" => "de", "language" => "German" ],
      [ "code" => "el", "language" => "Greek" ],
      [ "code" => "gu", "language" => "Gujarati" ],
      [ "code" => "ht", "language" => "Haitian Creole" ],
      [ "code" => "ha", "language" => "Hausa" ],
      [ "code" => "haw", "language" => "Hawaiian" ],
      [ "code" => "iw", "language" => "Hebrew" ],
      [ "code" => "hi", "language" => "Hindi" ],
      [ "code" => "hmn", "language" => "Hmong" ],
      [ "code" => "hu", "language" => "Hungarian" ],
      [ "code" => "is", "language" => "Icelandic" ],
      [ "code" => "ig", "language" => "Igbo" ],
      [ "code" => "id", "language" => "Indonesian" ],
      [ "code" => "ga", "language" => "Irish" ],
      [ "code" => "it", "language" => "Italian" ],
      [ "code" => "ja", "language" => "Japanese" ],
      [ "code" => "jv", "language" => "Javanese" ],
      [ "code" => "kn", "language" => "Kannada" ],
      [ "code" => "kk", "language" => "Kazakh" ],
      [ "code" => "km", "language" => "Khmer" ],
      [ "code" => "rw", "language" => "Kinyarwanda" ],
      [ "code" => "ko", "language" => "Korean" ],
      [ "code" => "ku", "language" => "Kurdish" ],
      [ "code" => "ky", "language" => "Kyrgyz" ],
      [ "code" => "lo", "language" => "Lao" ],
      [ "code" => "la", "language" => "Latin" ],
      [ "code" => "lv", "language" => "Latvian" ],
      [ "code" => "lt", "language" => "Lithuanian" ],
      [ "code" => "lb", "language" => "Luxembourgish" ],
      [ "code" => "mk", "language" => "Macedonian" ],
      [ "code" => "mg", "language" => "Malagasy" ],
      [ "code" => "ms", "language" => "Malay" ],
      [ "code" => "ml", "language" => "Malayalam" ],
      [ "code" => "mt", "language" => "Maltese" ],
      [ "code" => "mi", "language" => "Maori" ],
      [ "code" => "mr", "language" => "Marathi" ],
      [ "code" => "mn", "language" => "Mongolian" ],
      [ "code" => "ne", "language" => "Nepali" ],
      [ "code" => "no", "language" => "Norwegian" ],
      [ "code" => "or", "language" => "Odia" ],
      [ "code" => "om", "language" => "Oromo" ],
      [ "code" => "ps", "language" => "Pashto" ],
      [ "code" => "fa", "language" => "Persian" ],
      [ "code" => "pl", "language" => "Polish" ],
      [ "code" => "pt", "language" => "Portuguese" ],
      [ "code" => "pa", "language" => "Punjabi" ],
      [ "code" => "qu", "language" => "Quechua" ],
      [ "code" => "ro", "language" => "Romanian" ],
      [ "code" => "ru", "language" => "Russian" ],
      [ "code" => "sm", "language" => "Samoan" ],
      [ "code" => "sa", "language" => "Sanskrit" ],
      [ "code" => "gd", "language" => "Scottish Gaelic" ],
      [ "code" => "sr", "language" => "Serbian" ],
      [ "code" => "sn", "language" => "Shona" ],
      [ "code" => "sd", "language" => "Sindhi" ],
      [ "code" => "si", "language" => "Sinhala" ],
      [ "code" => "sk", "language" => "Slovak" ],
      [ "code" => "sl", "language" => "Slovenian" ],
      [ "code" => "so", "language" => "Somali" ],
      [ "code" => "es", "language" => "Spanish" ],
      [ "code" => "su", "language" => "Sundanese" ],
      [ "code" => "sw", "language" => "Swahili" ],
      [ "code" => "sv", "language" => "Swedish" ],
      [ "code" => "tg", "language" => "Tajik" ],
      [ "code" => "ta", "language" => "Tamil" ],
      [ "code" => "tt", "language" => "Tatar" ],
      [ "code" => "te", "language" => "Telugu" ],
      [ "code" => "th", "language" => "Thai" ],
      [ "code" => "ti", "language" => "Tigrinya" ],
      [ "code" => "ts", "language" => "Tsonga" ],
      [ "code" => "tr", "language" => "Turkish" ],
      [ "code" => "tk", "language" => "Turkmen" ],
      [ "code" => "uk", "language" => "Ukrainian" ],
      [ "code" => "ur", "language" => "Urdu" ],
      [ "code" => "ug", "language" => "Uyghur" ],
      [ "code" => "uz", "language" => "Uzbek" ],
      [ "code" => "vi", "language" => "Vietnamese" ],
      [ "code" => "cy", "language" => "Welsh" ],
      [ "code" => "fy", "language" => "Western Frisian" ],
      [ "code" => "xh", "language" => "Xhosa" ],
      [ "code" => "yi", "language" => "Yiddish" ],
      [ "code" => "yo", "language" => "Yoruba" ],
      [ "code" => "zu", "language" => "Zulu" ]
    ];


    return $language_list;
    
}