<commit_before>/*
 * Author: maxkalb.<EMAIL>
 *
 * This script automizes/wraps the registration of translations for R.js.
 * To do so it simply loads predefined translation js files to the head.
 * In addition it provides an automization for plain text translations and
 * some helper functions to easy up language selection by automatically 
 * adding html options according to the number of languages registered.
 * Users language selection will be stored in local storrage and
 * autoreload languange from local storrage is provided.
 * 
 * Uscase: Separate and easy up the translation process for R.js.
 *
 * 1. Define translation js file-names to be loaded.
 * 2. Set the directory of the translation files.
 * 3. Define select id for easy language switching* (optional).
 *
 * Note: langdef.js file must be inside langdirectory!
 *     * Select options will be auto populated with 'langdef.js' names.
 *     Make sure to add ...  
 */
 
// >-- Translations to be loaded .. 
var langfiles = ['en_GB', 'de_DE'];

// >-- Initial setup ..
var langdirectory = 'tr/';           // The translation files directory
var defaultlang = 'en-GB';           // Initial language if local storrage is not set
var asfEnable = true;                // Set true to use R.js advanced string formating (asf)
var loadCustomjs = false;            // Set false to manually load 'custom.js' later instead of now.
var langSelectId = 'selectLanguage'; // Select element id to be used for language switching

/*
 * Dummy function for  advanced string formating (asfEnable == true).
 * Note: Overwrite this within the 'custom.js' for advanced translation control.
 */
function translateCustomTexts() { }

/*
 * Creates a script element with src 'filename' and appends it to the head. 
 */
function loadjsfile( filename ) {
  var fileref = document.createElement('script');
  fileref.setAttribute("type", "text/javascript");
  fileref.setAttribute("src", filename);
  document.getElementsByTagName("head")[0].appendChild(fileref);
}

/*
 * Load js langauge definitions and register R.js translations.
 */
loadjsfile( langdirectory + 'langdef.js' );
for( var file of langfiles ) { 
  loadjsfile( langdirectory + file + '.js' ); 
}

/*
 * Load custom langauge definitions and register R.js translations.
 */
if( asfEnable && loadCustomjs ) loadjsfile( langdirectory + 'custom.js' );

/*
 * Set 'defaultlang' from local storage (if existing). 
 */
function getLocalLanguage() {<commit_msg>Changed langfiles iterator due to IE failure<commit_after>/*
 * Author: <EMAIL>
 *
 * This script automizes/wraps the registration of translations for R.js.
 * To do so it simply loads predefined translation js files to the head.
 * In addition it provides an automization for plain text translations and
 * some helper functions to easy up language selection by automatically 
 * adding html options according to the number of languages registered.
 * Users language selection will be stored in local storrage and
 * autoreload languange from local storrage is provided.
 * 
 * Uscase: Separate and easy up the translation process for R.js.
 *
 * 1. Define translation js file-names to be loaded.
 * 2. Set the directory of the translation files.
 * 3. Define select id for easy language switching* (optional).
 *
 * Note: langdef.js file must be inside langdirectory!
 *     * Select options will be auto populated with 'langdef.js' names.
 *     Make sure to add ...  
 */
 
// >-- Translations to be loaded .. 
var langfiles = ['en_GB', 'de_DE'];

// >-- Initial setup ..
var langdirectory = 'tr/';           // The translation files directory
var defaultlang = 'en-GB';           // Initial language if local storrage is not set
var asfEnable = true;                // Set true to use R.js advanced string formating (asf)
var loadCustomjs = false;            // Set false to manually load 'custom.js' later instead of now.
var langSelectId = 'selectLanguage'; // Select element id to be used for language switching

/*
 * Dummy function for  advanced string formating (asfEnable == true).
 * Note: Overwrite this within the 'custom.js' for advanced translation control.
 */
function translateCustomTexts() { }

/*
 * Creates a script element with src 'filename' and appends it to the head. 
 */
function loadjsfile( filename ) {
  var fileref = document.createElement('script');
  fileref.setAttribute("type", "text/javascript");
  fileref.setAttribute("src", filename);
  document.getElementsByTagName("head")[0].appendChild(fileref);
}

/*
 * Load js langauge definitions and register R.js translations.
 */
loadjsfile( langdirectory + 'langdef.js' );
for(var i=0; i<langfiles.length; i++) { 
  loadjsfile( langdirectory + langfiles[i] + '.js' ); 
}

/*
 * Load custom langauge definitions and register R.js translations.
 */
if( asfEnable && loadCustomjs ) loadjsfile( langdirectory + 'custom.js' );

/*
 * Set 'defaultlang' from local storage (if existing). 
 */
function getLocalLanguage() {
{'fraction_non_alphanumeric': 0.09915356711003627, 'fraction_numerical': 0.0018137847642079807, 'mean_word_length': 3.5241567912488607, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, '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': '3659429', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1318, 'n_words': 565}