KumbiaPHP  beta2
Framework PHP
 Todo Estructuras de Datos Namespaces Archivos Funciones Variables Páginas
i18n.php
Ir a la documentación de este archivo.
1 <?php
23 bindtextdomain('default', APP_PATH . 'locale/');
24 textdomain('default');
25 
32 class I18n
33 {
34 
44  public static function get($sentence)
45  {
49  $sentence = gettext($sentence);
50 
54  if (func_num_args() > 1) {
55  $args = func_get_args();
59  unset($args[0]);
60  $sentence = vsprintf($sentence, $args);
61  }
62 
63  return $sentence;
64  }
65 
74  public static function nget($sentence1, $sentence2, $n)
75  {
79  $sentence = ngettext($sentence1, $sentence2, $n);
80 
84  if (func_num_args() > 3) {
85  $args = func_get_args();
89  unset($args[0], $args[1], $args[2]);
90  $sentence = vsprintf($sentence, $args);
91  }
92 
93  return $sentence;
94  }
95 
103  public static function cget($sentence, $category)
104  {
108  $sentence = dcgettext(textdomain(null), $sentence, $category);
109 
113  if (func_num_args() > 2) {
114  $args = func_get_args();
118  unset($args[0], $args[1]);
119  $sentence = vsprintf($sentence, $args);
120  }
121 
122  return $sentence;
123  }
124 
134  public function cnget($sentence1, $sentence2, $n, $category)
135  {
139  $sentence = dcngettext(textdomain(null), $sentence1, $sentence2, $n, $category);
140 
144  if (func_num_args() > 4) {
145  $args = func_get_args();
149  unset($args[0], $args[1], $args[2], $args[3]);
150  $sentence = vsprintf($sentence, $args);
151  }
152 
153  return $sentence;
154  }
155 
156 }