Generate or get convertion dict cache for certain locale.
    Dictionaries are loaded on demand.
518827
def getdict(locale):
    
    global zhcdicts, dict_zhcn, dict_zhsg, dict_zhtw, dict_zhhk, pfsdict
    if zhcdicts is None:
        loaddict(DICTIONARY)
    if locale == 'zh-cn':
        if dict_zhcn:
            got = dict_zhcn
        else:
            dict_zhcn = zhcdicts['zh2Hans'].copy()
            dict_zhcn.update(zhcdicts['zh2CN'])
            got = dict_zhcn
    elif locale == 'zh-tw':
        if dict_zhtw:
            got = dict_zhtw
        else:
            dict_zhtw = zhcdicts['zh2Hant'].copy()
            dict_zhtw.update(zhcdicts['zh2TW'])
            got = dict_zhtw
    elif locale == 'zh-hk' or locale == 'zh-mo':
        if dict_zhhk:
            got = dict_zhhk
        else:
            dict_zhhk = zhcdicts['zh2Hant'].copy()
            dict_zhhk.update(zhcdicts['zh2HK'])
            got = dict_zhhk
    elif locale == 'zh-sg' or locale == 'zh-my':
        if dict_zhsg:
            got = dict_zhsg
        else:
            dict_zhsg = zhcdicts['zh2Hans'].copy()
            dict_zhsg.update(zhcdicts['zh2SG'])
            got = dict_zhsg
    elif locale == 'zh-hans':
        got = zhcdicts['zh2Hans']
    elif locale == 'zh-hant':
        got = zhcdicts['zh2Hant']
    else:
        got = {}
    if locale not in pfsdict:
        pfsdict[locale] = getpfset(got)
    return got
487220
def setCachedDataKey(engineVersionHash, key, value):
		
		cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash)
		return JsonDataManager(cacheFile).setKey(key, value)
479829
def get_content(api, rebuild_cache=False):
    """"""
    if hasattr(get_content, 'cache') and not rebuild_cache:
        return get_content.cache
    if not os.path.exists(CONTENT_JSON) or rebuild_cache:
        import locale
        content_endpoint = api.content.get
        # pylint: disable=protected-access
        try_langs = []
        try:
            lang = get_translation_for('habitipy').info()['language']
            try_langs.append(lang)
        except KeyError:
            pass
        try:
            loc = locale.getdefaultlocale()[0]
            if loc:
                try_langs.append(loc)
                try_langs.append(loc[:2])
        except IndexError:
            pass
        server_lang = content_endpoint._node.params['query']['language']
        # handle something like 'ru_RU' not available - only 'ru'
        for lang in try_langs:
            if lang in server_lang.possible_values:
                loc = {'language': lang}
                break
        else:
            loc = {}
        get_content.cache = content = content_endpoint(**loc)
        with open(CONTENT_JSON, 'w') as f:
            json.dump(content, f)
        return content
    try:
        with open(CONTENT_JSON) as f:
            get_content.cache = content = json.load(f)
        return content
    except JSONDecodeError:
        return get_content(api, rebuild_cache=True)
285407
def cache_page(*args, **kwargs):
    '''
    
    '''
    decorator = _django_cache_page(*args, **kwargs)
    def flavoured_decorator(func):
        return vary_on_flavour_fetch(decorator(vary_on_flavour_update(func)))
    return flavoured_decorator
792575
def loadcache(json_file):
    
    f = open(json_file, 'r')
    data = f.read()
    f.close()
    try:
        apicache = json.loads(data)
    except ValueError as e:
        print("Error processing json:", json_file, e)
        return {}
    return apicache
540069
def load_cache():
    
    if not os.path.exists(settings.DUP_FILTER_FILE):
        return set()

    with open(settings.DUP_FILTER_FILE) as f:
        return set(
            json.loads(f.read())
        )
650467
def load_locale_prefixdata(indir, separator=None):
    
    prefixdata = {}  # prefix => dict mapping locale to description
    for locale in os.listdir(indir):
        if not os.path.isdir(os.path.join(indir, locale)):
            continue
        for filename in glob.glob(os.path.join(indir, locale, "*%s" % PREFIXDATA_SUFFIX)):
            overall_prefix, ext = os.path.splitext(os.path.basename(filename))
            load_locale_prefixdata_file(prefixdata, filename, locale, overall_prefix, separator)
    return prefixdata
1157798
def as_dict(self, cache=None, fetch=True):
        
        if not self._fetched and fetch:
            info = self.fetch(cache)
        elif self._use_cache(cache):
            info = self._attrs.copy()
        else:
            info = {}
        info.update(url=self.url)
        return info
1222903
def cached(func):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        global cache
        key = json.dumps((func, args, kwargs), sort_keys=True, default=str)
        try:
            return cache[key]
        except KeyError:
            pass  # Drop out of the exception handler scope.
        res = func(*args, **kwargs)
        cache[key] = res
        return res
    wrapper._wrapped = func
    return wrapper
1249087
def get_translated_items(fapi, file_uri, use_cache, cache_dir=None):
    
    items = None
    cache_file = os.path.join(cache_dir, sha1(file_uri)) if use_cache else None
    if use_cache and os.path.exists(cache_file):
        print("Using cache file %s for translated items for: %s" % (cache_file, file_uri))
        items = json.loads(read_from_file(cache_file))
    if not items:
        print("Downloading %s from smartling" % file_uri)
        (response, code) = fapi.last_modified(file_uri)
        items = response.data.items
        if cache_file:
            print("Caching %s to %s" % (file_uri, cache_file))
            write_to_file(cache_file, json.dumps(items))
    return items
352623
def load_tt_dict(self, locale, tt_d):
        
        
        #/ get the old tt dict of the locale
        tt_d_old = self.tt_dd.get(locale, None)
        
        #/ if has old tt dict
        ## N
        if tt_d_old is None:
            #/ use the new tt dict
            self.tt_dd[locale] = tt_d
        ## Y
        else:
            #/ update the old tt dict
            tt_d_old.update(tt_d)
621956
DataBundle get(ULocale locale) {
        DataBundle result = cache.get(locale);
        if (result == null) {
            result = load(locale);
            cache.put(locale, result);
        }
        return result;
    }
739037
def reload_localzone():
    """"""
    global _cache_tz
    _cache_tz = pytz.timezone(get_localzone_name())
    utils.assert_tz_offset(_cache_tz)
    return _cache_tz
1227138
function localeIsLoaded(locale) {
  return !!(Cldr._raw && Cldr._raw.main && Cldr._raw.main[getLocaleKey(locale)]);
}
1163069
def cache_generator(self, key, generator):
        """"""
        results = []
        for result in generator:
            results.append(result)
            yield result

        self.inferred[key] = tuple(results)
627933
private function cacheTranslations() {
        $this->log("Downloading translations...");
        $sources = Config::instance()->application->apiClient()->get("application/sources");
        foreach($this->languages as $language) {
            $this->log("--------------------------------------------------------------");
            $this->log($language["locale"]. " locale...");
            $this->log("--------------------------------------------------------------");
            foreach($sources as $source) {
                $this->log("Downloading ". $source["source"] . " in " . $language["locale"]. "...");
                $source = Config::instance()->application->apiClient()->get("source", array("source" => $source["source"], "locale" => $language["locale"], "translations" => "true"));
                $this->cache(Source::cacheKey($source["source"], $language["locale"]), json_encode($source));
            }
        }
    }
1322718
public final void loadLocalizations() {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "loadLocalizations", this);

        _localizer.loadLocalizations();
        try {
            setJsDestinationUUIDCache(_localizer.updatedDestDefList);
        } catch (Exception e) {
            SibTr.entry(tc, "Exception while updating UUID Destination Cache in ", e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "loadLocalizations");
    }