Skip to content

Commit 7acbcda

Browse files
wachterjohannesluca-rath
authored andcommitted
04 - Add additional languages to the website
1 parent 82c2319 commit 7acbcda

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

config/routes_website.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Define your website routes here
22

33
app.event:
4-
path: /event/{id}
4+
path: /{_locale}/event/{id}
55
controller: App\Controller\Website\EventWebsiteController::indexAction

config/webspaces/example.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<localizations>
1111
<!-- See: http://docs.sulu.io/en/latest/book/localization.html how to add new localizations -->
1212
<localization language="en" default="true"/>
13+
<localization language="de"/>
14+
<localization language="fr"/>
1315
</localizations>
1416

1517
<default-templates>
@@ -48,22 +50,22 @@
4850
<environments>
4951
<environment type="prod">
5052
<urls>
51-
<url language="en">{host}</url>
53+
<url>{host}/{localization}</url>
5254
</urls>
5355
</environment>
5456
<environment type="stage">
5557
<urls>
56-
<url language="en">{host}</url>
58+
<url>{host}/{localization}</url>
5759
</urls>
5860
</environment>
5961
<environment type="test">
6062
<urls>
61-
<url language="en">{host}</url>
63+
<url>{host}/{localization}</url>
6264
</urls>
6365
</environment>
6466
<environment type="dev">
6567
<urls>
66-
<url language="en">{host}</url>
68+
<url>{host}/{localization}</url>
6769
</urls>
6870
</environment>
6971
</environments>

templates/base.html.twig

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
</li>
4242
{% endfor %}
4343
</ul>
44+
45+
<div class="navbar-nav">
46+
{% for locale, url in urls %}
47+
<a class="nav-link" href="{{ sulu_content_path(url, null, locale) }}">{{ locale }}</a>
48+
{% endfor %}
49+
</div>
4450
</div>
4551
</nav>
4652
</div>

tests/Functional/Controller/Website/EventWebsiteControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testIndexAction(): void
2929
{
3030
$event = $this->createEvent('Sulu is awesome', 'en');
3131

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

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

tests/Functional/Pages/HomepageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testHomepage(): void
5050
]
5151
);
5252

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

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

0 commit comments

Comments
 (0)