<commit_before>'use strict';

var Component = require('../../ui-base/component');
var ajax = require('../../ui-base/ajax');
var _ = require('../../ui-base/_');

var LocaleProvider = Component.extend({
    name: 'locale.provider',
    template: '{#if ready}{#inc this.$body}{/if}',
    config: function() {
        this.defaults({
            lang: 'cn'
        });

        this._initLang();
    },
    _initLang: function() {
        var api = this.data.api,
            lang = this.data.lang;

        LocaleProvider.lang = lang;
        ajax.get(`${api}?lang=${lang}`, function(json) {
            LocaleProvider.locale[lang] = json;
            this.$update('ready', true);
        }.bind(this))
    }
});

LocaleProvider.lang = 'cn';
LocaleProvider.locale = {};

const RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g;<commit_msg>misc:locale.provider增加emit ready事件<commit_after>'use strict';

var Component = require('../../ui-base/component');
var ajax = require('../../ui-base/ajax');
var _ = require('../../ui-base/_');

var LocaleProvider = Component.extend({
    name: 'locale.provider',
    template: '{#if ready}{#inc this.$body}{/if}',
    config: function() {
        this.defaults({
            lang: 'cn'
        });

        this._initLang();
    },
    _initLang: function() {
        var api = this.data.api,
            lang = this.data.lang;

        LocaleProvider.lang = lang;
        ajax.get(`${api}?lang=${lang}`, function(json) {
            LocaleProvider.locale[lang] = json;
            this.$update('ready', true);
            
            this.$emit('ready');
        }.bind(this))
    }
});

LocaleProvider.lang = 'cn';
LocaleProvider.locale = {};

const RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g;
{'fraction_non_alphanumeric': 0.20816326530612245, 'fraction_numerical': 0.0023323615160349854, 'mean_word_length': 2.2623574144486693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4727693', 'n_tokens_mistral': 556, 'n_tokens_neox': 538, 'n_words': 95}