Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Last active December 15, 2015 06:09
Show Gist options
  • Save raphaelchaib/5213876 to your computer and use it in GitHub Desktop.
Save raphaelchaib/5213876 to your computer and use it in GitHub Desktop.
PHP: Localization configuration
<?php
/* -------------------- LOCALIZATION -------------------- */
// PHP INI charset
ini_set("default_charset", "UTF-8");
// Default timezone
date_default_timezone_set('America/Sao_Paulo');
// Verify if there is some GET with choosed language
if( isset($_GET['lang']) ) {
$_SESSION[get_site_config('lang_session')] = $_GET['lang'];
header( 'Location: ' . get_site_info('url'));
}
// Default language
$locale = "pt_BR";
// Verify if there is any session iniciated with other language
if (isset( $_SESSION[get_site_config('lang_session')] ))
$locale = $_SESSION[get_site_config('lang_session')];
// Language configuration and .pot location
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("messages", "./locale");
textdomain("messages");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment