|
- <!DOCTYPE html>
- <html>
- <meta charset="utf-8">
- <head>
- <style>
- #header
- {
- background: #856d51;
- padding: 0.7em;
- text-align: left;
- }
-
- #header a
- {
- color: white;
- text-decoration: none;
- padding: 0.5em 1em 0.5em 1em;
- }
- #title
- {
- color: #433729;
- }
- html
- {
- font-family: sans-serif;
- }
- body
- {
- line-height: 1.5em;
- }
- body
- {
- background: #FAFAFA;
- }
- table
- {
- border-collapse: collapse;
- width: 100%;
- }
-
- table, th, td
- {
- border: 1px solid #aaa;
- padding: 0.5em;
- margin-top: 0.5em;
- margin-bottom: 0.5em;
- }
- code, pre
- {
- font-family: monospace, serif;
- font-size: 1em;
- color: #7f0a0c;
- background: #f5f5f5;
- white-space: pre-wrap;
- }
- video
- {
- width: 100%;
- }
- .contents
- {
- background: #FFFFFF;
- width: 720px;
- padding: 1em;
- margin-top: 2em;
- margin-bottom: 2em;
- border: 1px solid #E0E0E0;
- text-align: left;
- color: #444;
- }
- #footer
- {
- text-align: center;
- }
- #lang
- {
- float: right;
- }
- </style>
- <title>
- PSKOV
- </title>
- </head>
- <body>
- <div id="header">
- <strong id="title">PSKOV</strong>
- <a href="pskov_1.0.0.html">Tool</a>
- <a href="education.html">Education</a>
- <div id="lang">
- <a href="../en/education.04.lang.html">EN</a>
- <a href="../ru/education.04.lang.html">RU</a>
- </div>
- </div>
- <center><h1>
- Education: 04. Language
- </h1></center>
- <center><div class="contents">
- <table>
- <thead>
- <tr>
- <th>< Back</th>
- <th>Index</th>
- <th>Next ></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a href="education.03.site.html">03. Site</a></td>
- <td><a href="education.html">Education</a></td>
- <td><a href="education.05.blog.html">05. Blog</a></td>
- </tr>
- </tbody>
- </table>
- <p></div><div class="contents"></p>
- <p>In this document we add language selection.</p>
- <p>Estimated completion time: 10 minutes.</p>
- <p><strong>Table of contents</strong></p>
- <ul>
- <li><a href="#localization">01. Localization</a></li>
- <li><a href="#cfg">02. Investigate <code>pskov.cfg</code> file</a></li>
- <li><a href="#item">03. Investigate template files</a></li>
- <li><a href="#md">04. Investigate Markdown files</a></li>
- <li><a href="#lfsa">05. Launch LFSA</a></li>
- <li><a href="#gen">06. Generate the site</a></li>
- <li><a href="#observe">07. Observe the site</a></li>
- <li><a href="#summary">08. Summary</a></li>
- </ul>
- <p><a name="localization"/></p>
- <h2 id="01localization">01. Localization</h2>
- <p>Now that you have your web site in English you start to wonder why there's no Russian version, you're Russian after all!</p>
- <p>You set on to create the following <a href="https://github.com/OGStudio/site-pskov-sample/tree/master/02.Language">directory structure</a>:</p>
- <ul>
- <li><code>pskov.cfg</code></li>
- <li><code>en/item.template</code></li>
- <li><code>en/about.md</code></li>
- <li><code>en/cv.md</code></li>
- <li><code>ru/item.template</code></li>
- <li><code>ru/about.md</code></li>
- <li><code>ru/cv.md</code></li>
- </ul>
- <p>Let's look at the contents of these files closer.</p>
- <p><a name="cfg"/></p>
- <h2 id="02investigatepskovcfgfile">02. Investigate <code>pskov.cfg</code> file</h2>
- <p><code>pskov.cfg</code> file has the following contents:</p>
- <pre><code>input = en;ru
- item = item.template
- </code></pre>
- <p>As you see, <code>input</code> can accept multiple directories separated by <code>;</code> symbol: <strong>PSKOV</strong> will go over each directory specified and run as before.</p>
- <p>In this case, both <code>en/</code> and <code>ru/</code> directories have their own <code>item.template</code> file.</p>
- <p><a name="item"/></p>
- <h2 id="03investigatetemplatefiles">03. Investigate template files</h2>
- <ul>
- <li><p><code>en/item.template</code> contents:</p>
- <pre><code>- - - - Collapsed for brevity - - - -
- <title>Serov</title>
- </head>
- <body>
- <div id="header">
- <strong>Serov</strong>
- <a href="about.html">About me</a>
- <a href="cv.html">CV</a>
- <div id="lang">
- <a href="../en/PSKOV_ITEM_URL">EN</a>
- <a href="../ru/PSKOV_ITEM_URL">RU</a>
- </div>
- </div>
- <center>
- - - - - Collapsed for brevity - - - -
- </code></pre></li>
- <li><p><code>ru/item.template</code> contents:</p>
- <pre><code>- - - - Collapsed for brevity - - - -
- <title>Серов</title>
- </head>
- <body>
- <div id="header">
- <strong>Серов</strong>
- <a href="about.html">Обо мне</a>
- <a href="cv.html">Резюме</a>
- <div id="lang">
- <a href="../en/PSKOV_ITEM_URL">EN</a>
- <a href="../ru/PSKOV_ITEM_URL">RU</a>
- </div>
- </div>
- <center>
- - - - - Collapsed for brevity - - - -
- </code></pre></li>
- </ul>
- <p><strong>Note</strong>: beginning and ending were collapsed for brevity.</p>
- <p>As you can see, both <code>en/item.template</code> and <code>ru/item.template</code> look similar to <code>item.template</code> we saw <a href="education.03.site.html">before</a>.</p>
- <p>The changes include:</p>
- <ul>
- <li>use of <code><div id="lang">...</div></code> section to present language selection</li>
- <li>localization of titles into English and Russian</li>
- </ul>
- <p>Language selection uses new <strong>PSKOV</strong> constant:</p>
- <table>
- <thead>
- <tr>
- <th>PSKOV constant</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>PSKOV_ITEM_URL</code></td>
- <td>Provides generated page's file name</td>
- </tr>
- </tbody>
- </table>
- <p>As you see, <code>PSKOV_ITEM_URL</code> is all you need to have your page in as many languages as you please.</p>
- <p><a name="md"/></p>
- <h2 id="04investigatemarkdownfiles">04. Investigate Markdown files</h2>
- <p><code>en/about.md</code> and <code>en/cv.md</code> files look almost exactly as <a href="education.03.site.html">before</a>. <code>ru/about.md</code> and <code>ru/cv.md</code> are simply Russian variants of corresponding pages.</p>
- <p>For example, <code>ru/cv.md</code> has the following contents:</p>
- <pre><code> Title: Резюме
- Slug: cv
-
- Здесь вы можете увидеть моё резюме в том случае, если мои произведения всё ещё вас интересуют. Я использовал современный подход ИТ для структурирования своего резюме в виде пар ключ-значение словаря (карты). Наслаждайтесь!
-
- | Ключ | Значение |
- |---|---|
- | Имя | Валентин Серов |
- | Возраст | 46 |
- | Семейное положение | Женат |
- | Страна | Российская Империя |
- | Учёба | Императорская Академия художеств |
- | Звания | * академик ИАХ (1898) <br> * действительный член ИАХ (1903) |
- </code></pre>
- <p><strong>Note</strong>: Russian page has exactly the same <code>Slug</code> value as English one.</p>
- <p><a name="lfsa"/></p>
- <h2 id="05launchlfsa">05. Launch LFSA</h2>
- <video controls poster="../vid/education.04.lang.launch-lfsa.edgy.poster.png">
- <source src="../vid/education.04.lang.launch-lfsa.edgy.mp4" type ="video/mp4">
- <source src="../vid/education.04.lang.launch-lfsa.edgy.webm" type ="video/webm">
- ERROR Your browser does not support HTML5 video
- </video>
- <p>Launch <a href="http://opengamestudio.org/lfsa">LFSA</a> so that it points to directory with the files we just observed:</p>
- <pre><code>$ /path/to/lfsa_1.0.0.py /path/to/dir/02.Language
- </code></pre>
- <p><a name="gen"/></p>
- <h2 id="06generatethesite">06. Generate the site</h2>
- <video controls poster="../vid/education.04.lang.gen.edgy.poster.png">
- <source src="../vid/education.04.lang.gen.edgy.mp4" type ="video/mp4">
- <source src="../vid/education.04.lang.gen.edgy.webm" type ="video/webm">
- ERROR Your browser does not support HTML5 video
- </video>
- <p>Go to <a href="http://opengamestudio.org/pskov">Tool</a> page and press <code>Generate</code> button to generate HTML files right where Markdown ones reside.</p>
- <p><a name="observe"/></p>
- <h2 id="07observethesite">07. Observe the site</h2>
- <video controls poster="../vid/education.04.lang.observe.edgy.poster.png">
- <source src="../vid/education.04.lang.observe.edgy.mp4" type ="video/mp4">
- <source src="../vid/education.04.lang.observe.edgy.webm" type ="video/webm">
- ERROR Your browser does not support HTML5 video
- </video>
- <p>Observe generated web site locally by opening <code>en/about.html</code> or <code>ru/about.html</code> and switching language.</p>
- <p><a name="summary"/></p>
- <h2 id="08summary">08. Summary</h2>
- <p>You have successfully added language selection. <a href="http://opengamestudio.org/pskov/sample/02.Language/en/about.html">Check out the result</a>.</p>
- <p>Introduced PSKOV constants include:</p>
- <table>
- <thead>
- <tr>
- <th>PSKOV constant</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>PSKOV_ITEM_URL</code></td>
- <td>Provides generated page's file name</td>
- </tr>
- </tbody>
- </table>
- <p></div><div class="contents"></p>
- <table>
- <thead>
- <tr>
- <th>< Back</th>
- <th>Index</th>
- <th>Next ></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a href="education.03.site.html">03. Site</a></td>
- <td><a href="education.html">Education</a></td>
- <td><a href="education.05.blog.html">05. Blog</a></td>
- </tr>
- </tbody>
- </table>
- </div></center>
- <div id="footer">
- The site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>
- from <a href="http://github.com/ogstudio/site-pskov">this source code</a>.
- The site is hosted by <a href="https://pages.github.com">GitHub Pages</a>.
- </div>
- <script type="text/javascript">
- </script>
- </body>
- </html>
|