Skip to content

Instantly share code, notes, and snippets.

@rduarte
Created January 7, 2009 16:12
Show Gist options
  • Save rduarte/44316 to your computer and use it in GitHub Desktop.
Save rduarte/44316 to your computer and use it in GitHub Desktop.
<?php
$manager_strings['Bem_Vindo'] = 'Bem vindo ao meu site, %s';
$manager_strings['Noticias_introducao'] = 'Quanto é %s + %s + %s?';
?>
<?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) ""
?>
<?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