<?php

function smarty_function_translate_type($params, &$smarty)
{
    if (empty($params['type'])) {
        throw new InvalidArgumentException('Missing required parameter \'type\'');
    }

    $type = $params['type'];

    // preferred:
    // e.g. $txt_str['deliveryPriceLists']['navigation'] = 'Ceníky dopravy'
    if ($typeName = translate('navigation', $type, true)) {
        return $typeName;
    }

    // e.g. $txt_str['navigation']['deliveryDelivery'] = 'Dopravy'
    if ($typeName = translate($type, 'navigation', true)) {
        return $typeName;
    }

    return $type;
}
