-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I change languages? #1
Comments
might want to ask you first, what version did you use of this package? |
Sorry, I use 1.1.0. |
Whoops, sorry. It should be fixed on 1.1.1 well if you change locale in set_locale(LC_ALL, \Config::get('app.locale')); |
It's alright :) Seems to be working now, except that I don't get the Swedish language to be loaded. Any ideas? :) |
I tried some sample
{!! _('We have e-mailed your password reset link!') !!}
'languages' => [
'en' => [
'locale' => 'en_US',
'encoding' => 'utf-8',
'plural_forms' => "nplurals=2; plural=(n != 1);",
],
'sv' => [
'locale' => 'sv_SE', // usually use IDLanguage_IDCountry format like suggested in phptal.org/manual/en/split/gettext.html
'encoding' => 'utf-8',
'plural_forms' => "nplurals=2; plural=(n != 1);",
],
],
& scan files on resources/views directory.
Route::get('lang/{id}', function($id) {
$lang = Config::get('gettext.languages.'.$id);
set_locale(LC_ALL, $lang['locale'].'.'.$lang['encoding']); // e.g. sv_SE.utf-8
bindtextdomain('messages', base_path('resources/locale')); // locate to correct path
textdomain('messages'); // set default domain
return view('test');
}); This test is on WINDOWS machine. Should be working on UNIX also since Unit Test passing on travis. |
Thank you very much! I really appreciate your help. For a newbie like me, it's not really obvious to set bindtextdomain and textdomain, didn't even realize set_locale existed before I looked in your tests. :) It would be nice to add these explanations to the readme file. Good work! |
Hello!
I'm sorry for probably being stupid, but how do I change the language?
I have set the language to 'sv' in app.php, but it's still in English.
Trying to do a set_locale results in undefined function.
Thank you in advance!
The text was updated successfully, but these errors were encountered: