<commit_before>const yaml = require('js-yaml');
const getOptions = require('loader-utils').getOptions;

module.exports = function i18nYmlLoader(source, map, isTest) {
    var loader = this;

    var filename = loader.resourcePath;

    const yamlFile = yaml.safeLoad(source, {
        filename: filename,
        onWarning: function emitLoaderWarning(error) {
            loader.emitWarning(error.toString());
        }
    });
    var options = getOptions(loader) || {};
    var idsOnly = ('IDsOnly' in options ? options.IDsOnly : loader.IDsOnly) || false;
    var locale = ('defLocale' in options ? options.defLocale : loader.defLocale) || 'en';
    // var debug = 'debug' in options ? options.debug : loader.debug || false;

    const data = {}
    //     locale: 'en',
    //     messages: {}
    // };
    Object.keys(yamlFile).forEach(ns => {
        Object.keys(yamlFile[ns]).forEach(id => {
            const v = yamlFile[ns][id];
            const k = `${ns}.${id}`;
            let r;
            switch (true) {
                case typeof(v) == 'string':
                    r = v;
                    break;
                case typeof(v) == 'object' && v[locale]:
                    r = v[locale];
                    break;
                default:
                    r = null;<commit_msg>fix type comparition issue<commit_after>const yaml = require('js-yaml');
const getOptions = require('loader-utils').getOptions;

module.exports = function i18nYmlLoader(source, map) {
    var loader = this;

    var filename = loader.resourcePath;

    const yamlFile = yaml.safeLoad(source, {
        filename: filename,
        onWarning: function emitLoaderWarning(error) {
            loader.emitWarning(error.toString());
        }
    });
    var options = getOptions(loader) || {};
    var idsOnly = ('IDsOnly' in options ? options.IDsOnly : loader.IDsOnly) || false;
    var locale = ('defLocale' in options ? options.defLocale : loader.defLocale) || 'en';
    // var debug = 'debug' in options ? options.debug : loader.debug || false;

    const data = {}
    Object.keys(yamlFile).forEach(ns => {
        Object.keys(yamlFile[ns]).forEach(id => {
            const v = yamlFile[ns][id];
            const k = `${ns}.${id}`;
            let r;
            switch (true) {
                case typeof(v) == 'string':
                    r = v;
                    break;
                case typeof(v) == 'object' && !!v[locale]:
                    r = v[locale];
                    break;
                default:
                    r = null;
{'fraction_non_alphanumeric': 0.13828125, 'fraction_numerical': 0.0015625, 'mean_word_length': 1.8614525139664804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4271710', 'n_tokens_mistral': 729, 'n_tokens_neox': 699, 'n_words': 170}