CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: max(four, four)?
(Example: nine)

The Note You're Voting On

jon at ardentcreative dot co dot uk
19 years ago
This can be used for quick and dirty internationalization:

<?php
$GLOBALS
['strings']['example'] = "There are %d people.";

// Loads a phrase from the translations list in lang/$lang/phrases.php
function t() {
$args = func_get_args();
$nArgs = func_num_args();

$phrase = array_shift($args);
$nArgs--;

include_once(
"../lang/" . lang() . "/phrases.php");
if (isset(
$GLOBALS['strings'][$phrase])) {
return
vsprintf($GLOBALS['strings'][$phrase], $args);
} else {
return
'<span style="color: #ff0000">Untranslated string: ' . $phrase . '</span>';
}
}
?>

<< Back to user notes page

To Top