Skip to content

Commit

Permalink
Fixed locale lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
andyearnshaw committed May 6, 2013
1 parent 41ba34a commit b7d014a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Intl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*jshint eqnull:true, boss:true, laxbreak:true, newcap:false, shadow:true, funcscope:true */
window.OldIntl = window.Intl;
var Intl = /*window.Intl || */(function (Intl) {
// Copyright 2013 Andy Earnshaw, MIT License

/**
Expand All @@ -11,9 +13,7 @@
* are required to work with additional locales.
*/

window.OldIntl = window.Intl;
var Intl = /*window.Intl || */(function (Intl) {

"use strict";
var
// Private object houses our locale data for each locale
localeData = {},
Expand Down Expand Up @@ -155,7 +155,7 @@ function /* 9.2.1 */CanonicalizeLocaleList (locales) {

// b. Let kPresent be the result of calling the [[HasProperty]] internal
// method of O with argument Pk.
kPresent = hop.call(O, Pk);
kPresent = Pk in O;

// c. If kPresent is true, then
if (kPresent) {
Expand Down Expand Up @@ -186,7 +186,7 @@ function /* 9.2.1 */CanonicalizeLocaleList (locales) {

// vi. If tag is not an element of seen, then append tag as the last
// element of seen.
if (!seen.indexOf(tag))
if (seen.indexOf(tag) === -1)
seen.push(tag);
}

Expand All @@ -213,7 +213,7 @@ function /* 9.2.2 */BestAvailableLocale (availableLocales, locale) {
while (true) {
// a. If availableLocales contains an element equal to candidate, then return
// candidate.
if (availableLocales.indexOf(candidate))
if (availableLocales.indexOf(candidate) > -1)
return candidate;

var
Expand Down Expand Up @@ -326,7 +326,7 @@ function /* 9.2.4 */BestFitMatcher (availableLocales, requestedLocales) {
// is the index of the first Unicode locale extension sequence within the request
// locale language tag.
for (var i=0, max=requestedLocales.length; i < max; i++) {
if (availableLocales.indexOf(requestedLocales[i]))
if (availableLocales.indexOf(requestedLocales[i]) > -1)
return {
'[[locale]]': requestedLocales[i]
};
Expand Down
1 change: 1 addition & 0 deletions tests/NumberFormatter/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<script src="Intl.js"></script>
<script src="locale-data/jsonp/en.js"></script>
<script src="locale-data/jsonp/en-GB.js"></script>
<script src="locale-data/jsonp/de-DE.js"></script>
</body>
</html>

0 comments on commit b7d014a

Please sign in to comment.