Multi-language for NationBuilder sites

This is a note for adding Chinese language support for Gary Gu election site.

Gary Gu site menu

  1. Add Chinese pages for each existing page with _zh subfix.
  2. add 中文 button on the menu:
{% unless page.type_name == "Donation (v2)" %}
<nav id="menu" role="navigation">
  <ul id="topnav" class="topnav desktop-nav">
    {% for child in site.root_nav_pages %}
    {% if child.leaf? or child.nav_children.size == 0 %}
    <li {% if child.is_or_is_ancestor_of_current_page? %}class="active"{% endif %}>

      <a href="{{ child.url }}">{{ child.name }}</a>
    </li>
    {% else %}
    <li class="{% if child.is_or_is_ancestor_of_current_page? %}active{% endif %} drop">
      <a href="{{ child.url }}">{{ child.name }} <i class="icon-angle-down"></i></a>
      <ul class="sub">
        {% if site.show_parent_in_nav_dropdown? %}
        <li class="show-parent"><a href="{{ child.url }}">{{ child.name }}</a></li>
        {% else %}
        <li class="show-parent mobile-visible"><a href="{{ child.url }}">{{ child.name }}</a></li>
        {% endif %}
        {% for child2 in child.nav_children %}
        <li><a href="{{ child2.url }}">{{ child2.name }}</a></li>
        {% endfor %}
      </ul>
    </li>
    {% endif %}
    {% endfor %}
    <li class="drop">
      {% if page.is_homepage? == true %}
      <a href="http://www.garygu.ca/about_gary_gu_zh">中文</a>
      {% else %}
      <a href="http://www.garygu.ca{{ page.url }}_zh">中文</a>
       {% endif %}
    </li>
  </ul>
  {% unless request.logged_in? %}
  <div class="user-menu mobile-visible tablet-visible">
    <a class="login-button-facebook" href="{{ request.facebook_connect_url }}">Facebook</a>
    <a class="login-button-twitter" href="{{ request.twitter_connect_url }}">Twitter</a>
    <span>Or sign in with <a href="/login">email</a></span>
    <span>Don't have an account? <a href="/login">Register now</a></span>
  </div>
  {% endunless %}
</nav>

<a href="#menu" class="menu-link"><i class="icon-menu"></i></a>
{% endunless %}

Leave a Reply

Your email address will not be published. Required fields are marked *