It should be "trivial", but after some chating on #laravel irc channel, I found it may be impossible for now. But I'll ask it here before doing it the ugly-go-horse way just to have the project done. If it's indeed impossible by current means, I'll fill a request on github (after handing over the project to my client).
I'm using Zizaco\\Confide
to handle authentication in my service. It uses Laravel Lang
everywhere to get strings in one of the 8 bundled languages of the package. But I need to override some of those strings, and I don't want to modify the package files (which would defeat the whole purpose of Composer). How can I do this?
For example, I needed to modify confide::confide.alerts.wrong_credentials
for pt_BR
language. What I tried so far:
/app/lang/pt_BR/confide.php
file, with contents return array('alerts' => array('wrong_credentials' => '...'))
. It works for Lang::get('confide.alerts.wrong_credentials')
but not for the namespaced Lang::get('confide::confide.alerts.wrong_credentials')
/app/lang/pt_BR/packages/zizaco/confide/confide.php
with return array('alerts' => ......)
/app/lang/pt_BR/packages/zizaco/confide/confide/alerts.php
with return array('wrong_credentials' => ...)
/app/lang/packages/zizaco/confide/pt_BR/confide.php
with array('alerts' => array('wrong_credentials' => '...'))
- /app/lang/packages/zizaco/confide/pt_BR/confide/alerts.php
with return array('wrong_credentials' => ...)
Any clue on what am I missing? Or does Laravel4 really lacks this feature?
Thanks in advance!
actually it fixed in Laravel 4.1 core
you can now overwrite it by doing
app/lang/packages/(locale)/confide/confide.php
check this
So, as for today, Laravel really does lack this feature. I've asked for it creating a issue on github .
Meanwhile, this functionality could be achieved seamlessly using crynobone's Orchestra Platform 2 Translation Component, which can be found here
All you need to do is require
it in composer.json
{
"require": {
"orchestra/translation": "2.0.*"
}
}
and replace the original translation package ( 'Illuminate\\Translation\\TranslationServiceProvider'
) in /config/app.php
'providers' => array(
//'Illuminate\Translation\TranslationServiceProvider',
// ...
'Orchestra\Translation\TranslationServiceProvider',
),
That's it! Now, having app/lang/en/packages/confide/confide.php
will do it! (please note that the path should be /packages/ packagename /, not /packages/vendor/packagename/
It really saved me from a big headache, hope others find this useful too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.