Skip to content

Commit

Permalink
04 - Add additional languages to the website
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored and niklasnatter committed Oct 21, 2020
1 parent 7bf512d commit 5c8bf6e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/routes_website.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Define your website routes here

app.event:
path: /event/{id}
path: /{_locale}/event/{id}
controller: App\Controller\Website\EventWebsiteController::indexAction
10 changes: 6 additions & 4 deletions config/webspaces/example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<localizations>
<!-- See: http://docs.sulu.io/en/latest/book/localization.html how to add new localizations -->
<localization language="en" default="true"/>
<localization language="de"/>
<localization language="fr"/>
</localizations>

<default-templates>
Expand Down Expand Up @@ -48,22 +50,22 @@
<environments>
<environment type="prod">
<urls>
<url language="en">{host}</url>
<url>{host}/{localization}</url>
</urls>
</environment>
<environment type="stage">
<urls>
<url language="en">{host}</url>
<url>{host}/{localization}</url>
</urls>
</environment>
<environment type="test">
<urls>
<url language="en">{host}</url>
<url>{host}/{localization}</url>
</urls>
</environment>
<environment type="dev">
<urls>
<url language="en">{host}</url>
<url>{host}/{localization}</url>
</urls>
</environment>
</environments>
Expand Down
6 changes: 6 additions & 0 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
</li>
{% endfor %}
</ul>

<div class="navbar-nav">
{% for locale, url in urls %}
<a class="nav-link" href="{{ sulu_content_path(url, null, locale) }}">{{ locale }}</a>
{% endfor %}
</div>
</div>
</nav>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testIndexAction(): void
{
$event = $this->createEvent('Sulu is awesome', 'en');

$crawler = $this->client->request('GET', '/event/' . $event->getId());
$crawler = $this->client->request('GET', '/en/event/' . $event->getId());

$response = $this->client->getResponse();
$this->assertInstanceOf(Response::class, $response);
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Pages/HomepageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testHomepage(): void
]
);

$crawler = $this->client->request(Request::METHOD_GET, '/homepage');
$crawler = $this->client->request(Request::METHOD_GET, '/en/homepage');

$response = $this->client->getResponse();
$this->assertInstanceOf(Response::class, $response);
Expand Down

0 comments on commit 5c8bf6e

Please sign in to comment.