Permalink
Browse files

Updated language switcher to allow per-page default language selection.

  • Loading branch information...
1 parent 58dbc6f commit c5ee5feb8d2c1e9537e3d997b26805bd84f0058e Paddy Foran committed Jan 4, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 _layouts/default.html
View
@@ -78,7 +78,8 @@
<script src="{{ site.baseurl }}/js/purl.js" type="text/javascript"></script>
<script src="{{ site.baseurl }}/js/cookies.min.js" type="text/javascript"></script>
<script type="text/javascript">
- var languages = { {% for lang in page.languages %}
+ {% assign default_lang = "ruby" %}
+ var languages = { {% for lang in page.languages %}{% if lang.default %}{% assign default_lang = lang.slug %}{% endif %}
'{{ lang.slug }}': '{{ lang.name }}'{% unless forloop.last %},{% endunless %}{% endfor %}
};
</script>
@@ -94,11 +95,11 @@
desiredLanguage = localStorage.getItem('desired_language');
}
} else {
- desiredLanguage = "ruby";
+ desiredLanguage = "{{ default_lang }}";
}
};
if(!validLanguage(desiredLanguage)) {
- switchLanguage("ruby", false);
+ switchLanguage("{{ default_lang }}", false);
} else {
switchLanguage(desiredLanguage);
}

0 comments on commit c5ee5fe

Please sign in to comment.