Created
January 7, 2009 16:12
-
-
Save rduarte/44316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$manager_strings['Bem_Vindo'] = 'Bem vindo ao meu site, %s'; | |
$manager_strings['Noticias_introducao'] = 'Quanto é %s + %s + %s?'; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('txt_db.php'); | |
include('txt_func.php'); | |
echo txt('Bem_Vindo', 'Zé das Couves'); | |
// Bem vindo ao meu site, Zé das Couves | |
echo txt('Noticias_introducao', 1, 2, 3); | |
// Quanto é 1 + 2 + 3? | |
echo txt(''); | |
// NULL[] | |
echo txt(1,2); | |
// NULL[1] | |
var_dump(txt()); | |
// string(0) "" | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function txt(){ | |
/* TODO: | |
* 1. Trocar arquivo com Array por Componente no Tecmedia Manager | |
* 2. Notificar (email/rss) quando string não estiver no banco. | |
*/ | |
global $manager_strings; | |
$arrString = func_get_args(); | |
$return = ""; | |
$numArgs = func_num_args(); | |
if($numArgs > 0){ | |
$return = "NULL[".$arrString[0]."]"; | |
if(!empty($manager_strings[$arrString[0]])){ | |
$return = $manager_strings[$arrString[0]]; | |
if($numArgs > 1){ | |
$string_id = array_shift($arrString); | |
$return = vsprintf($manager_strings[$string_id], $arrString); | |
} | |
} | |
} | |
return $return; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment