Skip to content

How to translate text that is not page or post content

alessandro contini edited this page Oct 19, 2017 · 7 revisions

There might be content in the website that is not exactly post or page content:

  • _includes content
  • read more links
  • footer content

Please DO NOT hardcode this content in the HTML, all the content of these layout blocks have been conveniently moved in language files called lang.yml that can be found inside the /_data/ folder, and inside the respective language folders, /en/ /it/ etc...

MicroWebsiteTemplate
|
├── _data
       ├── en
       |   └── lang.yml
       └── it
           └── lang.yml

The lang.yml file is filled with dictionary keys that have been already divided in a series of categories:

  • global dictionary keys
  • homepage dictionary keys
  • footer dictionary keys
  • category dictionary keys
  • blog dictionary keys

Dos and Don'ts

All the dictionary keys have been conveniently commented, so it should be clear where they pertain to and how to edit them, but a few things need to be taken in account when editing the keys:

  • please always keep the original indentation (breaking the indentation may turn into errors and the incorrect displaying, or not displaying at all, of content)
  • in the case of multiple levels of indentation please be sure to keep the code structure unchanged, since the builder will loop through the list to generate some of the interface elements
# dictionary keys for homeheader.html include file
header:
  title: "MicroWebsiteTemplate"
  tagline: "This is the template for opencarecc websites"
  buttons:
    - text: "View on GitHub"
      link: "https://github.com/opencarecc/MicroWebsiteTemplate"
    - text: "Download .zip"
      link: "https://github.com/opencarecc/MicroWebsiteTemplate/zipball/master"
    - text: "Build your own!"
      link: "https://github.com/opencarecc/MicroWebsiteTemplate/wiki"

In the example above the code will loop over the buttons array to generate the buttons of the banner in the homepage, where the button attributes (text and link) are defined after any of the - symbols. If you want to remove a button just delete the dictionary keys after one of the - indexes of the array and the - symbol itself.

  • It is possible to add HTML in the dictionary keys to add links or basic text formatting, like the following example
# dictionary keys for license.html include file
license:
  title: "Open Source"
  license_content_html: "Software - <a href='https://www.gnu.org/licenses/gpl-3.0.en.html' target='_blank'>GNU 
                        General Public License</a>
                        <br>
                        Hardware - <a href='http://ohwr.org/cernohl' target='_blank'>CERN OHL v.1.2</a>"

Just be sure to use ' instead of " inside HTML tags (eg <a href='http://ohwr.org/cernohl'>), or the site build will break. Also, please keep the dictionary keys clean and do not add too complex HTML!!!