Skip to content
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

Langauge selection for users #25

Open
sarpaykent opened this issue Dec 11, 2016 · 17 comments
Open

Langauge selection for users #25

sarpaykent opened this issue Dec 11, 2016 · 17 comments

Comments

@sarpaykent
Copy link

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

@neil-jennings
Copy link
Contributor

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);

@jva91
Copy link

jva91 commented Jul 4, 2017

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

@SarajevoNo1
Copy link

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:

@SarajevoNo1
Copy link

What should I do to fix this issue, and where I need to change in code...?

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 13, 2017

Lang.txt
This is my code in Middleware file:

@chadanuk
Copy link
Contributor

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

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 14, 2017 via email

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 14, 2017 via email

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 14, 2017 via email

@tliesnham
Copy link
Contributor

tliesnham commented Jul 14, 2017

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

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 14, 2017 via email

@tliesnham
Copy link
Contributor

Oops, missed the closing apostrophe. I've since edited my last comment.

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 14, 2017 via email

@SarajevoNo1
Copy link

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 :)

@chadanuk
Copy link
Contributor

Thanks for pushing us on this @SarajevoNo1 :)

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 18, 2017 via email

@SarajevoNo1
Copy link

SarajevoNo1 commented Jul 18, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants