coastercms
coastercms copied to clipboard
Langauge selection for users
Hey,
I just quick look language system. I added my own language but, I want to let users change their language. So did I miss something or coaster isn't supporting it yet ?
Thanks
The admin side of things should work if you add another language but there is no front-end switch inbuilt yet, however you can implement your own.
One way would be to add a listener for \CoasterCms\Events\Cms\GeneratePage\InitializePageBuilder (which would run before any templates are loaded) and do something simple based on query strings.
$languageId = Request::input('lang');
\CoasterCms\Models\Language::set($languageId);
It would be nice if the cms knows when there is more than 1 language, a language chooser would be shown by default on the frontend
I create everything (new row for lang in database table, in headers add code, create new and add in Middleware file, and add in Kernel.php). Now I get this error:
(1/1) FatalErrorExceptionCall to a member function send() on null
in index.php (line 56)
This is my code in Middleware file:
What should I do to fix this issue, and where I need to change in code...?
Lang.txt This is my code in Middleware file:
Hi @SarajevoNo1 It's probably because the routes are provided separately by Coaster, you'll need to copy this line
Route::any('{other}', ['uses' => 'CmsController@generatePage'])->where('other', '.*');
into your routes/web.php file and add the middleware -
Route::any('{other}', [['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
Also, make sure that in app/config.php the app route provider comes before the coaster cms route provider
Hi Daniel Thank you on answer I will try this now and I will send you an email if it working.
P.s. these two lines (two seperate piece of code) of code you have sent me I need to add both of them into routes/web.php ?! It is true?! .........
Are you available for freelancing on coaster if I need some more modification.
Can you give me your private email. Because I like coaster really much but I need help if I need something for modification to pay for that via paypal or etc ...
Tarik
Get Outlook for Androidhttps://aka.ms/ghei36
From: Daniel Chadwick Sent: Friday, July 14, 13:25 Subject: Re: [Web-Feet/coastercms] Langauge selection for users (#25) To: Web-Feet/coastercms Cc: SarajevoNo1, Mention
Hi @SarajevoNo1https://github.com/sarajevono1 It's probably because the routes are provided separately by Coaster, you'll need to copy this line
Route::any('{other}', ['uses' => 'CmsController@generatePage'])->where('other', '.*');
into your routes/web.php file and add the middleware -
Route::any('{other}', [['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
Also, make sure that in app/config.php the app route provider comes before the coaster cms route provider
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Web-Feet/coastercms/issues/25#issuecomment-315336989, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AatkBXbfUiPt8pvrhXp3m1FNpEZSJGmmks5sN1A-gaJpZM4LJ_gy.
Hi Daniel I tried to add this to web.php but in your second line of code that you sent me we had syntax error:
[cid:fbafd47e-ece1-401d-937c-90617b49b9f1]
Šalje: Daniel Chadwick [email protected] Poslano: 14. srpnja 2017. 13:25 Prima: Web-Feet/coastercms Kopija: SarajevoNo1; Mention Predmet: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Hi @SarajevoNo1https://github.com/sarajevono1 It's probably because the routes are provided separately by Coaster, you'll need to copy this line
Route::any('{other}', ['uses' => 'CmsController@generatePage'])->where('other', '.*');
into your routes/web.php file and add the middleware -
Route::any('{other}', [['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
Also, make sure that in app/config.php the app route provider comes before the coaster cms route provider
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Web-Feet/coastercms/issues/25#issuecomment-315336989, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AatkBXbfUiPt8pvrhXp3m1FNpEZSJGmmks5sN1A-gaJpZM4LJ_gy.
Hi Daniel are you there,
Did you get my last emails :)
I really need some help to implement this i dont understand why this is not implemented in Coastercms yet....
I get error when trying to add in web.php the second line of code you have sent me:
Route::any('{other}', [['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
Results
- Error: There is 1 more opening brackets '[' found This count is unaware if brackets are inside of a string * [['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
- PHP Syntax Check: Parse error: syntax error, unexpected '' => '' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in your code on line 1 * Route::any('{other}', [['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
Šalje: tarik s [email protected] Poslano: 14. srpnja 2017. 14:41 Prima: Web-Feet/coastercms Predmet: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Hi Daniel I tried to add this to web.php but in your second line of code that you sent me we had syntax error:
[cid:fbafd47e-ece1-401d-937c-90617b49b9f1]
Šalje: Daniel Chadwick [email protected] Poslano: 14. srpnja 2017. 13:25 Prima: Web-Feet/coastercms Kopija: SarajevoNo1; Mention Predmet: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Hi @SarajevoNo1https://github.com/sarajevono1 It's probably because the routes are provided separately by Coaster, you'll need to copy this line
Route::any('{other}', ['uses' => 'CmsController@generatePage'])->where('other', '.*');
into your routes/web.php file and add the middleware -
Route::any('{other}', [['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
Also, make sure that in app/config.php the app route provider comes before the coaster cms route provider
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Web-Feet/coastercms/issues/25#issuecomment-315336989, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AatkBXbfUiPt8pvrhXp3m1FNpEZSJGmmks5sN1A-gaJpZM4LJ_gy.
Hi @SarajevoNo1,
Dan is away this afternoon, I'll try to help the best I can.
It's probably worth removing the double square bracket before 'middleware' to fix the syntax error. Try the following:
Route::any('{other}', ['middleware' => 'lang', 'uses' => 'CmsController@generatePage'])->where('other', '.*');
Have you also checked that the app route provider in your app/config.php file comes before Coaster's route provider?
Hope that helps,
Taylor
Hi when I trying to paste your piece (that you sent me now) of code inside web.php it is again with error:
Route::any('{other}', ['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
[cid:01c2339f-664c-48b4-9637-44329a73b8ab]
Šalje: Taylor [email protected] Poslano: 14. srpnja 2017. 15:07 Prima: Web-Feet/coastercms Kopija: SarajevoNo1; Mention Predmet: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Hi @SarajevoNo1https://github.com/sarajevono1,
Dan is away this afternoon, I'll try to help the best I can.
It's probably worth removing the double square bracket before 'middleware' to fix the syntax error. Try the following:
Route::any('{other}', ['middleware' => 'lang', uses' => 'CmsController@generatePage'])->where('other', '.*');
Have you also checked that the app route provider in your app/config.php file comes before Coaster's route provider?
Hope that helps,
Taylor
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Web-Feet/coastercms/issues/25#issuecomment-315355271, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AatkBSpSxK715cfWnDreyq3adiERS6_Pks5sN2gtgaJpZM4LJ_gy.
Oops, missed the closing apostrophe. I've since edited my last comment.
I add this now in web.php ; but I still get the same error: http://juli.croatiago.com/
Route::any('{other}', ['uses' => 'CmsController@generatePage'])->where('other', '.*');
Route::any('{other}', ['middleware' => 'lang', 'uses' => 'CmsController@generatePage'])->where('other', '.*');
[cid:932afb1a-27ab-454a-a19f-92a8599abef4]
Šalje: Taylor [email protected] Poslano: 14. srpnja 2017. 15:15 Prima: Web-Feet/coastercms Kopija: SarajevoNo1; Mention Predmet: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Oops, missed the closing apostrophe. I've since edited my last comment.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Web-Feet/coastercms/issues/25#issuecomment-315356692, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AatkBUlAvWR_SSf_mappfzgKI0zQzJwQks5sN2nUgaJpZM4LJ_gy.
With Neils help we are at the finish line of the lang switcher implementing, and Please Neil do not forgot to update the script with new version here and in the demo version on your site !! :))
Danke :)
Thanks for pushing us on this @SarajevoNo1 :)
Nothing Chardwik I have a wish to write some documentation and send ypu ( maybe than you can read and fix if I write something wrong) about Lang Switcher.
And you can upload it on your blog or in github you can tell me and I can send you when finish it.
We havr finished 99% of work only thing has left is URL CHANGE WHEN CHANGE LANG - I am waiting for Neil's answer for right way to finish that line and add the real piece for that in Middleware file (created for Lang..). And than it is 100% finished.
Only you can add from settings thst we can automatic add new language instead of going to database and adding it from phpmyadmin manualy... That is it.!!
And I must say that Neil is real "BEAST" (Of course in positive mind).
Thanks Tarik :) :;))))))))
Get Outlook for Androidhttps://aka.ms/ghei36
From: Daniel Chadwick [email protected] Sent: Tuesday, July 18, 2017 8:18:26 PM To: Web-Feet/coastercms Cc: SarajevoNo1; Mention Subject: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Thanks for pushing us on this @SarajevoNo1https://github.com/sarajevono1 :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Web-Feet/coastercms/issues/25#issuecomment-316151052, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AatkBXwz8Mydq87X5rc02E6zluyDqRHAks5sPPbxgaJpZM4LJ_gy.
Chardwik.. (I wondered is this needed and is this important and can this be implemented updated what I write next:::). Maybe you can just help us with way of implementing or adding SITEMAP for this new language and content for that language. What we should do now when lang switcher is implemented in frontend 99%(just waiitng Neils answer for URL change to finish to 100%) in backend when adding new row for lang in database and fill content im backend on BOTH language what we need to do or better CAN YOU update the files im Coaster to havr generete Sitemap in both language when somebody add the other language and fill content diferentll like me... That will be the best to finish this proces I think it is great than Coaster we can have on 2 langauge :;))))))
With everything of implemented and with Sitemap it will be awesome !!!
Thanks Tarik
I love coaster
Get Outlook for Androidhttps://aka.ms/ghei36
From: tarik s [email protected] Sent: Wednesday, July 19, 2017 12:19:42 AM To: Web-Feet/coastercms; Web-Feet/coastercms Cc: Mention Subject: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Nothing Chardwik I have a wish to write some documentation and send ypu ( maybe than you can read and fix if I write something wrong) about Lang Switcher.
And you can upload it on your blog or in github you can tell me and I can send you when finish it.
We havr finished 99% of work only thing has left is URL CHANGE WHEN CHANGE LANG - I am waiting for Neil's answer for right way to finish that line and add the real piece for that in Middleware file (created for Lang..). And than it is 100% finished.
Only you can add from settings thst we can automatic add new language instead of going to database and adding it from phpmyadmin manualy... That is it.!!
And I must say that Neil is real "BEAST" (Of course in positive mind).
Thanks Tarik :) :;))))))))
Get Outlook for Androidhttps://aka.ms/ghei36
From: Daniel Chadwick [email protected] Sent: Tuesday, July 18, 2017 8:18:26 PM To: Web-Feet/coastercms Cc: SarajevoNo1; Mention Subject: Re: [Web-Feet/coastercms] Langauge selection for users (#25)
Thanks for pushing us on this @SarajevoNo1https://github.com/sarajevono1 :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Web-Feet/coastercms/issues/25#issuecomment-316151052, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AatkBXwz8Mydq87X5rc02E6zluyDqRHAks5sPPbxgaJpZM4LJ_gy.