Skip to content
Browse files

Enabling g11n specific environment settings.

  • Loading branch information...
1 parent 94ae9b1 commit 8741bbbabbd3a0b32189aca19fe9b907557cb1b5 @davidpersson davidpersson committed with gwoo Feb 13, 2010
View
18 app/config/bootstrap/g11n.php
@@ -6,13 +6,31 @@
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
+use \lithium\core\Environment;
+use \lithium\g11n\Locale;
use \lithium\g11n\Catalog;
use \lithium\g11n\Message;
use \lithium\util\Inflector;
use \lithium\util\Validator;
use \lithium\net\http\Media;
/**
+ * Adds globalization specifc settings to the evironment.
+ *
+ * The settings for the current locale, time zone and currency are kept as environment
+ * settings. This allows for _centrally_ switching, _transparently_ setting and retrieving
+ * globalization related settings.
+ *
+ * The environment settings are:
+ * - `'locale'` The effective locale. Defaults to `'en'`.
+ * - `'availableLocales'` Application locales available. Defaults to `array('en')`.
+ */
+Environment::set('development', array(
+ 'locale' => 'en',
+ 'availableLocales' => array('en')
+));
+
+/**
* Globalization (g11n) catalog configuration. The catalog allows for obtaining and
* writing globalized data. Each configuration can be adjusted through the following settings:
*
View
3 libraries/lithium/g11n/Message.php
@@ -81,8 +81,7 @@ class Message extends \lithium\core\StaticObject {
public static function translate($id, $options = array()) {
$defaults = array(
'count' => 1,
- // 'locale' => Environment::get('g11n.locale'),
- 'locale' => 'root',
+ 'locale' => Environment::get('locale'),
'scope' => null,
'default' => null,
'noop' => false
View
6 libraries/lithium/tests/cases/g11n/MessageTest.php
@@ -25,11 +25,17 @@ public function setUp() {
));
$data = function($n) { return $n == 1 ? 0 : 1; };
Catalog::write('message.plural', 'root', $data, array('name' => 'runtime'));
+
+ $this->_backups['environment'] = Environment::get('test');
+ Environment::set('test', array('locale' => 'en'));
+ Environment::set('test');
}
public function tearDown() {
Catalog::reset();
Catalog::config($this->_backups['catalogConfig']);
+
+ Environment::set('test', $this->_backups['environment']);
}
public function testTranslateBasic() {

0 comments on commit 8741bbb

Please sign in to comment.
Something went wrong with that request. Please try again.