<commit_before>import * as i18n from 'i18n';
import moment from 'moment';
import log from 'logger';

export default function(Vue, options) {

    // Register the i18n filter
    Vue.filter('i18n', function(value, options) {
        return i18n._(value, options);
    });

    Vue.filter('dt', function(value, format) {
        return moment(value).format(format || 'LLL');
    });

    Vue.filter('timeago', function(value) {
        return moment(value).fromNow();
    });

    Vue.filter('since', function(value) {
        return moment(value).fromNow(true);
    });

    Vue.directive('i18n', {
        bind: function() {
            this.el.innerHTML = i18n._(this.expression);
        }
    });

    // Make translations accesible globally and on instance
    Vue._ = Vue.prototype._ = i18n._;
    Vue.lang = Vue.prototype.lang = i18n.lang;

    log.debug('Plugin i18next loaded');<commit_msg>Ensure time-based filters handle null/undefined values<commit_after>import * as i18n from 'i18n';
import moment from 'moment';
import log from 'logger';

export default function(Vue, options) {

    // Register the i18n filter
    Vue.filter('i18n', function(value, options) {
        return i18n._(value, options);
    });

    Vue.filter('dt', function(value, format) {
        return value ? moment(value).format(format || 'LLL') : '-';
    });

    Vue.filter('timeago', function(value) {
        return value ? moment(value).fromNow() : '-';
    });

    Vue.filter('since', function(value) {
        return value ? moment(value).fromNow(true) : '-';
    });

    Vue.directive('i18n', {
        bind: function() {
            this.el.innerHTML = i18n._(this.expression);
        }
    });

    // Make translations accesible globally and on instance
    Vue._ = Vue.prototype._ = i18n._;
    Vue.lang = Vue.prototype.lang = i18n.lang;

    log.debug('Plugin i18next loaded');
{'fraction_non_alphanumeric': 0.15380521554018095, 'fraction_numerical': 0.021287919105907396, 'mean_word_length': 2.782696177062374, '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': '4700138', 'n_tokens_mistral': 630, 'n_tokens_neox': 592, 'n_words': 131}