From 463a1201ec6dc04414dac7248e3ea096f8f8b833 Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Wed, 14 May 2014 00:27:45 +0200 Subject: [PATCH] Add referral to third party translations in docs; closes #13094 --- docs/_includes/footer.html | 3 ++ docs/assets/js/translation-notice.js | 47 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 docs/assets/js/translation-notice.js diff --git a/docs/_includes/footer.html b/docs/_includes/footer.html index 0bb3eafd33a4..717e56dd2f0b 100644 --- a/docs/_includes/footer.html +++ b/docs/_includes/footer.html @@ -38,6 +38,9 @@ {% if page.slug == "customize" %} {% endif %} +{% if page.slug == "getting-started" or page.slug == "css" or page.slug == "components" or page.slug == "js" %} + +{% endif %} {% comment %} Inject Twitter widgets asynchronously. Snippet snipped from Twitter's diff --git a/docs/assets/js/translation-notice.js b/docs/assets/js/translation-notice.js new file mode 100644 index 000000000000..7d24ec1a9928 --- /dev/null +++ b/docs/assets/js/translation-notice.js @@ -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 = '
' + + '

' + translation.name + ' translation of this documentation available

' + + '

We want to let you know that you can read this documentation in ' + translation.name + '!

' + + '

Please note that this translation has been authored by a third party and may not be up to date.

' + + '

' + + 'Open ' + translation.name + ' translation ' + + '' + + '

' + + '
' + + $(template) + .insertBefore('.bs-docs-section:first') + .alert() + .on('close.bs.alert', function () { + localStorage.setItem('bs.dismissedTranslationNotice', 'true') + }) + } + +}(jQuery) \ No newline at end of file