#!/bin/bash

# Set source and destination repositories
SRC_REPO="/root/dev/NextERP/dev/Viindoo/odoo-18.0"
DEST_REPO="/root/dev/NextERP/dev/odoo18/Odoo18"
LANG="vi"
# Ensure both paths exist
if [ ! -d "$SRC_REPO" ]; then
    echo "Error: Source repository does not exist!"
    exit 1
fi

if [ ! -d "$DEST_REPO" ]; then
    echo "Error: Destination repository does not exist!"
    exit 1
fi

# Find and copy vi.po files while preserving directory structure
cd "$SRC_REPO" || exit
find . -type f -name "${LANG}.po" | while read -r file; do
    # Get the directory path of the file
    dir_path=$(dirname "$file")

    # Ensure the destination directory exists
    mkdir -p "$DEST_REPO/$dir_path"

    # Copy the file
    cp "$file" "$DEST_REPO/$dir_path/"
    
    echo "Copied: $file -> $DEST_REPO/$dir_path/"
done

echo "All ${LANG}.po files copied successfully!"