<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __openerp__.py
#
##############################################################################

import logging
import re
import sys
import threading
import locale
from collections import OrderedDict

from contextlib import contextmanager

from odoo import models, fields, api, _

logger = logging.getLogger(__name__)

LOCALE_LOCK = threading.Lock()


@contextmanager
def setlocale(name):
    with LOCALE_LOCK:
        saved = locale.setlocale(locale.LC_ALL)
        try:
            yield locale.setlocale(locale.LC_ALL, (name, 'UTF-8'))
        finally:
            locale.setlocale(locale.LC_ALL, saved)


class IrAdvancedTranslation(models.Model):
    """ Used to translate terms in context of a subject that can be
    male / female and singular / plural.
    """
    _name = 'ir.advanced.translation'
    _description = 'Advanced translation terms'

    src = fields.Text(required=True, translate=False)
    lang = fields.Selection('_get_lang', required=True)<commit_msg>FIX locale setting won't raise errors<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __openerp__.py
#
##############################################################################

import logging
import re
import sys
import threading
import locale
from collections import OrderedDict

from contextlib import contextmanager

from odoo import models, fields, api, _

logger = logging.getLogger(__name__)

LOCALE_LOCK = threading.Lock()


@contextmanager
def setlocale(name):
    with LOCALE_LOCK:
        saved = locale.setlocale(locale.LC_ALL)
        try:
            yield locale.setlocale(locale.LC_ALL, (name, 'UTF-8'))
        except:
            yield
        finally:
            locale.setlocale(locale.LC_ALL, saved)


class IrAdvancedTranslation(models.Model):
    """ Used to translate terms in context of a subject that can be
    male / female and singular / plural.
    """
    _name = 'ir.advanced.translation'
    _description = 'Advanced translation terms'

    src = fields.Text(required=True, translate=False)
    lang = fields.Selection('_get_lang', required=True)
{'fraction_non_alphanumeric': 0.20642201834862386, 'fraction_numerical': 0.0045871559633027525, 'mean_word_length': 3.9377358490566037, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1366991', 'n_tokens_mistral': 727, 'n_tokens_neox': 688, 'n_words': 206}