Last active
December 15, 2015 06:09
-
-
Save raphaelchaib/5213876 to your computer and use it in GitHub Desktop.
PHP: Localization configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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