25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

265 satır
9.1KB

  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <style>
  6. #header
  7. {
  8. background: #856d51;
  9. padding: 0.7em;
  10. text-align: left;
  11. }
  12. #header a
  13. {
  14. color: white;
  15. text-decoration: none;
  16. padding: 0.5em 1em 0.5em 1em;
  17. }
  18. #title
  19. {
  20. color: #433729;
  21. }
  22. html
  23. {
  24. font-family: sans-serif;
  25. }
  26. body
  27. {
  28. line-height: 1.5em;
  29. }
  30. body
  31. {
  32. background: #FAFAFA;
  33. }
  34. table
  35. {
  36. border-collapse: collapse;
  37. width: 100%;
  38. }
  39. table, th, td
  40. {
  41. border: 1px solid #aaa;
  42. padding: 0.5em;
  43. margin-top: 0.5em;
  44. margin-bottom: 0.5em;
  45. }
  46. code, pre
  47. {
  48. font-family: monospace, serif;
  49. font-size: 1em;
  50. color: #7f0a0c;
  51. background: #f5f5f5;
  52. white-space: pre-wrap;
  53. }
  54. .contents
  55. {
  56. background: #FFFFFF;
  57. width: 720px;
  58. padding: 1em;
  59. margin-top: 2em;
  60. margin-bottom: 2em;
  61. border: 1px solid #E0E0E0;
  62. text-align: left;
  63. color: #444;
  64. }
  65. </style>
  66. <title>
  67. PSKOV-201905
  68. </title>
  69. </head>
  70. <body>
  71. <div id="header">
  72. <strong id="title">PSKOV</strong>
  73. <a href="tool.pskov.html">Tool</a>
  74. <a href="education.html">Education</a>
  75. </div>
  76. <center><h1>
  77. Education: 04. Language
  78. </h1></center>
  79. <center><div class="contents">
  80. <table>
  81. <thead>
  82. <tr>
  83. <th>&lt; Back</th>
  84. <th>Index</th>
  85. <th>Next &gt;</th>
  86. </tr>
  87. </thead>
  88. <tbody>
  89. <tr>
  90. <td><a href="education.03.site.html">03. Site</a></td>
  91. <td><a href="education.html">Education</a></td>
  92. <td><a href="education.05.blog.html">05. Blog</a></td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <p></div><div class="contents"></p>
  97. <p>In this document we add language selection.</p>
  98. <p>Estimated completion time: 10 minutes.</p>
  99. <p><strong>Table of contents</strong></p>
  100. <ul>
  101. <li><a href="#localization">01. Localization</a></li>
  102. <li><a href="#cfg">02. Investigate <code>cfg</code> file</a></li>
  103. <li><a href="#item">03. Investigate template files</a></li>
  104. <li><a href="#md">04. Investigate Markdown files</a></li>
  105. <li><a href="#gen">05. Launch LFSA and generate the site</a></li>
  106. <li><a href="#summary">06. Summary</a></li>
  107. </ul>
  108. <p><a name="localization"/></p>
  109. <h2 id="01localization">01. Localization</h2>
  110. <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>
  111. <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>
  112. <ul>
  113. <li><code>cfg</code></li>
  114. <li><code>en/item.template</code></li>
  115. <li><code>en/about.md</code></li>
  116. <li><code>en/cv.md</code></li>
  117. <li><code>ru/item.template</code></li>
  118. <li><code>ru/about.md</code></li>
  119. <li><code>ru/cv.md</code></li>
  120. </ul>
  121. <p>Let's look at the contents of these files closer.</p>
  122. <p><a name="cfg"/></p>
  123. <h2 id="02investigatecfgfile">02. Investigate <code>cfg</code> file</h2>
  124. <p><code>cfg</code> file has the following contents:</p>
  125. <pre><code>input = en;ru
  126. item = item.template
  127. </code></pre>
  128. <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>
  129. <p>In this case, both <code>en/</code> and <code>ru/</code> directories have their own <code>item.template</code> file.</p>
  130. <p><a name="item"/></p>
  131. <h2 id="03investigatetemplatefiles">03. Investigate template files</h2>
  132. <ul>
  133. <li><p><code>en/item.template</code> contents:</p>
  134. <pre><code>- - - - Collapsed for brevity - - - -
  135. &lt;title&gt;Serov&lt;/title&gt;
  136. &lt;/head&gt;
  137. &lt;body&gt;
  138. &lt;div id="header"&gt;
  139. &lt;strong&gt;Serov&lt;/strong&gt;
  140. &lt;a href="about.html"&gt;About me&lt;/a&gt;
  141. &lt;a href="cv.html"&gt;CV&lt;/a&gt;
  142. &lt;div id="lang"&gt;
  143. &lt;a href="../en/PSKOV_ITEM_URL"&gt;EN&lt;/a&gt;
  144. &lt;a href="../ru/PSKOV_ITEM_URL"&gt;RU&lt;/a&gt;
  145. &lt;/div&gt;
  146. &lt;/div&gt;
  147. &lt;center&gt;
  148. - - - - Collapsed for brevity - - - -
  149. </code></pre></li>
  150. <li><p><code>ru/item.template</code> contents:</p>
  151. <pre><code>- - - - Collapsed for brevity - - - -
  152. &lt;title&gt;Серов&lt;/title&gt;
  153. &lt;/head&gt;
  154. &lt;body&gt;
  155. &lt;div id="header"&gt;
  156. &lt;strong&gt;Серов&lt;/strong&gt;
  157. &lt;a href="about.html"&gt;Обо мне&lt;/a&gt;
  158. &lt;a href="cv.html"&gt;Резюме&lt;/a&gt;
  159. &lt;div id="lang"&gt;
  160. &lt;a href="../en/PSKOV_ITEM_URL"&gt;EN&lt;/a&gt;
  161. &lt;a href="../ru/PSKOV_ITEM_URL"&gt;RU&lt;/a&gt;
  162. &lt;/div&gt;
  163. &lt;/div&gt;
  164. &lt;center&gt;
  165. - - - - Collapsed for brevity - - - -
  166. </code></pre></li>
  167. </ul>
  168. <p><strong>Note</strong>: beginning and ending were collapsed for brevity.</p>
  169. <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>
  170. <p>The changes include:</p>
  171. <ul>
  172. <li>use of <code>&lt;div id="lang"&gt;...&lt;/div&gt;</code> section to present language selection</li>
  173. <li>localization of titles into English and Russian</li>
  174. </ul>
  175. <p>Language selection uses new <strong>PSKOV</strong> constant:</p>
  176. <table>
  177. <thead>
  178. <tr>
  179. <th>PSKOV constant</th>
  180. <th>Description</th>
  181. </tr>
  182. </thead>
  183. <tbody>
  184. <tr>
  185. <td><code>PSKOV_ITEM_URL</code></td>
  186. <td>Provides generated page's file name: <code>&lt;slug&gt;.html</code></td>
  187. </tr>
  188. </tbody>
  189. </table>
  190. <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>
  191. <p><a name="md"/></p>
  192. <h2 id="04investigatemarkdownfiles">04. Investigate Markdown files</h2>
  193. <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 the same pages.</p>
  194. <p>For example, <code>ru/cv.md</code> has the following contents:</p>
  195. <pre><code> Title: Резюме
  196. Slug: cv
  197. Здесь вы можете увидеть моё резюме в том случае, если мои произведения всё ещё вас интересуют. Я использовал современный подход ИТ для структурирования своего резюме в виде пар ключ-значение словаря (карты). Наслаждайтесь!
  198. | Ключ | Значение |
  199. |---|---|
  200. | Имя | Валентин Серов |
  201. | Возраст | 46 |
  202. | Семейное положение | Женат |
  203. | Страна | Российская Империя |
  204. | Учёба | Императорская Академия художеств |
  205. | Звания | * академик ИАХ (1898) &lt;br&gt; * действительный член ИАХ (1903) |
  206. </code></pre>
  207. <p><strong>Note</strong>: Russian page has exactly the same <code>Slug:</code> value as English one.</p>
  208. <p><a name="gen"/></p>
  209. <h2 id="05launchlfsaandgeneratethesite">05. Launch LFSA and generate the site</h2>
  210. <p>Launch <a href="http://opengamestudio.org/lfsa">LFSA</a> so that it points to directory with the files we just observed:</p>
  211. <pre><code>$ /path/to/lfsa-201905.py /path/to/dir/02.Language
  212. </code></pre>
  213. <p>Generate the site:</p>
  214. <ul>
  215. <li>Go to <a href="http://opengamestudio.org/pskov">Tool</a> page</li>
  216. <li>Press <code>Generate</code> button</li>
  217. <li>Open generated <code>en/about.html</code> or <code>ru/about.html</code> from the site's directory locally</li>
  218. <li>Switch language to verify language selection works fine</li>
  219. </ul>
  220. <p><a name="summary"/></p>
  221. <h2 id="06summary">06. Summary</h2>
  222. <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>
  223. <p>Introduced PSKOV constants include:</p>
  224. <table>
  225. <thead>
  226. <tr>
  227. <th>PSKOV constant</th>
  228. <th>Description</th>
  229. </tr>
  230. </thead>
  231. <tbody>
  232. <tr>
  233. <td><code>PSKOV_ITEM_URL</code></td>
  234. <td>Provides generated page's file name: <code>&lt;slug&gt;.html</code></td>
  235. </tr>
  236. </tbody>
  237. </table>
  238. <p></div><div class="contents"></p>
  239. <table>
  240. <thead>
  241. <tr>
  242. <th>&lt; Back</th>
  243. <th>Index</th>
  244. <th>Next &gt;</th>
  245. </tr>
  246. </thead>
  247. <tbody>
  248. <tr>
  249. <td><a href="education.03.site.html">03. Site</a></td>
  250. <td><a href="education.html">Education</a></td>
  251. <td><a href="education.05.blog.html">05. Blog</a></td>
  252. </tr>
  253. </tbody>
  254. </table>
  255. </div></center>
  256. <script type="text/javascript">
  257. </script>
  258. </body>
  259. </html>