-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
97 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
breadcrumb: | ||
home: Home | ||
licenses: Licenses | ||
|
||
sidebar: | ||
clipboard: Copy license text to clipboard | ||
how_to_apply: How to apply this license | ||
note: Note | ||
optional: Optional | ||
add: Add | ||
or: or | ||
disallow: to disallow future versions | ||
package: to your project's package description, if applicable | ||
exempli_gratia: e.g. | ||
and: and | ||
ensure: This will ensure the license is displayed in package directories. | ||
source: Source | ||
projects_with_license: Who's using this license? | ||
|
||
license_overview: | ||
view_full: View full | ||
|
||
footer: | ||
about: About | ||
table_of_contents: Table of Contents | ||
licenses: The content of this site is licensed under the <a href="https://creativecommons.org/licenses/by/3.0/"> | ||
Creative Commons Attribution 3.0 Unported License</a> | ||
with_love: Curated with <3 by <a href="https://github.com">GitHub, Inc.</a> and <a href="https://github.com/github/choosealicense.com">You!</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
$(document).ready(function() { | ||
var currentLocale = $('html').attr('lang'); | ||
|
||
// All available translations | ||
var translations = $('a.locale-chooser'); | ||
|
||
// Get the preferred locale | ||
var locale = getLocaleFromQuery() | ||
|| getLocaleFromCookie() | ||
|| getLocaleFromBrowser(translations); | ||
|
||
// If preferred locale is not the same as the current locale, then set it. | ||
if (locale && locale != currentLocale) { | ||
translations.filter("[lang=" + locale + "]").click(); | ||
} | ||
|
||
// Set locale when clicking on locale link | ||
translations.on('click', function(event) { | ||
setLocale($(event.target).attr('lang')); | ||
}); | ||
}); | ||
|
||
// Save the preferred locale in a cookie, which will be set on any subdomain. | ||
function setLocale(locale) { | ||
document.cookie = 'locale=' + locale; | ||
} | ||
|
||
// Get locale from the `l` parameter of the query string | ||
function getLocaleFromQuery() { | ||
return window.location.search.replace(/.*[?&]l=([^&$]+).*/, '$1'); | ||
} | ||
|
||
function getLocaleFromCookie() { | ||
return document.cookie.replace(/(?:(?:^|.*;\s*)locale\s*\=\s*([^;]*).*$)|^.*$/, '$1'); | ||
} | ||
|
||
// Use locale that matches browser's preferred locales | ||
function getLocaleFromBrowser(translations) { | ||
var browserLocales = [].concat(navigator.languages || navigator.userLanguage || navigator.language); | ||
for(var i = 0; i < browserLocales.length; i++) { | ||
if (translations.filter('[lang=' + browserLocales[i] + ']').length) { | ||
return browserLocales[i]; | ||
} | ||
} | ||
} |