<commit_before>( function( global, factory ) {

    if ( typeof module === "object" && typeof module.exports === "object" ) {
        module.require( "../resources/locale-names" );
        module.require( "./resource-bundle" );
        module.exports = factory( global );
    } else {
        factory( global );
    }

}( this, function( global ) {

    function Locale( language, country, variant ) {
        var _DISPLAY_LANGUAGE = 0;
        var _DISPLAY_COUNTRY = 1;
        var _DISPLAY_VARIANT = 2;
        // var _DISPLAY_SCRIPT = 3;

        var _language = language ? language.toLowerCase() : "";
        var _country = country ? country.toUpperCase() : "";
        var _variant = variant ? variant.toString() : "";

        var _getDisplayString = function( code, inLocale, type ) {
            if ( code.length == 0 ) {
                return "";
            }

            var bundle = global.ResourceBundle.getBundle( "LocaleNames", inLocale );
            var key = type == _DISPLAY_VARIANT ? "%%" + code : code;
            var result = null;

            if ( !result ) {
                result = bundle[ key ];
            }

            if ( result ) {
                return result;
            }

            return code;
        };

        this.getLanguage = function() {
            return _language;
        };

        this.getCountry = function() {
            return _country;
        };

        this.getVariant = function() {
            return _variant;
        };

        this.toLanguageTag = function() {
            var tag = "";
            if ( _language.length > 0 ) {
                tag = _language;
            }
            if ( _country.length > 0 ) {
                tag += "-" + _country;
            }
            if ( _variant.length ) {
                tag += "-" + _variant;
            }
            return tag;
        };

        this.getDisplayLanguage = function( inLocale ) {
            return _getDisplayString( this.getLanguage(), inLocale, _DISPLAY_LANGUAGE );
        };

        this.getDisplayCountry = function( inLocale ) {
            return _getDisplayString( this.getCountry(), inLocale, _DISPLAY_COUNTRY );
        };

        this.getDisplayVariant = function( inLocale ) {
            return _getDisplayString( this.getVariant(), inLocale, _DISPLAY_VARIANT );
        };

    }

    var _CACHE = {};
    var _defaultLocale;

    var _initDefault = function() {
        var browserLanguageParts = global.navigator ? global.navigator.language.split( "-" ) : "en-US";
        var language = "";
        var country = "";
        if ( browserLanguageParts.length > 0 ) {
            language = browserLanguageParts[ 0 ];
            if ( browserLanguageParts.length > 1 ) {
                country = browserLanguageParts[ 1 ];
            }
        }
        _defaultLocale = _getInstance( language, country );
    };

    var _getInstance = function( language, country, variant ) {
        var parts = [ language ];
        var locale;
        var key;
        if ( country ) {
            parts.push( country );
        }
        if ( variant ) {
            parts.push( variant );
        }
        key = parts.join( "-" );
        locale = _CACHE[ key ];
        if ( locale ) {
            return locale;
        } else {
            locale = new Locale( language, country, variant );
            _CACHE[ key ] = locale;
            return locale;
        }
    };

    Locale.getDefault = function() {
        if ( !_defaultLocale ) {
            _initDefault();
        }
        return _defaultLocale;
    };

    Locale.forLanguageTag = function( tag ) {
        var language;
        var country;
        var variant;
        var index;
        var part = tag;
        index = part.search( "-" );
        if ( index > -1 ) {
            language = part.substring( 0, index );
            part = part.substring( index + 1 );
            index = part.search( "-" );
            if ( index > -1 ) {
                country = part.substring( 0, index );
                variant = part.substring( index + 1 );
            } else {
                country = part;
            }
        } else {
            language = part;
        }
        return new Locale( language, country, variant );
    };

    Locale.prototype.getDisplayName = function() {
        var result = this.getDisplayLanguage();
        if ( this.getDisplayCountry() ) {
            result += " (" + this.getDisplayCountry() + ")";
        }
        return result;
    };

    Locale.prototype.toString = function() {<commit_msg>Add `inLocale` argument to the locale `getDisplayName` method<commit_after>( function( global, factory ) {

    if ( typeof module === "object" && typeof module.exports === "object" ) {
        module.require( "./resource-bundle" );
        module.exports = factory( global );
    } else {
        factory( global );
    }

}( this, function( global ) {

    function Locale( language, country, variant ) {
        var _DISPLAY_LANGUAGE = 0;
        var _DISPLAY_COUNTRY = 1;
        var _DISPLAY_VARIANT = 2;
        // var _DISPLAY_SCRIPT = 3;

        var _language = language ? language.toLowerCase() : "";
        var _country = country ? country.toUpperCase() : "";
        var _variant = variant ? variant.toString() : "";

        var _getDisplayString = function( code, inLocale, type ) {
            if ( code.length == 0 ) {
                return "";
            }

            var bundle = global.ResourceBundle.getBundle( "LocaleNames", inLocale );
            var key = type == _DISPLAY_VARIANT ? "%%" + code : code;
            var result = null;

            if ( !result ) {
                result = bundle[ key ];
            }

            if ( result ) {
                return result;
            }

            return code;
        };

        this.getLanguage = function() {
            return _language;
        };

        this.getCountry = function() {
            return _country;
        };

        this.getVariant = function() {
            return _variant;
        };

        this.toLanguageTag = function() {
            var tag = "";
            if ( _language.length > 0 ) {
                tag = _language;
            }
            if ( _country.length > 0 ) {
                tag += "-" + _country;
            }
            if ( _variant.length ) {
                tag += "-" + _variant;
            }
            return tag;
        };

        this.getDisplayLanguage = function( inLocale ) {
            return _getDisplayString( this.getLanguage(), inLocale, _DISPLAY_LANGUAGE );
        };

        this.getDisplayCountry = function( inLocale ) {
            return _getDisplayString( this.getCountry(), inLocale, _DISPLAY_COUNTRY );
        };

        this.getDisplayVariant = function( inLocale ) {
            return _getDisplayString( this.getVariant(), inLocale, _DISPLAY_VARIANT );
        };

    }

    var _CACHE = {};
    var _defaultLocale;

    var _initDefault = function() {
        var browserLanguageParts = global.navigator ? global.navigator.language.split( "-" ) : [ "en", "US" ];
        var language = "";
        var country = "";
        if ( browserLanguageParts.length > 0 ) {
            language = browserLanguageParts[ 0 ];
            if ( browserLanguageParts.length > 1 ) {
                country = browserLanguageParts[ 1 ];
            }
        }
        _defaultLocale = _getInstance( language, country );
    };

    var _getInstance = function( language, country, variant ) {
        var parts = [ language ];
        var locale;
        var key;
        if ( country ) {
            parts.push( country );
        }
        if ( variant ) {
            parts.push( variant );
        }
        key = parts.join( "-" );
        locale = _CACHE[ key ];
        if ( locale ) {
            return locale;
        } else {
            locale = new Locale( language, country, variant );
            _CACHE[ key ] = locale;
            return locale;
        }
    };

    Locale.getDefault = function() {
        if ( !_defaultLocale ) {
            _initDefault();
        }
        return _defaultLocale;
    };

    Locale.forLanguageTag = function( tag ) {
        var language;
        var country;
        var variant;
        var index;
        var part = tag;
        index = part.search( "-" );
        if ( index > -1 ) {
            language = part.substring( 0, index );
            part = part.substring( index + 1 );
            index = part.search( "-" );
            if ( index > -1 ) {
                country = part.substring( 0, index );
                variant = part.substring( index + 1 );
            } else {
                country = part;
            }
        } else {
            language = part;
        }
        return new Locale( language, country, variant );
    };

    Locale.prototype.getDisplayName = function( inLocale ) {
        var result = this.getDisplayLanguage( inLocale );
        if ( this.getCountry() != "" ) {
            result += " (" + this.getDisplayCountry( inLocale ) + ")";
        }
        return result;
    };

    Locale.prototype.toString = function() {
{'fraction_non_alphanumeric': 0.11535523300229182, 'fraction_numerical': 0.0037105751391465678, 'mean_word_length': 1.4734143049932524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1622095', 'n_tokens_mistral': 2464, 'n_tokens_neox': 2363, 'n_words': 589}