Open chadanuk opened 8 years ago
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 :)
I know this issue is quite old, but are there any plans on multi-language support for the backend or is this abandoned?
Seems like someone made some progress in this regard but didn't finish it. If I get some support, I would implement the feature
Coaster fits all my needs for a Laravel CMS except multi-language support.
EDIT: Now I'm confused: is this issue about having different languages in the admin backend or creating multilingual pages?
@Paluschki It isn't too tricky actually, (it's not built in out of the box yet). See #25
The key is to add a new language in the database table languages
.
The admin will then display a language switcher (https://github.com/Web-Feet/coasterframework/blob/f4ad185076d996cc80de928f2442368bffb34f37/src/Helpers/Admin/View/AdminMenu.php#L33)
On the front end then you'll need to add a form that submits a way to set the language..
$languageId = Request::input('lang');
\CoasterCms\Models\Language::set($languageId);
OR you may want to override the Coaster routes in routes/web.php
if you want domain/lang/route
type routes to be somthing like...
// catch all (rest must be cms pages)
Route::any('{lang}/{other}', ['uses' => 'CmsController@generatePage'])->middleware('language.change')->where('other', '.*');
The language.change
middleware would have the logic to change the language, something like:
$languages = ['en-gb' => 'English', 'fr-fr' => 'French'];
$language = Language::where('language', array_search($request->route->parameter('lang')->first(), $languages));
\CoasterCms\Models\Language::set($language->id);
Also little bit more info here on building a form for a frontend switcher, and also url changing: https://github.com/Web-Feet/coasterdocs/blob/master/languages.md
And if you want to use the default language as a fallback for content you can set frontend.language_fallback to 1 in the settings table (maybe need to add new row)
It would be nice if you can manage different languages in the backend.