<commit_before># -*- coding: utf-8 -*-
 
import os
import config
import gettext
 
# Change this variable to your app name!
#  The translation files will be under
#  @LOCALE_DIR@/@LANGUAGE@/LC_MESSAGES/@APP_NAME@.mo
APP_NAME = "simpleValidator"
 
LOCALE_DIR = os.path.abspath('lang') # .mo files will then be located in APP_Dir/i18n/LANGUAGECODE/LC_MESSAGES/
 
DEFAULT_LANGUAGE = config.LOCALE

 
#lc, encoding = locale.getdefaultlocale()
#if lc:
#    languages = [lc]
 
defaultlang = gettext.translation(APP_NAME, LOCALE_DIR, languages=DEFAULT_LANGUAGE, fallback=False)

def switch_language(lang):
    global defaultlang
    defaultlang = gettext.translation(APP_NAME, LOCALE_DIR, languages=[lang], fallback=False)
<commit_msg>Set fallback to true on get text to avoid crash on missing language file<commit_after># -*- coding: utf-8 -*-
 
import os
import config
import gettext
 
# Change this variable to your app name!
#  The translation files will be under
#  @LOCALE_DIR@/@LANGUAGE@/LC_MESSAGES/@APP_NAME@.mo
APP_NAME = "simpleValidator"
 
LOCALE_DIR = os.path.abspath('lang') # .mo files will then be located in APP_Dir/i18n/LANGUAGECODE/LC_MESSAGES/
 
DEFAULT_LANGUAGE = config.LOCALE

 
#lc, encoding = locale.getdefaultlocale()
#if lc:
#    languages = [lc]
 
defaultlang = gettext.translation(APP_NAME, LOCALE_DIR, languages=DEFAULT_LANGUAGE, fallback=True)

def switch_language(lang):
    global defaultlang
    defaultlang = gettext.translation(APP_NAME, LOCALE_DIR, languages=[lang], fallback=True)

{'fraction_non_alphanumeric': 0.10456651224354732, 'fraction_numerical': 0.003970880211780278, 'mean_word_length': 5.0, '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': '5332424', 'n_tokens_mistral': 525, 'n_tokens_neox': 500, 'n_words': 129}