Add translateability
This commit is contained in:
parent
b017306382
commit
f687ce8e1e
4 changed files with 121 additions and 21 deletions
23
index.php
23
index.php
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
$app = new Silex\Application();
|
$app = new Silex\Application();
|
||||||
|
|
||||||
$app['debug'] = true;
|
$app['debug'] = true;
|
||||||
|
@ -9,15 +11,26 @@ $app->register(new Silex\Provider\TwigServiceProvider(), array(
|
||||||
'twig.path' => __DIR__.'/templates',
|
'twig.path' => __DIR__.'/templates',
|
||||||
));
|
));
|
||||||
|
|
||||||
$app->get('/', function () use ($app) {
|
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
|
||||||
return $app['twig']->render('index.twig', array(
|
'locale_fallback' => 'de',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$app['translator'] = $app->share($app->extend('translator', function($translator, $app) {
|
||||||
|
$translator->addResource('xliff', __DIR__.'/locales/de.xml', 'de');
|
||||||
|
$translator->addResource('xliff', __DIR__.'/locales/en.xml', 'en');
|
||||||
|
|
||||||
|
return $translator;
|
||||||
|
}));
|
||||||
|
|
||||||
|
$app->before(function(Request $request) use ($app){
|
||||||
|
$lang = $request->getPreferredLanguage(array('en', 'de'));
|
||||||
|
$app['translator']->setLocale($lang);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->post('/', function () use ($app) {
|
$app->get('/', function (Request $request) use ($app) {
|
||||||
return $app['twig']->render('index.twig', array(
|
return $app['twig']->render('registration_form.twig', array(
|
||||||
|
'errors' => array(),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
|
72
locales/de.xml
Normal file
72
locales/de.xml
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2
|
||||||
|
xliff-core-1.2-transitional.xsd"
|
||||||
|
version="1.2">
|
||||||
|
<file source-language="de" datatype="plaintext" original="file.ext">
|
||||||
|
<body>
|
||||||
|
<trans-unit id="1">
|
||||||
|
<source>Ein XMPP-Konto registrieren</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="2">
|
||||||
|
<source>Bitte behebe folgende Fehler bevor du weiter machen kannst</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="3">
|
||||||
|
<source>Benutzername</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="4">
|
||||||
|
<source>Gib hier deinen gewünschten Benutzernamen ein.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="5">
|
||||||
|
<source>Server</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="6">
|
||||||
|
<source>Wähle hier einen Servernamen aus. Deine XMPP-ID ist dann <span class="xmpp-id-preview">Benutzername@Servername</span></source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="7">
|
||||||
|
<source>E-Mail-Adresse</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="8">
|
||||||
|
<source>Gib hier eine gültige E-Mail-Adresse ein. Die Adresse wird benutzt um dir einen Validierungscode zu schicken, sie wird nicht gespeichert.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="9">
|
||||||
|
<source>Passwort</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="10">
|
||||||
|
<source>Bitte wähle ein starkes Passwort. Also mindestens 8, besser 12 oder mehr Zeichen mit einer möglichst großen Variation aus Klein- und Großbuchstaben, Zahlen und Sonderzeichen.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="11">
|
||||||
|
<source>Passwortwiederholung</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="12">
|
||||||
|
<source>Bitte wiederhole hier dein gewähltes Passwort um sicherzustellen, dass du dich auch nicht vertippt hast.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="13">
|
||||||
|
<source>Absenden</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="14">
|
||||||
|
<source>Abbrechen</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="15">
|
||||||
|
<source>Kein Benutzername angegeben.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="16">
|
||||||
|
<source>Keinen Hostnamen angegeben.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="17">
|
||||||
|
<source>Keine E-Mail-Adresse angegeben.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="18">
|
||||||
|
<source>Keine gültige E-Mail-Adresse angegeben.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="19">
|
||||||
|
<source>Kein Passwort angegeben.</source>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="20">
|
||||||
|
<source>Bitte gebe in den Feldern Passwort und Passwortwiederholung identische Werte ein.</source>
|
||||||
|
</trans-unit>
|
||||||
|
</body>
|
||||||
|
</file>
|
||||||
|
</xliff>
|
16
locales/en.xml
Normal file
16
locales/en.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2
|
||||||
|
xliff-core-1.2-transitional.xsd"
|
||||||
|
version="1.2">
|
||||||
|
<file source-language="de" datatype="plaintext" original="file.ext">
|
||||||
|
<body>
|
||||||
|
<trans-unit id="1">
|
||||||
|
<source>Ein XMPP-Konto registrieren</source>
|
||||||
|
<target>Register an xmpp account</target>
|
||||||
|
</trans-unit>
|
||||||
|
</body>
|
||||||
|
</file>
|
||||||
|
</xliff>
|
|
@ -6,7 +6,7 @@
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
|
|
||||||
<title>Ein XMPP-Konto registrieren</title>
|
<title>{% trans %}Ein XMPP-Konto registrieren{% endtrans %}</title>
|
||||||
|
|
||||||
<!-- Bootstrap core CSS -->
|
<!-- Bootstrap core CSS -->
|
||||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
@ -19,53 +19,53 @@
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|
||||||
<!-- Form Name -->
|
<!-- Form Name -->
|
||||||
<legend>Ein XMPP-Konto registrieren</legend>
|
<legend>{% trans %}Ein XMPP-Konto registrieren{% endtrans %}</legend>
|
||||||
|
|
||||||
<!-- Text input-->
|
<!-- Text input-->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="username">Benutzername</label>
|
<label class="control-label" for="username">{% trans %}Benutzername{% endtrans %}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input id="username" name="username" placeholder="bernd" class="input-xlarge" required="" type="text">
|
<input id="username" name="username" placeholder="bernd" class="input-xlarge" required="" type="text">
|
||||||
<p class="help-block">Gib hier deinen gewünschten Benutzernamen ein.</p>
|
<p class="help-block">{% trans %}Gib hier deinen gewünschten Benutzernamen ein.{% endtrans %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Select Basic -->
|
<!-- Select Basic -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="host">Server</label>
|
<label class="control-label" for="host">{% trans %}Server{% endtrans %}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<select id="host" name="host" class="input-xlarge" required="">
|
<select id="host" name="host" class="input-xlarge" required="">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option>krautspace.de</option>
|
<option>krautspace.de</option>
|
||||||
</select>
|
</select>
|
||||||
<p class="help-block">Wähle hier einen Servernamen aus. Deine XMPP-ID ist dann <span class="xmpp-id-preview">Benutzername@Servername</span></p>
|
<p class="help-block">{% trans %}Wähle hier einen Servernamen aus. Deine XMPP-ID ist dann <span class="xmpp-id-preview">Benutzername@Servername</span>{% endtrans %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Text input-->
|
<!-- Text input-->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="mail">E-Mail-Adresse</label>
|
<label class="control-label" for="mail">{% trans %}E-Mail-Adresse{% endtrans %}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input id="mail" name="mail" placeholder="bernd@example.com" class="input-xlarge" required="" type="text">
|
<input id="mail" name="mail" placeholder="bernd@example.com" class="input-xlarge" required="" type="text">
|
||||||
<p class="help-block">Gib hier eine gültige E-Mail-Adresse ein. Die Adresse wird benutzt um dir einen Validierungscode zu schicken, sie wird nicht gespeichert.</p>
|
<p class="help-block">{% trans %}Gib hier eine gültige E-Mail-Adresse ein. Die Adresse wird benutzt um dir einen Validierungscode zu schicken, sie wird nicht gespeichert.{% endtrans %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Password input-->
|
<!-- Password input-->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="password">Passwort:</label>
|
<label class="control-label" for="password">{% trans %}Passwort{% endtrans %}:</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input id="password" name="password" placeholder="" class="input-xlarge" required="" type="password">
|
<input id="password" name="password" placeholder="" class="input-xlarge" required="" type="password">
|
||||||
<p class="help-block">Bitte wähle ein starkes Passwort. Also mindestens 8, besser 12 oder mehr Zeichen mit einer möglichst großen Variation aus Klein- und Großbuchstaben, Zahlen und Sonderzeichen.</p>
|
<p class="help-block">{% trans %}Bitte wähle ein starkes Passwort. Also mindestens 8, besser 12 oder mehr Zeichen mit einer möglichst großen Variation aus Klein- und Großbuchstaben, Zahlen und Sonderzeichen.{% endtrans %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Password input-->
|
<!-- Password input-->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="password_repeat">Passwortwiederholung</label>
|
<label class="control-label" for="password_repeat">{% trans %}Passwortwiederholung{% endtrans %}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input id="password_repeat" name="password_repeat" placeholder="" class="input-xlarge" required="" type="password">
|
<input id="password_repeat" name="password_repeat" placeholder="" class="input-xlarge" required="" type="password">
|
||||||
<p class="help-block">Bitte wiederhole hier dein gewähltes Passwort um sicherzustellen, dass du dich auch nicht vertippt hast.</p>
|
<p class="help-block">{% trans %}Bitte wiederhole hier dein gewähltes Passwort um sicherzustellen, dass du dich auch nicht vertippt hast.{% endtrans %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="submit"></label>
|
<label class="control-label" for="submit"></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button id="submit" name="submit" class="btn btn-success">Submit</button>
|
<button id="submit" name="submit" class="btn btn-success">{% trans %}Absenden{% endtrans %}</button>
|
||||||
<button id="cancel" name="cancel" class="btn btn-danger">Abbrechen</button>
|
<button id="cancel" name="cancel" class="btn btn-danger">{% trans %}Abbrechen{% endtrans %}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -83,4 +83,3 @@
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
Reference in a new issue