Пример #1
0
 public function testDefaultLocaleUsPosix()
 {
     locale_set_default('en_US_POSIX');
     $datetime = new \ebussola\common\datatype\DateTime('2014-08-19 03:00:00');
     $datetime_str = (string) $datetime;
     $this->assertEquals('08/19/2014 03:00:00 am', $datetime_str);
 }
Пример #2
0
 public function testPeriodByTime()
 {
     locale_set_default('pt_BR');
     $period = new \ebussola\common\datatype\datetime\Period(new Time('13:00'), new DateInterval('PT1H'), new Time('18:00'));
     $i = 1;
     foreach ($period as $time) {
         switch ($i) {
             case 1:
                 $this->assertEquals('13:00:00', (string) $time);
                 break;
             case 2:
                 $this->assertEquals('14:00:00', (string) $time);
                 break;
             case 3:
                 $this->assertEquals('15:00:00', (string) $time);
                 break;
             case 4:
                 $this->assertEquals('16:00:00', (string) $time);
                 break;
             case 5:
                 $this->assertEquals('17:00:00', (string) $time);
                 break;
             case 6:
                 $this->assertEquals('18:00:00', (string) $time);
                 break;
         }
         $i++;
     }
     $this->assertCount(6, $period);
 }
Пример #3
0
 /**
 	Initialize the locale.
 
 	The parameters array can contain:
 	* auto:		Whether to automatically try to select the best locale based on the HTTP_ACCEPT_LANGUAGE header.
 	* default:	The default locale to use when others aren't available.
 
 	@param $aParams The parameters listed above.
 */
 public function __construct($aParams = array())
 {
     function_exists('locale_set_default') or burn('ConfigurationException', _WT('The intl PHP extension is required by the weeLocale application driver.'));
     if (!empty($aParams['default'])) {
         locale_set_default($aParams['default']) or burn('InvalidArgumentException', _WT('Setting the default locale failed.'));
     }
     if (!empty($aParams['auto']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         try {
             $this->set(locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']));
         } catch (UnexpectedValueException $e) {
             //TODO:maybe try the default locale here and otherwise go back to 'C'?
         }
     }
 }
Пример #4
0
 public static function applyLocale($newlocale)
 {
     self::$locale = $newlocale;
     //TODO Allow locale to be overriden by GET request?
     //if($_GET['lang']) $locale = $_GET['lang'];
     locale_set_default(self::$locale);
     //$language = locale_get_display_language(self::$locale, 'en');
     $lang = locale_get_primary_language(self::$locale);
     //$region = locale_get_display_region(self::$locale);
     T_setlocale(LC_MESSAGES, $lang);
     T_bindtextdomain("grase", "/usr/share/grase/locale");
     T_bind_textdomain_codeset("grase", "UTF-8");
     T_textdomain("grase");
 }
Пример #5
0
 public function testGeneralUse()
 {
     $amount = new Currency(50, 'pt_BR');
     $this->assertEquals('R$50,00', (string) $amount);
     $amount = new Currency(50, 'en_US');
     $this->assertEquals('$50.00', (string) $amount);
     locale_set_default('pt_BR');
     $amount = new Currency(-50);
     $this->assertEquals('(R$50,00)', (string) $amount);
     $amount = new Currency('(40,00)');
     $this->assertEquals('(R$40,00)', (string) $amount);
     $amount->setFormat('{number} = {symbol}');
     $this->assertEquals('(40,00 = R$)', (string) $amount);
 }
Пример #6
0
function ut_main()
{
    $res_str = '';
    $lang = ut_loc_get_default();
    $res_str .= "Default locale: {$lang}";
    $res_str .= "\n";
    locale_set_default('de-DE');
    $lang = ut_loc_get_default();
    $res_str .= "Default locale: {$lang}";
    $res_str .= "\n";
    ini_set('intl.default_locale', 'fr');
    $lang = ut_loc_get_default();
    $res_str .= "Default locale: {$lang}";
    $res_str .= "\n";
    ini_restore("intl.default_locale");
    return $res_str;
}
 protected function tearDown()
 {
     locale_set_default('pt_BR');
 }
<?php

/**
 * @file fecha.php
* @version 1.0
* @author V�ctor Cuervo (http://lineadecodigo.com)
* @date   31-agosto-2013
* @url    http://lineadecodigo.com/php/xxx/
* @description Programa que nos muestra el mes del a�o en el que estamos
*/
date_default_timezone_set("Europe/Madrid");
locale_set_default('es-ES');
echo "Ahora estamos en el mes de " . date("F");
 /**
  * @param string $locale
  * @param string $defaultLocale
  */
 protected function setConfigurationLocale($locale, $defaultLocale)
 {
     locale_set_default($defaultLocale);
     $this->locale = $locale;
 }
Пример #10
0
 public function testToString()
 {
     locale_set_default('pt_BR');
     $time = new \ebussola\common\datatype\datetime\Time('13:15:20');
     $this->assertEquals('13:15:20', (string) $time);
 }
Пример #11
0
 /**
  * Constructor
  *
  * @param ObjectConfig $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     //Create the transport queue
     $this->_queue = $this->getObject('lib:object.queue');
     //Attach the request transport handlers
     $transports = (array) ObjectConfig::unbox($config->transports);
     foreach ($transports as $key => $value) {
         if (is_numeric($key)) {
             $this->attachTransport($value);
         } else {
             $this->attachTransport($key, $value);
         }
     }
     //Set the trusted proxies
     $this->setProxies(ObjectConfig::unbox($config->proxies));
     //Set files parameters
     $this->setFiles($config->files);
     //Set cookie parameters
     $this->setCookies($config->cookies);
     //Set the base URL
     $this->setBaseUrl($config->base_url);
     //Set the base path
     $this->setBasePath($config->base_path);
     //Set the formats
     foreach (ObjectConfig::unbox($config->formats) as $format => $mimetypes) {
         $this->addFormat($format, $mimetypes);
     }
     //Receive the request
     $this->receive();
     // Set timezone to user's settings
     date_default_timezone_set($this->getTimezone());
     // Set language to user's settings
     locale_set_default($this->getLanguage());
 }
Пример #12
0
 /**
  * Sets the language
  *
  * The language should be a properly formatted language tag, eg xx-XX
  * @link https://en.wikipedia.org/wiki/IETF_language_tag
  * @link https://tools.ietf.org/html/rfc5646
  * @see $language
  *
  * @param string $language  The language tag
  * @return TranslatorAbstract
  */
 public function setLanguage($language)
 {
     if ($this->__language != $language) {
         $this->__language = $language;
         //Set runtime locale information for date and time formatting
         setlocale(LC_TIME, $language);
         //Sets the default runtime locale
         locale_set_default($language);
         //Clear the catalogue
         $this->getCatalogue()->clear();
         //Load the library translations
         $this->load(dirname(dirname(__FILE__)) . '/resources/language');
     }
     return $this;
 }
Пример #13
0
 public function setUp()
 {
     locale_set_default('pt_BR');
 }
Пример #14
0
        echo "Error: Cannot open <{$filename}>\n";
        exit(1);
    }
    $zip->extractTo($out);
    $zip->close();
}
/**
 * Script entry point
 */
$_LANGUAGES = array();
echo "Generating iso-639 data.\n\n";
echo "This script takes a long time to complete.\n";
echo "Please wait...\n\n";
// Set the default locale to english
if (false === locale_set_default('en_US')) {
    if (false === locale_set_default('en_US')) {
        echo "Error: Unable to set the default locale to English.\n";
        exit(1);
    }
}
// Download the ISO-639 file in UTF-8 from
// http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
$lines = file_get_contents("http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt");
// Remove UTF-8 BOM (0xEF,0xBB,0xBF)
$lines = substr($lines, 3);
// Split into single lines
$lines = explode("\n", $lines);
// Allow translations from package isocodes
translate_with_pkg_isocodes();
// Build the array from the file contents
echo "Gathering ISO 639 data\n";
Пример #15
0
    Configure::write('Cache._cake_core_.duration', '+1 years');
}
/**
 * Set server timezone to UTC. You can change it to another timezone of your
 * choice but using UTC makes time calculations / conversions easier.
 */
date_default_timezone_set('America/Sao_Paulo');
/**
 * Configure the mbstring extension to use the correct encoding.
 */
mb_internal_encoding(Configure::read('App.encoding'));
/**
 * Set the default locale. This controls how dates, number and currency is
 * formatted and sets the default language to use for translations.
 */
locale_set_default('en_US');
/**
 * Register application error and exception handlers.
 */
$isCli = php_sapi_name() === 'cli';
if ($isCli) {
    (new ConsoleErrorHandler(Configure::read('Error')))->register();
} else {
    (new ErrorHandler(Configure::read('Error')))->register();
}
// Include the CLI bootstrap overrides.
if ($isCli) {
    require __DIR__ . '/bootstrap_cli.php';
}
/**
 * Set the full base URL.
Пример #16
0
<?php

// Definição do Timezone no PHP
date_default_timezone_set('America/Sao_Paulo');
// Definição de Locale Padrão
locale_set_default('pt_BR');
// Apresentação
return array('db' => array('driver' => 'pgsql', 'database' => 'balance', 'username' => 'balance', 'password' => 'balance', 'hostname' => 'localhost', 'port' => '5432'));
/**
 * Sets/gets the default internal value of the locale id (for the intl extension, ICU).
 * @param string $locale (optional)	The locale id to be set. When it is omitted, the function returns (gets, reads) the default internal value.
 * @return mixed						When the function sets the default value, it returns TRUE on success or FALSE on error. Otherwise the function returns as string the current default value.
 */
function _api_set_default_locale($locale = null)
{
    static $default_locale = 'en';
    if (!empty($locale)) {
        $default_locale = $locale;
        if (INTL_INSTALLED) {
            return @locale_set_default($locale);
        }
        return true;
    } else {
        if (INTL_INSTALLED) {
            $default_locale = @locale_get_default();
        }
    }
    return $default_locale;
}
Пример #18
0
 protected function tearDown()
 {
     locale_set_default($this->saveLocale);
 }
Пример #19
0
array_shift($argv);
//remove program name
$argc--;
if ($argc == 3) {
    list($code, $namespace, $destDir) = $argv;
    $useLocale = false;
} else {
    list($code, $namespace, $destDir, $locale) = $argv;
    $useLocale = true;
}
if (!file_exists($destDir)) {
    echo "Invalid destination directory: {$destDir}\n";
    exit(-2);
}
$code = strtoupper($code);
if ($useLocale) {
    $saveLocale = locale_get_default();
    locale_set_default($locale);
}
try {
    $director = new CurrencyDirector(new StringType($code), new StringType($namespace), new StringType($destDir));
    $director->build();
    echo "Finished. {$code}.php written to {$destDir}\n";
} catch (\InvalidArgumentException $e) {
    echo $e->getMessage() . PHP_EOL;
    exit(-3);
}
if ($useLocale) {
    locale_set_default($saveLocale);
}
exit(0);
Пример #20
0
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>Locales</title>
</head>
<body style="font-size: 18pt;">
<?php # Script 14.5 - locales.php

// Set the default timezone:
date_default_timezone_set('UTC');

// Need a date object:
$d = new DateTime();

// Create a list of locales:
$locales = array('en_US', 'fr_FR', 'es_BO', 'zh_Hans_CN', 'ru_RU', 'el_GR', 'is_IS');

// Print the date in each locale:
foreach ($locales as $locale) {

	// Set the locale:
	locale_set_default($locale);
	
	// Print the date:
	echo "<p>$locale: " . strtotitle(date_format_locale($d, 'l, j F Y')) . "</p>\n";

}

?>
</body>
</html>