Comments (7)
5th Jan 2010, Mark Story said:
Why? What does this fix? What issues does it solve? Removing a function and replacing it with floating code seems like a poor idea to me.
from cakephp.
5th Jan 2010, NaMB said:
Sorry, you misread, I wasn't very clear, let me rephrase.
I think this portion of code in the _setLocale function :
$I18n->l10n->get(Configure::read('Config.language'));
should be replaced with this :
if (!$I18n->l10n->found)
$I18n->l10n->get(Configure::read('Config.language'));
This allows to set the locale manually by calling l10n->get() prior to db calls, thereby overriding Config.language (which would remain as a fallback).
Amongst other advantages, this would alleviate the over-reliance on the config class to store the current language (which doesn't sound like the right place to store a runtime specific value, but that's a debate we can leave for another time).
from cakephp.
5th Jan 2010, Mark Story said:
Configure is the correct place to store runtime configuration. That's pretty much its sole purpose, to store runtime configuration.
from cakephp.
5th Jan 2010, NaMB said:
Mmh, ok, now I'm thinking over this, I realize I'm using Config.language as a default language, which isn't right either I guess. So I guess there are actually two different issues here, each of which should probably be tackled as a whole.
- The runtime-language is stored in two different places : in Config.language and in l10n. I think it should be centralized in l10n. Especially since l10n doesn't keep the two in sync
- The config class should, on the other hand, be used to define a default language. Currently, this is done with the DEFAULT_LANGUAGE global. That should be changed to Config::read('Config.defaultLanguage');. As a sidenote, I see no used to check for it twice :
function __construct() {
if (defined('DEFAULT_LANGUAGE')) {
$this->default = DEFAULT_LANGUAGE;
}
parent::__construct();
}
and
function __setLanguage($language = null) {
$langKey = null;
if ($language !== null && isset($this->__l10nMap[$language]) && isset($this->__l10nCatalog[$this->__l10nMap[$language]])) {
$langKey = $this->__l10nMap[$language];
} else if ($language !== null && isset($this->__l10nCatalog[$language])) {
$langKey = $language;
} else if (defined('DEFAULT_LANGUAGE')) {
$langKey = DEFAULT_LANGUAGE;
}
so that last bit should be changed to :
@@@php
} else if ($this->default) {
$langKey = $this->default;
}
Should I open separate tickets ?
from cakephp.
5th Jan 2010, NaMB said:
Configure is the correct place to store runtime configuration.
Except that I would say that, in an internationalized website, the language isn't runtime configuration at all, it's a dynamic value.
from cakephp.
Config.language
can be saved in and read from the session, which is documented in the CookBook:
http://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html#localization-in-cakephp
class AppController extends Controller {
public function beforeFilter() {
if ($this->Session->check('Config.language')) {
Configure::write('Config.language', $this->Session->read('Config.language'));
}
}
}
Also DEFAULT_LANGUAGE
is deprecated:
http://book.cakephp.org/2.0/en/appendices/2-4-migration-guide.html#l10n
The constant
DEFAULT_LANGUAGE
has been deprecated in favor of Configure valueConfig.language
.
That makes the ticket obsolete, right?
from cakephp.
I think so 👍
from cakephp.
Related Issues (20)
- DatabaseException : "Cannot describe requests. It has 0 columns" after Cakephp update HOT 13
- 4.5: Stack trace off in CLI
- EntityRoute does not support enum fields HOT 3
- Cake\I18n\DateTime changes value when converted to JSON if the year is "0000" HOT 5
- Extending Collection causes infinite loop HOT 4
- CakePHP 5.0 PHPUnit support causing fatal errors HOT 5
- Can not catch `DatabaseException` HOT 1
- dev_error_stacktrace shows <?php even when it's not php code HOT 3
- Test fails on linux mint
- Session.timeout does not override anything HOT 15
- Consider allowing unbuffered queries for ORM SelectQuery HOT 6
- Connection aliasing only happens after migrations are run HOT 1
- 5.x typo in enum value HOT 4
- assertEventFiredWith causes a warning for non-string values
- 5.x: Enum mapped field in `find('list')` throws TypeError HOT 1
- Update from Cakephp 5.0.3 -> 5.0.4 CellTrait issue HOT 1
- 5.next: Add version of installed plugin to `bin/cake plugin list` HOT 12
- `Hash::remove()` doesn't work if a child element is an object HOT 3
- Issue with Security::decrypt() in App\Model\Entity\Member HOT 7
- No way how to change rounding strategy in NumberHelper HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cakephp.