Saudi Arabia has sentenced dozens of foreign construction workers to lashes and jail for a protest held several months ago over unpaid wages.