<commit_before>define(["dojo/_base/declare", "./_MultiLangParent", "dojo/i18n", "ppwcode/oddsAndEnds/xml"],
  function(declare, _MultiLangParent, i18n, xml) {

    var _MultiLangBundleParent = declare([_MultiLangParent], {
      // summary:
      //   Optional parent for MultiLangParent. We can set
      //   - nlsParentDirectory: the directory containing the used nls directory
      //   - bundleName: the name of the i18n file
      //   - lang; the locale, which can change
      //
      //   All locales must be defined as extraLocale in dojoConfig.
      //   The actual i18n resource must be loaded using the i18n! plugin syntax.
      //
      //   If nlsParentDirectory is not set, we see if we have a `mid` property on the Constructor.
      //   If so, we derive it from that, and cache it.

      // nlsParentDirectory: String?
      nlsParentDirectory: null,

      // bundleName: String?
      bundleName: null,

      _getNlsParentDirectoryAttr: function() {
        if ((!this.nlsParentDirectory) && this.constructor.mid) {
          this.set("nlsParentDirectory", _MultiLangBundleParent.dirFromMid(this.constructor.mid));
        }
        return this.nlsParentDirectory;
      },

      getLabel: function(labelName, escapeXml) {
        var render = "?" + labelName + "?";
        var nlsParentDir = this.get("nlsParentDirectory");
        if (nlsParentDir && this.get("bundleName") && labelName) {
          try {
            var labels = i18n.getLocalization(nlsParentDir, this.get("bundleName"), this.get("lang"));
            render = labels[labelName];
          }
          catch (err) {
            console.info("INFO error while getting (" + nlsParentDir + "/nls/" + this.bundleName + ")." +
              labelName + " for locale '" + this.lang + "': " + (err.message || err));
          }
        }
        return (!escapeXml) ? render : xml.escape(render, false);
      }

    });

    _MultiLangBundleParent.dirFromMid = function(mid) {
      // summary:
      //   Helper function to get the directory from a MID
      var parts = mid.split("/");
      parts.pop();
      return parts.join("/");
    };
<commit_msg>generalizing method<commit_after>define(["dojo/_base/declare", "./_MultiLangParent", "dojo/i18n", "ppwcode/oddsAndEnds/xml"],
  function(declare, _MultiLangParent, i18n, xml) {

    var _MultiLangBundleParent = declare([_MultiLangParent], {
      // summary:
      //   Optional parent for MultiLangParent. We can set
      //   - nlsParentDirectory: the directory containing the used nls directory
      //   - bundleName: the name of the i18n file
      //   - lang; the locale, which can change
      //
      //   All locales must be defined as extraLocale in dojoConfig.
      //   The actual i18n resource must be loaded using the i18n! plugin syntax.
      //
      //   If nlsParentDirectory is not set, we see if we have a `mid` property on the Constructor.
      //   If so, we derive it from that, and cache it.

      // nlsParentDirectory: String?
      nlsParentDirectory: null,

      // bundleName: String?
      bundleName: null,

      _getNlsParentDirectoryAttr: function() {
        if ((!this.nlsParentDirectory) && this.constructor.mid) {
          this.set("nlsParentDirectory", _MultiLangBundleParent.dirFromMid(this.constructor.mid));
        }
        return this.nlsParentDirectory;
      },

      getLabel: function(labelName, escapeXml, /*String?*/ otherBundleName) {
        // summary:
        // otherBundleName: String?
        //   Optional. Use otherBundleName instead of this.bundleName if provided.

        var render = "?" + labelName + "?";
        var nlsParentDir = this.get("nlsParentDirectory");
        var bundleName = otherBundleName || this.get("bundleName");
        if (nlsParentDir && bundleName && labelName) {
          try {
            var labels = i18n.getLocalization(nlsParentDir, bundleName, this.get("lang"));
            render = labels[labelName];
          }
          catch (err) {
            console.info("INFO error while getting (" + nlsParentDir + "/nls/" + bundleName + ")." +
              labelName + " for locale '" + this.lang + "': " + (err.message || err));
          }
        }
        return (!escapeXml) ? render : xml.escape(render, false);
      }

    });

    _MultiLangBundleParent.dirFromMid = function(mid) {
      // summary:
      //   Helper function to get the directory from a MID
      var parts = mid.split("/");
      parts.pop();
      return parts.join("/");
    };

{'fraction_non_alphanumeric': 0.12184315463003988, 'fraction_numerical': 0.005316792202038104, 'mean_word_length': 2.2860262008733625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '3216162', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1277, 'n_words': 344}