<?php
/**
 * Create MO file from PO file
 * This file handles initial creation of compiled translation files
 */

// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Create MO file from PO file
 */
function flowdino_create_mo_file() {
    $po_file = FLOWDINO_WC_PLUGIN_PATH . 'languages/flowdino-fr_FR.po';
    $mo_file = FLOWDINO_WC_PLUGIN_PATH . 'languages/flowdino-fr_FR.mo';
    
    // Check if PO file exists
    if (!file_exists($po_file)) {
        return false;
    }
    
    // Include the generator
    if (file_exists(FLOWDINO_WC_PLUGIN_PATH . 'languages/generate-mo.php')) {
        include_once FLOWDINO_WC_PLUGIN_PATH . 'languages/generate-mo.php';
        if (function_exists('flowdino_check_and_generate_mo')) {
            return flowdino_check_and_generate_mo();
        }
    }
    
    return false;
}

// Auto-execute if called directly in CLI
if (php_sapi_name() === 'cli' && defined('FLOWDINO_WC_PLUGIN_PATH')) {
    flowdino_create_mo_file();
}
