Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix language pack availability issue in 0.14.1 #4587

Merged
merged 1 commit into from
Oct 7, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions kalite/updates/static/js/updates/update_languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ var installed_languages = [];
var downloading = false;

function version_comparison(v1, v2) {
// compare two version strings and return 1 if the first is higher than the second,
// -1 if the first is lower than the second, and 0 if they are equal
/*
compare two version strings and return 1 if the first is higher than the second,
-1 if the first is lower than the second, and 0 if they are equal.

:params v1, v2: Version strings expected format is either "N.N.N" or "N.N", where N is a positive integer.
If both strings have the same format, they're compared using a lexical order.
If one string is shorter than the other, then the other is truncated and then compared using lexical order.
*/
var v1parts = v1.split('.'), v2parts = v2.split('.');
var maxLen = Math.max(v1parts.length, v2parts.length);
var minLen = Math.min(v1parts.length, v2parts.length);
var part1, part2;
for(var i = 0; i < maxLen; i++) {
for(var i = 0; i < minLen; i++) {
part1 = parseInt(v1parts[i], 10) || 0;
part2 = parseInt(v2parts[i], 10) || 0;
if (part1 > part2) return 1;
Expand Down