Skip to content

Commit

Permalink
Merge pull request #598 from bolt/feature/frontend-locale-switcher
Browse files Browse the repository at this point in the history
 Locale switcher (language select) for the frontend.
  • Loading branch information
bobdenotter authored Aug 23, 2019
2 parents 249d6b8 + 7e15ce3 commit 8389f26
Show file tree
Hide file tree
Showing 16 changed files with 658 additions and 385 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"miljar/php-exif": "^0.6.4",
"nelmio/cors-bundle": "^1.5",
"nesbot/carbon": "^1.38 || ^2.19",
"peterkahl/country-code-to-emoji-flag": "^0.9.1",
"php-translation/symfony-bundle": "^0.8",
"phpdocumentor/reflection-docblock": "^4.3",
"psr/simple-cache": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion config/bolt/contenttypes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ homepage:
group: meta
viewless: true
taxonomy: [ categories, tags, foobars ]
locales: ['en', 'nl', 'pt_BR', 'es', 'hu']
locales: ['en', 'nl', 'ja', 'nb']
singleton: true
default_status: published
icon_many: "fa:home"
Expand Down
2 changes: 1 addition & 1 deletion config/packages/translation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ framework:
translation:
webui:
enabled: true
locales: ['en', 'nl', 'es', 'fr', 'de', 'pl', 'it', 'hu', 'pt_BR']
locales: ['en', 'nl', 'es', 'fr', 'de', 'pl', 'it', 'hu', 'pt_BR', 'is', 'jp', 'nb', 'dk', 'pl']
edit_in_place:
enabled: false
configs:
Expand Down
2 changes: 1 addition & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
parameters:
locale: 'en'
# This parameter defines the codes of the locales (languages) enabled in the application
app_locales: en|nl|nl_NL|nl_BE|es|fr|de|pl|it|hu|pt_BR
app_locales: en|nl|es|fr|de|pl|it|hu|pt_BR|ja|nb|nn|nl_NL|nl_BE
app.notifications.email_sender: anonymous@example.com
doctrine.orm.entity_manager.class: Bolt\Doctrine\TranslatableEntityManager
stof_doctrine_extensions.listener.translatable.class: Bolt\Event\Listener\PreTranslatableListener
Expand Down
2 changes: 0 additions & 2 deletions public/theme/skeleton/partials/_aside.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

</div>


{# The next section iterates over all of the content types, and prints a list
of the five latest records of each of them. The 'magic' happens in the
setcontent tag.. ct.slug ~ "/latest/3" concatenates the slug of the
Expand All @@ -65,7 +64,6 @@
</ul>
<p><a href="{{ path('listing', {'contentTypeSlug': ct.slug}) }}">{{ __('contenttypes.generic.overview',{'%contenttypes%': ct.name}) }} &raquo;</a></p>


{% endfor %}

{{ widgets('aside_bottom') }}
Expand Down
6 changes: 6 additions & 0 deletions public/theme/skeleton/partials/_footer.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

<hr>

<h4>{{ __('general.phrase.select_language') }}</h4>

{% include 'helpers/_languageselect.html.twig' with {'type': 'select'} %}

<hr>

<p>
{{ __('general.phrase.built-with-bolt') }}
</p>
Expand Down
16 changes: 0 additions & 16 deletions src/Controller/Frontend/ListingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,4 @@ public function listing(ContentRepository $contentRepository, Request $request,

return $this->renderTemplate($templates, $twigVars);
}

/**
* Route alias for Bolt 3 backwards compatibility
*
* @deprecated since 4.0
*
* @Route(
* "/{contenttypeslug}",
* name="contentlisting",
* requirements={"contenttypeslug"="%bolt.requirement.contenttypes%"},
* methods={"GET"})
*/
public function contentListing(ContentRepository $contentRepository, Request $request, string $contenttypeslug): Response
{
return $this->listing($contentRepository, $request, $contenttypeslug);
}
}
5 changes: 3 additions & 2 deletions src/Controller/TwigAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\HttpFoundation\Response;
use Tightenco\Collect\Support\Collection;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;

class TwigAwareController extends AbstractController
{
Expand Down Expand Up @@ -86,8 +87,8 @@ private function setTwigLoader(): void
/** @var NativeFilesystemLoader $twigLoaders */
$twigLoaders = $this->twig->getLoader();

if ($twigLoaders instanceof NativeFilesystemLoader) {
$twigLoaders->addPath($this->config->getPath('theme'), '__main__');
if ($twigLoaders instanceof FilesystemLoader) {
$twigLoaders->prependPath($this->config->getPath('theme'), '__main__');
}
}

Expand Down
Loading

0 comments on commit 8389f26

Please sign in to comment.