- commit
- 90345a8ffc23109b82e4e3864fb4079a17ca5335
- parent
- 11a9c6ff1a51a96333a0ebf9ac037ed82570deb8
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-10-19 14:25
mark strings as translatable
Diffstat
| M | index.php | 10 | ++++++++-- |
| M | static/main.js | 6 | +++++- |
| M | templates/base.html | 6 | +++--- |
| M | templates/page.html | 12 | ++++++------ |
| M | templates/site.html | 4 | ++-- |
| M | templates/uploads.html | 10 | +++++----- |
6 files changed, 29 insertions, 19 deletions
diff --git a/index.php b/index.php
@@ -4,6 +4,11 @@ require __DIR__ . '/vendor/autoload.php'; 4 4 use Symfony\Component\Yaml\Yaml; 5 5 use Michelf\MarkdownExtra; 6 6 -1 7 function trans($s) -1 8 { -1 9 return $s; -1 10 } -1 11 7 12 function rmdirs($path) 8 13 { 9 14 if ($path !== '.' && file_exists($path)) { @@ -65,7 +70,7 @@ function validatePath($path) 65 70 66 71 function getBreadcrumbs($path) 67 72 {68 -1 $breadcrumbs = array('home' => '');-1 73 $breadcrumbs = array(trans('home') => ''); 69 74 $parts = explode('/', $path); 70 75 for ($i = 1; $i < count($parts); $i++) { 71 76 $name = $parts[$i]; @@ -201,7 +206,7 @@ class Pupupu 201 206 public function render($path, $verbose=false) 202 207 { 203 208 if ($verbose) {204 -1 echo "rendering $path\n";-1 209 echo trans('rendering') . " $path\n"; 205 210 } 206 211 207 212 $page = $this->getYaml($path); @@ -327,6 +332,7 @@ if (isset($_SERVER['REQUEST_METHOD'])) { 327 332 328 333 $loader = new Twig_Loader_Filesystem('templates'); 329 334 $twig = new Twig_Environment($loader); -1 335 $twig->addFilter(new Twig_Filter('trans', 'trans')); 330 336 331 337 if (empty($_GET['path']) && $_GET['path'] !== '') { 332 338 header('Location: ?path=', true, 302);
diff --git a/static/main.js b/static/main.js
@@ -1,4 +1,8 @@ 1 1 (function() { -1 2 var trans = function(s) { -1 3 return s; -1 4 }; -1 5 2 6 var on = function(element, eventType, selector, fn) { 3 7 element.addEventListener(eventType, function(event) { 4 8 var target = event.target.closest(selector); @@ -29,7 +33,7 @@ 29 33 }); 30 34 31 35 on(document, 'click', '[name="delete"]', function(event) {32 -1 if (!window.confirm('Are you sure you want to delete this?')) {-1 36 if (!window.confirm(trans('Are you sure you want to delete this?'))) { 33 37 event.preventDefault(); 34 38 } 35 39 });
diff --git a/templates/base.html b/templates/base.html
@@ -12,12 +12,12 @@ 12 12 <header> 13 13 <nav aria-label="Breadcrumbs"> 14 14 {% block breadcrumbs %}15 -1 <a href="?path=">home</a> /-1 15 <a href="?path=">{{ 'home'|trans }}</a> / 16 16 {% endblock %} 17 17 </nav> 18 18 <nav>19 -1 <a href="?path=_site">site config</a>20 -1 <a href="?path=_uploads">uploads</a>-1 19 <a href="?path=_site">{{ 'site config'|trans }}</a> -1 20 <a href="?path=_uploads">{{ 'uploads'|trans }}</a> 21 21 </nav> 22 22 </header> 23 23
diff --git a/templates/page.html b/templates/page.html
@@ -9,22 +9,22 @@ 9 9 {% block main %} 10 10 <form method="POST"> 11 11 <label>12 -1 Body-1 12 {{ 'Body'|trans }} 13 13 <textarea name="md">{{ md }}</textarea> 14 14 </label> 15 15 16 16 <label>17 -1 Metadata-1 17 {{ 'Metadata'|trans }} 18 18 <textarea name="yml">{{ yml }}</textarea> 19 19 </label> 20 20 21 21 <div class="button-row"> 22 22 <div>23 -1 <input type="submit" value="Save">24 -1 <input type="submit" class="button--danger" name="delete" value="Delete">-1 23 <input type="submit" value="{{ 'Save'|trans }}"> -1 24 <input type="submit" class="button--danger" name="delete" value="{{ 'Delete'|trans }}"> 25 25 </div> 26 26 <div>27 -1 <a href="{{ url }}" target="_blank" class="button">View</a>-1 27 <a href="{{ url }}" target="_blank" class="button">{{ 'View'|trans }}</a> 28 28 </div> 29 29 </div> 30 30 </form> @@ -37,7 +37,7 @@ 37 37 <li> 38 38 <form class="flex-ignore"> 39 39 <input type="hidden" name="path" value="{{ path }}">40 -1 <input type="text" name="add" placeholder="add page" class="input--invisible file-list__main">-1 40 <input type="text" name="add" placeholder="{{ 'add page'|trans }}" class="input--invisible file-list__main"> 41 41 </form> 42 42 </li> 43 43 </ul>
diff --git a/templates/site.html b/templates/site.html
@@ -3,13 +3,13 @@ 3 3 {% block main %} 4 4 <form method="POST"> 5 5 <label>6 -1 Metadata-1 6 {{ 'Metadata'|trans }} 7 7 <textarea name="yml">{{ yml }}</textarea> 8 8 </label> 9 9 10 10 <div class="button-row"> 11 11 <div>12 -1 <input type="submit" value="Save">-1 12 <input type="submit" value="{{ 'Save'|trans }}"> 13 13 </div> 14 14 </div> 15 15 </form>
diff --git a/templates/uploads.html b/templates/uploads.html
@@ -6,17 +6,17 @@ 6 6 <li> 7 7 {% if file.is_file %} 8 8 {% if file.is_image %}9 -1 <img src="{{ file.url }}" class="file-list__icon" alt="image">-1 9 <img src="{{ file.url }}" class="file-list__icon" alt="{{ 'image'|trans }}"> 10 10 {% else %}11 -1 <img src="static/file.png" class="file-list__icon" alt="file">-1 11 <img src="static/file.png" class="file-list__icon" alt="{{ 'file'|trans }}"> 12 12 {% endif %} 13 13 <a href="{{ file.url }}" target="_blank" class="file-list__main">{{ file.name }}</a> 14 14 <form method="post"> 15 15 <input type="hidden" name="name" value="{{ file.name }}">16 -1 <button class="button--danger button--small" name="delete">Delete</button>-1 16 <button class="button--danger button--small" name="delete">{{ 'Delete'|trans }}</button> 17 17 </form> 18 18 {% else %}19 -1 <img src="static/folder.png" class="file-list__icon" alt="folder">-1 19 <img src="static/folder.png" class="file-list__icon" alt="{{ 'folder'|trans }}"> 20 20 <a href="?path=_uploads{{ file.path }}" class="file-list__main">{{ file.name }}/</a> 21 21 {% endif %} 22 22 </li> @@ -24,7 +24,7 @@ 24 24 <li> 25 25 <form method="post" enctype="multipart/form-data" class="flex-ignore"> 26 26 <input type="file" name="file" class="input--invisible file-list__main">27 -1 <input type="submit" value="Upload" class="button--small">-1 27 <input type="submit" value="{{ 'Upload'|trans }}" class="button--small"> 28 28 </form> 29 29 </li> 30 30 </ul>