Commit: c20b2c26feea4ff6691e59a556867e0d86f2cb99
Author: David Persson | Date: 2010-03-18 00:26:47 +0100
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 15a380b..acc861c 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -1,10 +1,15 @@
<?php
/**
- * Require the g11n if it has not been included yet.
- *
+ * Register g11n resource.
*/
-require_once LITHIUM_APP_PATH . '/config/bootstrap/g11n.php';
+use \lithium\g11n\Catalog;
+
+Catalog::config(array(
+ 'li3_docs' => array(
+ 'adapter' => 'Gettext',
+ 'path' => dirname(__DIR__) . '/resources/g11n'
+)) + Catalog::config());
/**
* Filter to serve the assets from plugins.
diff --git a/config/routes.php b/config/routes.php
index 3cf8196..ebd5985 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -1,9 +1,20 @@
<?php
use \lithium\net\http\Router;
+use \app\extensions\net\http\LocaleRoute;
-Router::connect('/docs', array('plugin' => 'li3_docs', 'controller' => 'browser'));
-Router::connect('/docs/{:library}/{:args}', array(
- 'plugin' => 'li3_docs', 'controller' => 'browser', 'action' => 'view'
-));
-?>
+Router::connect(new LocaleRoute(array(
+ 'template' => '/docs',
+ 'params' => array(
+ 'plugin' => 'li3_docs',
+ 'controller' => 'browser'
+))));
+Router::connect(new LocaleRoute(array(
+ 'template' => '/docs/{:library}/{:args}',
+ 'params' => array(
+ 'plugin' => 'li3_docs',
+ 'controller' => 'browser', 'action' => 'view',
+ 'args' => null
+))));
+
+?>
\ No newline at end of file
diff --git a/resources/g11n/de/LC_MESSAGES/li3_docs.mo b/resources/g11n/de/LC_MESSAGES/li3_docs.mo
new file mode 100644
index 0000000..32d5490
Binary files /dev/null and b/resources/g11n/de/LC_MESSAGES/li3_docs.mo differ
diff --git a/resources/g11n/de/LC_MESSAGES/li3_docs.po b/resources/g11n/de/LC_MESSAGES/li3_docs.po
new file mode 100644
index 0000000..3e66e62
--- /dev/null
+++ b/resources/g11n/de/LC_MESSAGES/li3_docs.po
@@ -0,0 +1,85 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: li3_docs\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: \n"
+"Last-Translator: David Persson <davidpersson@gmx.de>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Poedit-Language: German\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+#: /views/browser/index.html.php:1
+msgid "Libraries"
+msgstr "Bibliotheken"
+
+#: /views/browser/view.html.php:12
+msgid "Package contents"
+msgstr "Paketinhalte"
+
+#: /views/browser/view.html.php:27
+msgid "Parent class"
+msgstr "Elternklasse"
+
+#: /views/browser/view.html.php:34
+msgid "Description"
+msgstr "Beschreibung"
+
+#: /views/browser/view.html.php:36
+#: /views/browser/view.html.php:41
+#: /views/browser/view.html.php:67
+msgid "info"
+msgstr "info"
+
+#: /views/browser/view.html.php:48
+msgid "Parameters"
+msgstr "Parameter"
+
+#: /views/browser/view.html.php:55
+msgid "text"
+msgstr "text"
+
+#: /views/browser/view.html.php:64
+msgid "Returns"
+msgstr "Gibt zurück"
+
+#: /views/browser/view.html.php:74
+msgid "This method can be filtered."
+msgstr "Diese Methode kann gefiltert werden."
+
+#: /views/browser/view.html.php:80
+msgid "Related"
+msgstr "Beziehend"
+
+#: /views/browser/view.html.php:90
+msgid "Properties"
+msgstr "Eigenschaften"
+
+#: /views/browser/view.html.php:100
+msgid "Methods"
+msgstr "Methoden"
+
+#: /views/browser/view.html.php:111
+msgid "Subclasses"
+msgstr "Unterklasse"
+
+#: /views/browser/view.html.php:127
+msgid "Show source"
+msgstr "Zeige Quellcode"
+
+#: /views/layouts/default.html.php:17
+#: /views/layouts/default.html.php:28
+msgid "Lithium API"
+msgstr "Lithium API"
+
+#: /views/layouts/default.html.php:53
+msgid "Pretty much everything is © {:year} and beyond, the Union of Rad"
+msgstr "So ziemlich alles © {:year} und später, die Union of Rad "
+
+#: /views/layouts/default.html.php:87
+msgid "Hide source"
+msgstr "Verstecke Quellcode"
+
diff --git a/resources/g11n/message_li3_docs.pot b/resources/g11n/message_li3_docs.pot
index 9c809b5..1ed98bf 100644
--- a/resources/g11n/message_li3_docs.pot
+++ b/resources/g11n/message_li3_docs.pot
@@ -1,74 +1,85 @@
+# This file is distributed under the same license as the PACKAGE package.
#
-# Lithium: the most rad php framework
-#
-# @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
-# @license http://opensource.org/licenses/bsd-license.php The BSD License
-#
-"Project-Id-Version: lithium 0.3\n"
-"POT-Creation-Date: DATE\n"
-"PO-Revision-Date: DATE\n"
-"Last-Translator: NAME <EMAIL>\n"
-"Language-Team: LOCALE <EMAIL>\n"
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=NUMBER; plural=EXPRESSION;\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-#: app/libraries/plugins/li3_docs/views/browser/index.html.php:1
-msgid "Select a library below:"
+#: /views/browser/index.html.php:1
+msgid "Libraries"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:35
+#: /views/browser/view.html.php:12
msgid "Package contents"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:50
+#: /views/browser/view.html.php:27
msgid "Parent class"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:57
+#: /views/browser/view.html.php:34
msgid "Description"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:59
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:64
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:90
+#: /views/browser/view.html.php:36
+#: /views/browser/view.html.php:41
+#: /views/browser/view.html.php:67
msgid "info"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:71
+#: /views/browser/view.html.php:48
msgid "Parameters"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:78
+#: /views/browser/view.html.php:55
msgid "text"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:87
+#: /views/browser/view.html.php:64
msgid "Returns"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:97
+#: /views/browser/view.html.php:74
msgid "This method can be filtered."
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:103
+#: /views/browser/view.html.php:80
msgid "Related"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:113
+#: /views/browser/view.html.php:90
msgid "Properties"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:123
+#: /views/browser/view.html.php:100
msgid "Methods"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/browser/view.html.php:134
+#: /views/browser/view.html.php:111
msgid "Subclasses"
msgstr ""
-#: app/libraries/plugins/li3_docs/views/layouts/default.html.php:64
-msgid "Pretty much everything is © 2009 and beyond, the Union of Rad"
+#: /views/browser/view.html.php:127
+msgid "Show source"
+msgstr ""
+
+#: /views/layouts/default.html.php:17
+#: /views/layouts/default.html.php:28
+msgid "Lithium API"
+msgstr ""
+
+#: /views/layouts/default.html.php:53
+msgid "Pretty much everything is © {:year} and beyond, the Union of Rad"
+msgstr ""
+
+#: /views/layouts/default.html.php:87
+msgid "Hide source"
msgstr ""
diff --git a/views/browser/index.html.php b/views/browser/index.html.php
index 60000d3..2e3df6a 100644
--- a/views/browser/index.html.php
+++ b/views/browser/index.html.php
@@ -2,6 +2,10 @@
<ul class="libraries">
<?php foreach ($libraries as $name => $config) { ?>
<?php $display = ucwords(str_replace('_', ' ', $name)); ?>
- <li><?php echo $this->html->link($display, "docs/{$name}"); ?></li>
+ <li><?=$this->html->link($display, array(
+ 'plugin' => 'li3_docs',
+ 'controller' => 'browser', 'action' => 'view',
+ 'library' => $name
+ )); ?></li>
<?php } ?>
</ul>
\ No newline at end of file
diff --git a/views/browser/view.html.php b/views/browser/view.html.php
index 3d58910..7fa19c9 100644
--- a/views/browser/view.html.php
+++ b/views/browser/view.html.php
@@ -2,6 +2,16 @@
$cleanup = function($text) {
return preg_replace('/\n\s+-\s/msi', "\n\n - ", $text);
};
+$identifierUrl = function($class) {
+ $parts = explode('\\', $class);
+ return array(
+ 'plugin' => 'li3_docs',
+ 'controller' => 'browser', 'action' => 'view',
+ 'library' => array_shift($parts),
+ 'args' => $parts
+ );
+};
+
$scope = strtok($object['identifier'], '\\') . '_docs';
$namespace = str_replace('\\', '/', $name);
$this->title($namespace);
@@ -12,7 +22,7 @@ $this->title($namespace);
<?php foreach ($object['children'] as $class => $type) { ?>
<?php
$parts = explode('\\', $class);
- $url = 'docs/' . str_replace('\\', '/', $class);
+ $url = $identifierUrl($class);
?>
<li class="<?=$type; ?>"><?php echo $this->html->link(end($parts), $url); ?></li>
<?php } ?>
@@ -24,7 +34,7 @@ $this->title($namespace);
<?php $parent = $object['parent']; ?>
<h4><?=$t('Parent class', array('scope' => 'li3_docs')); ?></h4>
<span class="parent">
- <?php echo $this->html->link($parent, 'docs/' . str_replace('\\', '/', $parent)); ?>
+ <?php echo $this->html->link($parent, $identifierUrl($parent)); ?>
</span>
<?php } ?>
@@ -78,7 +88,7 @@ $this->title($namespace);
<h4><?=$t('Related', array('scope' => 'li3_docs')); ?></h4>
<ul class="related">
<?php foreach ((array)$object['info']['tags']['see'] as $name) { ?>
- <li><?php echo$this->html->link($name, 'docs/' . str_replace('\\', '/', $name)); ?></li>
+ <li><?=$this->html->link($name, $identifierUrl($name)); ?></li>
<?php } ?>
</ul>
<?php } ?>
@@ -88,7 +98,7 @@ $this->title($namespace);
<h4><?=$t('Properties', array('scope' => 'li3_docs')); ?></h4>
<ul class="properties">
<?php foreach ($object['properties'] as $name => $value) { ?>
- <li><?php echo $this->html->link($name, "docs/{$namespace}::\${$name}"); ?></li>
+ <li><?=$this->html->link($name, $identifierUrl("{$namespace}::\${$name}")); ?></li>
<?php } ?>
</ul>
<?php } ?>
@@ -98,7 +108,7 @@ $this->title($namespace);
<h4><?=$t('Methods', array('scope' => 'li3_docs')); ?></h4>
<ul class="methods">
<?php foreach ($object['methods'] as $method) { ?>
- <?php $url = "docs/{$namespace}::{$method->name}()"; ?>
+ <?php $url = $identifierUrl("{$namespace}::{$method->name}()"); ?>
<li><?php echo $this->html->link($method->name, $url); ?></li>
<?php } ?>
</ul>
@@ -109,7 +119,7 @@ $this->title($namespace);
<h4><?=$t('Subclasses', array('scope' => 'li3_docs')); ?></h4>
<ul class="subclasses">
<?php foreach ($object['subClasses'] as $class) { ?>
- <?php $url = 'docs/' . str_replace('\\', '/', $class); ?>
+ <?php $url = $identifierUrl($class); ?>
<li><?php echo $this->html->link($class, $url); ?></li>
<?php } ?>
</ul>
@@ -122,5 +132,5 @@ $this->title($namespace);
<code class="php"><?php echo $h($object['source']); ?></code>
</pre>
</div>
- <button class="source-toggle">Show source</button>
-<?php } ?>
+ <button class="source-toggle"><?=$t('Show source', array('scope' => 'li3_docs')); ?></button>
+<?php } ?>
\ No newline at end of file
diff --git a/views/layouts/default.html.php b/views/layouts/default.html.php
index fb9ff1d..84246e9 100644
--- a/views/layouts/default.html.php
+++ b/views/layouts/default.html.php
@@ -1,25 +1,32 @@
- <?php
+<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
+
+use \lithium\core\Environment;
+use \lithium\g11n\Locale;
+
?>
<!doctype html>
-<html>
+<html lang="<?= str_replace('_', '-', Environment::get('locale')); ?>">
<head>
<?php echo $this->html->charset(); ?>
- <title>Docs > <?php echo $this->title(); ?></title>
+ <title><?=$t('Docs', array('scope' => 'li3_docs')) . ' ' . $this->title(); ?></title>
<?php echo $this->html->style(array('lithium', 'u1m', '/li3_docs/css/li3_docs')); ?>
<?php echo $this->scripts(); ?>
<?php echo $this->html->link('Icon', null, array('type' => 'icon')); ?>
</head>
<body class="docs">
<div id="wrapper">
+ <?=$this->_view->render(array('element' => 'locale_navigation')); ?>
<div id="container">
<div id="header">
- <h1><?php echo $this->html->link('Lithium API', '/docs');?></h1>
+ <h1><?php echo $this->html->link($t('Lithium API', array('scope' => 'li3_docs')), array(
+ 'plugin' => 'li3_docs', 'controller' => 'browser', 'action' => 'index'
+ ));?></h1>
<ul class="crumbs">
<?php foreach (isset($crumbs) ? $crumbs : array() as $crumb): ?>
<li class="<?= $crumb['class'];?>">
@@ -42,11 +49,10 @@
</div>
<div id="footer">
<p class="copyright">
- <?php printf(
- $t('Pretty much everything is %s %s and beyond, the Union of Rad'),
- '©',
- date('Y')
- ); ?>
+ <?=$t('Pretty much everything is © {:year} and beyond, the Union of Rad', array(
+ 'year' => date('Y'),
+ 'scope' => 'li3_docs'
+ )); ?>
</p>
</div>
<?php echo $this->html->script(array(
@@ -61,7 +67,10 @@
$(document).ready(function () {
$(codeSelector).hide();
- RadCli.setup();
+ RadCli.setup({
+ commandBase: 'http://lithify.me/<?= Locale::language(Environment::get('locale')); ?>/cmd'
+ });
+
var converter = new Showdown.converter("/");
$(".markdown").each(function () {
@@ -70,7 +79,14 @@
$('.source-toggle').bind('click', function() {
visible = $(codeSelector).is(':visible');
- $(this).text((visible ? 'Show' : 'Hide') + ' source');
+
+ if (visible) {
+ text = '<?=$t('Show source', array('scope' => 'li3_docs')); ?>';
+ } else {
+ text = '<?=$t('Hide source', array('scope' => 'li3_docs')); ?>';
+ }
+ $(this).text((text));
+
visible ? $(codeSelector).slideUp() : $(codeSelector).slideDown();
});
hljs.initHighlightingOnLoad();