forked from czukowski/I18n_Plural
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.php
40 lines (39 loc) · 1.12 KB
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Kohana translation/internationalization function with context support.
* The PHP function [strtr](http://php.net/strtr) is used for replacing parameters.
*
* ___(':count user is online', 1000, array(':count' => 1000));
* // 1000 users are online
*
* @uses I18n_Plural::get()
* @uses I18n_Form::get()
* @param string $string to translate
* @param mixed $context string form or numeric count
* @param array $values param values to insert
* @param string $lang target language
* @return string
*/
function ___($string, $context = 0, $values = NULL, $lang = NULL)
{
if (is_array($context) AND ! is_array($values))
{
// Assume no form is specified and the 2nd argument are parameters
$lang = $values;
$values = $context;
$context = 0;
}
if (is_numeric($context))
{
// Get plural form
$string = I18n_Plural::get($string, $context, $lang);
}
else
{
// Get custom form
$string = I18n_Form::get($string, $context, $lang);
}
return empty($values) ? $string : strtr($string, $values);
}
// Force load I18n class, if not done already
I18n::lang();