How can I translate my base.html.php
layout?
<!-- app/Resources/views/base.html.php -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
</head>
<body>
<?php echo $view['translator']->trans('Bye'); ?>
<div id="content">
<?php $view['slots']->output('body') ?>
</div>
</body>
</html>
<!-- app/Resources/translations/messages.de.xliff -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Bye</source>
<target>Auf Wiedersehen.</target>
</trans-unit>
</body>
</file>
</xliff>
I do have also for my bundle src/../Bundle/../translation/messages.de.xliff
. This works properly. It starts with id="1"
.
So how can I get the translation to work in base.html.php?
Is it possible to change also pics with different locale in the html?
You can put anything you want as a target string, so urls can be possible:
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>foo_image</source>
<target>images/foo.de.png</target>
</trans-unit>
</body>
</file>
</xliff>
<img src="<?= $view['translator']->trans('foo_image') ?>">