<commit_before>'use strict';

var schema = require('js-schema-6901');
var text = require('../text');
var iso = require('../iso');
var ietf = require('../ietf');
var subdomain = require('../subdomain');
var service = require('../service');
var extend = require('util')._extend;
var locator = require('../../service/locator');

var defaults = {
    forex: {
        base: 'NZD',
        currencies: ['USD', 'CNY', 'EUR', 'NZD']
    },
    language: {
        fallback: 'en',
        supported: ['en', 'fr','zh']
    },
    services: locator.loadAllServices()
};

function upgrade(r) {
    let r1 = extend(extend({}, defaults), r);
    
    // 20-Nov-2015 forex and language became objects 
    if (r1.currencies) {
        r1.forex = {
            base: r1.baseCurrency || defaults.forex.base,
            currencies: r1.currencies
        };
    }
    if (r1.languages) {
        r1.language = {
            fallback: defaults.language.fallback,
            supported: r1.languages
        };
    }
    r1.baseCurrency = r1.currencies = r1.languages = undefined;
    
    // 22-Nov-2015 Services array becomes Service object keyed by moduleName
    r1.service = r1.service || {};
    if (r1.services) {
        r1.services.forEach(s => r1.service[s.moduleName] = r1.service[s.moduleName] || s);
    }
    r1.services = undefined;
    <commit_msg>default language<commit_after>'use strict';

var schema = require('js-schema-6901');
var text = require('../text');
var iso = require('../iso');
var ietf = require('../ietf');
var subdomain = require('../subdomain');
var service = require('../service');
var extend = require('util')._extend;
var locator = require('../../service/locator');
let config = require("config");

var defaults = {
    forex: {
        base: 'NZD',
        currencies: ['USD', 'CNY', 'EUR', 'NZD']
    },
    language: {
        fallback: config.get('language'),
        supported: ['en', 'fr','zh', 'zh-CN', 'zh-TW']
    },
    services: locator.loadAllServices()
};

function upgrade(r) {
    let r1 = extend(extend({}, defaults), r);
    
    // 20-Nov-2015 forex and language became objects 
    if (r1.currencies) {
        r1.forex = {
            base: r1.baseCurrency || defaults.forex.base,
            currencies: r1.currencies
        };
    }
    if (r1.languages) {
        r1.language = {
            fallback: defaults.language.fallback,
            supported: r1.languages
        };
    }
    r1.baseCurrency = r1.currencies = r1.languages = undefined;
    
    // 22-Nov-2015 Services array becomes Service object keyed by moduleName
    r1.service = r1.service || {};
    if (r1.services) {
        r1.services.forEach(s => r1.service[s.moduleName] = r1.service[s.moduleName] || s);
    }
    r1.services = undefined;
    
{'fraction_non_alphanumeric': 0.1691416153567548, 'fraction_numerical': 0.02462875769648678, 'mean_word_length': 2.3972939729397296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '942023', 'n_tokens_mistral': 942, 'n_tokens_neox': 900, 'n_words': 196}