<?php
function _ts_restrictions_translate_ws_message($message = '') {
$source = array(
'The maximum quantity allowed for (\w+) title groups is (\d+) per two-year cycle.',
'The maximum allotment of licenses for this (\w+) title group is (\d+) per two-year cycle.',
'The maximum quantity allowed for (\w+) server products is (\d+) per two-year cycle.',
'Your organization has already requested Get Genuine Full Windows operating system products. This is a one-time-only donation.',
'Get Genuine Windows full operating system requests are subject to a unique approval process, so you cannot combine them with any other products in a single cart. Please remove these products from your cart and complete the check-out process for the remaining products. Then place a second request for the Get Genuine Windows full operating systems.',
'You cannot combine products from the main Microsoft Donations Program with products from the Microsoft Direct Donations Program in a single cart.',
'You must order a minimum of (\d+) seats for (\w+) product orders.',
'You can order a maximum of (\d+) (\w+) items in (\w+). You have already ordered $annualOrdered and can not order any more.',
'You can order a maximum of (\d+) (\w+) items in (\w+). You have already ordered $annualOrdered and can only order (\d+) more.',
'You can order a maximum of (\d+) (\w+) title (\w+) in a fiscal year. You have already ordered (\d+) and can not order any more.',
'You can order a maximum of (\d+) (\w+) title (\w+) in a fiscal year. You have already ordered (\d+) and can only order (\d+) more.',
'There is a limit on the number of times you may request this (\w+) product. The quantity in your cart of product (\w+) exceeds the maximum number of allowable requests.',
);
$matches = array();
$count = 0;
foreach ($source as $pattern) {
if (preg_match('/' . $pattern . '/', $message, $matches)) {
array_shift($matches);
str_replace(array('(\w+)', '(\d+)'), array('@variable', '@variable'), $pattern, $count);
$t_variables = array();
for ($i = 0; $i < $count; $i++) {
$t_variable = '@variable' . $i;
str_replace('@variable', $t_variable, $pattern);
$t_variables[$t_variable] = $matches[$i];
}
return t($pattern, $t_variables);
}
}
}
var_dump(_ts_restrictions_translate_ws_message('The maximum quantity allowed for Microsoft title groups is 10 per two-year cycle.'));
Fatal error: Uncaught Error: Call to undefined function t() in /in/l56RP:30
Stack trace:
#0 /in/l56RP(36): _ts_restrictions_translate_ws_message('The maximum qua...')
#1 {main}
thrown in /in/l56RP on line 30
Process exited with code 255.