<commit_before>
// require dependencies
const extend     = require ('extendify');
const helper     = require ('helper');
const backend    = require ('i18next-node-fs-backend');
const sprintf    = require ('i18next-sprintf-postprocessor');
const i18next    = require ('i18next');
const middleware = require ('i18next-express-middleware');

// require local dependencies
const config = require ('config');

// require compiled conf
const compiled = cache ('locale');

/**
 * build locale controller class
 */
class locale extends helper {
  /**
   * construct locale controller class
   */
  constructor () {
    // run super
    super ();

    // bind variables
    this.extend = extend ({
      'isDeep'  : true,
      'inPlace' : false
    });

    // bind methods
    this.t     = this.t.bind (this);
    this.build = this.build.bind (this);

    // build
    this.build ();
  }

  /**
   * translates i18n by user
   *
   * @param  {user}   User
   * @param  {String} str
   * @param  {Object} opts
   *
   * @return {String}
   */
  t (User, str, opts) {
    // check opts
    opts = opts || {};

    // set lang
    opts.lng = User ? (User.get ('lang') || config.get ('i18n.fallbackLng')) : config.get ('i18n.fallbackLng');

    // check locale<commit_msg>fallback language automatically if no user<commit_after>
// require dependencies
const extend     = require ('extendify');
const helper     = require ('helper');
const backend    = require ('i18next-node-fs-backend');
const sprintf    = require ('i18next-sprintf-postprocessor');
const i18next    = require ('i18next');
const middleware = require ('i18next-express-middleware');

// require local dependencies
const config = require ('config');

// require compiled conf
const compiled = cache ('locale');

/**
 * build locale controller class
 */
class locale extends helper {
  /**
   * construct locale controller class
   */
  constructor () {
    // run super
    super ();

    // bind variables
    this.extend = extend ({
      'isDeep'  : true,
      'inPlace' : false
    });

    // bind methods
    this.t     = this.t.bind (this);
    this.build = this.build.bind (this);

    // build
    this.build ();
  }

  /**
   * translates i18n by user
   *
   * @param  {user}   User
   * @param  {String} str
   * @param  {Object} opts
   *
   * @return {String}
   */
  t (User, str, opts) {
    // check user
    if (typeof User === 'string') {
      // set setr and opts
      str  = arguments[0];
      opts = arguments[1];
    }
    
    // check opts
    opts = opts || {};

    // set lang
    opts.lng = User ? (User.get ('lang') || config.get ('i18n.fallbackLng')) : config.get ('i18n.fallbackLng');

    // check locale
{'fraction_non_alphanumeric': 0.14942528735632185, 'fraction_numerical': 0.01260659992584353, 'mean_word_length': 2.428208386277001, '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': '6942971', 'n_tokens_mistral': 849, 'n_tokens_neox': 822, 'n_words': 238}