Permalink
Browse files

added zend_locale

  • Loading branch information...
1 parent 96edbd7 commit c265f965cfb7216e9d643ff744d4e951a102abdb Michael committed Oct 13, 2011
View
@@ -51,6 +51,30 @@ public function _initServices()
Zend_Registry::set('sc', $sc);
}
+ public function _initLocale()
+ {
+ try{
+ $locale = new Zend_Locale(Zend_Locale::BROWSER);
+ } catch (Zend_Locale_Exception $e) {
+ $locale = new Zend_Locale('de');
+ }
+
+ Zend_Registry::set('Zend_Locale', $locale);
+
+ $translator = new Zend_Translate(
+ array(
+ 'adapter' => 'Csv',
+ 'content' => APPLICATION_PATH . '/../data/lang/',
+ 'scan' => Zend_Translate::LOCALE_DIRECTORY,
+ 'delimiter' => ',',
+ 'disableNotices' => true
+ )
+ );
+
+ Zend_Registry::set('Zend_Translate', $translator);
+ Zend_Form::setDefaultTranslator($translator);
+ }
+
public function _initElasticSearch()
{
$es = new Elastica_Client();
@@ -185,7 +185,7 @@ public function footerAction()
$timestamp = $cache->fetch('timestamp');
$this->view->cachedTimestamp = true;
} else {
- $timestamp = date("d M Y H:i:s");
+ $timestamp = time();
$cache->save('timestamp', $timestamp);
}
@@ -1,3 +1,3 @@
-<p>&copy; 2011 Michael Romer
-<small>Page rendered on <?php echo $this->timestamp ?> <?php if ($this->cachedTimestamp) { ?>(Timestamp served from Memcached) <?php } ?></small>
+<p>&copy; 2011 Michael Romer<br />
+<small><?php echo $this->translate("Today is"); ?> <b><?php echo new Zend_Date($this->timestamp); ?></b> <?php if ($this->cachedTimestamp) { ?>(<?php echo $this->translate("Timestamp served from Memcached");?>)<?php } ?></small>
</p>
@@ -5,7 +5,7 @@
<?php echo $this->navigation()->menu(); ?>
<form action="/index/search" class="pull-right">
<input class="input" name="query" type="text" placeholder="Cherralea Morgen">
- <button class="btn" type="submit">Find Quote</button>
+ <button class="btn" type="submit"><?php echo $this->translate("Find Quote"); ?></button>
</form>
</div>
</div>
@@ -13,15 +13,15 @@
<?php } ?>
<div class="hero-unit">
-<h1>Hello from ZF-Boilerplate!</h1>
-<p>Well done, ZF-Boilerplate is up and running. You may want to modify or remove this example page.</p>
-<p><a class="btn primary large">Learn more &raquo;</a></p>
+<h1><?php echo $this->translate("Hello from ZF-Boilerplate!");?></h1>
+<p><?php echo $this->translate("Well done, ZF-Boilerplate is up and running. You may want to modify or remove this example page.");?></p>
+<p><a class="btn primary large"><?php echo $this->translate("Learn more");?> &raquo;</a></p>
</div>
<?php if (!$this->databaseError) { ?>
<div class="row" style="padding-left:148px">
<div class="span10">
- <h3 style="margin-bottom:10px;"><? if (!$this->search) { ?> Random Quotes <a href="/index/add-random" class="btn small success">Add another</a><?php } else { ?>Quotes found <a href="/" class="btn small success">Back</a><?php } ?></h3>
+ <h3 style="margin-bottom:10px;"><? if (!$this->search) { ?> <?php echo $this->translate("Random Quotes"); ?> <a href="/index/add-random" class="btn small success"><?php echo $this->translate("Add another"); ?></a><?php } else { ?><?php echo $this->translate("Quotes found"); ?> <a href="/" class="btn small success"><?php echo $this->translate("Back"); ?></a><?php } ?></h3>
<?php foreach($this->data as $quote) { ?>
<blockquote>
<p><?php echo $quote; ?></p>
View
@@ -0,0 +1,9 @@
+<?php
+/**
+ * Created by JetBrains PhpStorm.
+ * User: Michael
+ * Date: 13.10.11
+ * Time: 04:35
+ * To change this template use File | Settings | File Templates.
+ */
+
View
@@ -0,0 +1,2 @@
+"Today is","Heute ist der"
+"Timestamp served from Memcached","Datum aus Memcached"
View
@@ -0,0 +1,3 @@
+"Your wise words:","Dein Zitat:"
+"Your name:","Dein Name:"
+"List my quote","Mein Zitat hinzufügen"
View
@@ -0,0 +1,3 @@
+"Home","Startseite"
+"Documentation","Handbuch"
+"Find Quote","Zitat finden"
View
@@ -0,0 +1,7 @@
+"Hello from ZF-Boilerplate!","Hallo von ZF-Boilerplate!"
+"Well done, ZF-Boilerplate is up and running. You may want to modify or remove this example page.","Gut gemacht, ZF-Boilerplate ist einsatzbereit! Ändere oder lösche diese Seite für deine Anwendung."
+"Learn more","Mehr erfahren"
+"Random Quotes","Zufällige Zitate"
+"Add another","Weiteres Zitat hinzufügen"
+"Quotes found","Gefundene Zitate"
+"Back","Zurück"
View
@@ -0,0 +1,2 @@
+"Today is","Today is"
+"Timestamp served from Memcached","Timestamp served from Memcached"
View
@@ -0,0 +1,3 @@
+"Your wise words:","Your wise words:"
+"Your name:","Your name:"
+"List my quote","List my quote"
View
@@ -0,0 +1,3 @@
+"Home","Home"
+"Documentation","Documentation"
+"Find Quote","Find Quote"
View
@@ -0,0 +1,7 @@
+"Hello from ZF-Boilerplate!","Hello from ZF-Boilerplate!"
+"Well done, ZF-Boilerplate is up and running. You may want to modify or remove this example page.","Well done, ZF-Boilerplate is up and running. You may want to modify or remove this example page."
+"Learn more","Learn more"
+"Random Quotes","Random Quotes"
+"Add another","Add another"
+"Quotes found","Quotes found"
+"Back","Back"
@@ -13,6 +13,7 @@ class AddQuote extends \EasyBib_Form
{
public function init()
{
+ // $this->setDefaultTranslator(\Zend_Registry::get('Zend_Translate')); ???
$this->setMethod('POST');
$this->setAction('/index/add-custom');
$this->setAttrib('id', 'addQuote');
@@ -23,12 +24,13 @@ public function init()
$quote->setLabel('Your wise words:')
->setRequired(true)
- ->setAttrib('rows', '4');
+ ->setAttrib('rows', '4')
+ ->setTranslator(\Zend_Registry::get('Zend_Translate'));
- $name->setLabel('Your Name:')
+ $name->setLabel('Your name:')
->setRequired(true);
- $submit->setLabel('Add to list');
+ $submit->setLabel('List my quote');
$this->addElements(array($quote, $name, $submit));
\EasyBib_Form_Decorator::setFormDecorator(

0 comments on commit c265f96

Please sign in to comment.