Skip to content

Commit

Permalink
Add referral to third party translations in docs; closes twbs#13094
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrch02 committed May 13, 2014
1 parent ceda948 commit 463a120
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/_includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
{% if page.slug == "customize" %}
<script src="../assets/js/customize.min.js"></script>
{% endif %}
{% if page.slug == "getting-started" or page.slug == "css" or page.slug == "components" or page.slug == "js" %}
<script src="../assets/js/translation-notice.js"></script>
{% endif %}

{% comment %}
Inject Twitter widgets asynchronously. Snippet snipped from Twitter's
Expand Down
47 changes: 47 additions & 0 deletions docs/assets/js/translation-notice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
layout: nil
---
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
// IT'S JUST JUNK FOR OUR DOCS!
// ++++++++++++++++++++++++++++++++++++++++++
/*!
* Copyright 2011-2014 Twitter, Inc.
*
* Licensed under the Creative Commons Attribution 3.0 Unported License. For
* details, see http://creativecommons.org/licenses/by/3.0/.
*/
!function ($) {

var alreadyDismissed = localStorage.getItem('bs.dismissedTranslationNotice') === 'true'
var language = navigator.language || navigator.userLanguage
var translations = {
{% for language in site.data.translations %}
{{ language.code }}: {
name: '{{ language.name }}',
description: '{{ language.description }}',
url: '{{ language.url }}'
}{% unless forloop.last %},{% endunless %}
{% endfor %}
}

if(!alreadyDismissed && language && language.substring(0, 2) in translations) {
var translation = translations[language]
var template = '<div class="alert alert-info js-translation-notice">' +
'<h4>' + translation.name + ' translation of this documentation available</h4>' +
'<p>We want to let you know that you can read this documentation in ' + translation.name + '!</p>' +
'<p><small>Please note that this translation has been authored by a third party and may not be up to date.</small></p>' +
'<p>' +
'<a class="btn btn-primary" href="' + translation.url + '">Open ' + translation.name + ' translation</a> ' +
'<button type="button" class="btn btn-default" data-dismiss="alert" data-target=".js-translation-notice">Don\'t show me this again</button>' +
'</p>' +
'</div>'

$(template)
.insertBefore('.bs-docs-section:first')
.alert()
.on('close.bs.alert', function () {
localStorage.setItem('bs.dismissedTranslationNotice', 'true')
})
}

}(jQuery)

0 comments on commit 463a120

Please sign in to comment.