'Replacer method called by re.sub when
traversing the language string.
Args:
match (re.matchobj): Match object from regex.
Returns:
converted word.
Notes:
Assumes self.lastword and self.level is available
on the object.'

def _translate_sub(self, match):

    word = match.group()
    lword = len(word)
    if (len(word) <= self.level):
        new_word = word
    else:
        new_word = self.language['translation'].get(word.lower(), '')
        if (not new_word):
            if word.istitle():
                new_word = ('%s%s%s' % (self.language['noun_prefix'], word, self.language['noun_postfix']))
            else:
                wlen = max(0, (lword + sum((randint((-1), 1) for i in range(self.language['word_length_variance'])))))
                grammar = self.language['grammar']
                if (wlen not in grammar):
                    return ''
                structure = choice(grammar[wlen])
                grammar2phonemes = self.language['grammar2phonemes']
                for match in _RE_GRAMMAR.finditer(structure):
                    new_word += choice(grammar2phonemes[match.group()])
        if word.istitle():
            new_word = new_word.capitalize()
        if ((len(word) > 1) and word.isupper()):
            new_word = new_word.upper()
    return new_word
