Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
bim-g authored Jan 2, 2022
2 parents 97e85ad + 3665bd1 commit 31c5635
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions lang/fr/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
"`%s` is unknow"=>"`%s` n'est pas definit",
"`%s` should be a date."=>"`%s` devrait être une date.",
"`%s` should be greater than now"=>"`%s` devrait être plus grand que maintenant",
"`%s` should be a string"=>"`%s` doit est une chaine de caractere",
];
21 changes: 21 additions & 0 deletions src/Escape.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php


namespace Wepesi\app;

class i18n
{
static function translate(string $message,array $data=[]):string{
$file="./lang/".LANG."/language.php";
if(!is_file($file) && !file_exists($file)){
$file="./lang/en/language.php";
}
include($file);
$message_key=$message;
if(count($data)>0){
$key_value=!isset($language[$message])?null:$language[$message];
$message_key=$key_value!=null?vsprintf($key_value,$data):vsprintf($message,$data);
}
return $message_key;
}
}
4 changes: 2 additions & 2 deletions test/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"date_created"=>"2021-05-23"
];
$valid=new Validate($source);
// include "./test/string.php";
include "./test/string.php";
// include "./test/number.php";
// include "./test/boolean.php";
include "./test/date.php";
// include "./test/date.php";

0 comments on commit 31c5635

Please sign in to comment.