import random

def getstring(obj):
    if isinstance(obj, list):
        return random.choice(obj)
    else:
        return obj

class Lang:
    def __init__(self, defaults, local):
        self._defaults = defaults
        self._local = local
    
    def __getattr__(self, var):
        if var not in self._defaults:
            return var
        
        if var not in self._local:
            return getstring(self._defaults[var])
        
        return getstring(self._local[var])

class Locals:
    def __init__(self, local):
        self._default = local[local['default']] if 'default' in local else local[local.keys()[0]]
        self._local = local
    
    def __getitem__(self, lang):
        local = self._local[lang] if lang in self._local else self._default

        return Lang(self._default, local)
