Store a new translation in the cache.
173620
def _cache_translation(translation, timeout=cache.default_timeout):
    
    if not appsettings.PARLER_ENABLE_CACHING:
        return

    if translation.master_id is None:
        raise ValueError("Can't cache unsaved translation")

    # Cache a translation object.
    # For internal usage, object parameters are not suited for outside usage.
    fields = translation.get_translated_fields()
    values = {'id': translation.id}
    for name in fields:
        values[name] = getattr(translation, name)

    key = get_translation_cache_key(translation.__class__, translation.master_id, translation.language_code)
    cache.set(key, values, timeout=timeout)
687946
public function registerCacheRepository()
    {
        $this->app->singleton('translation.cache.repository', function ($app) {
            $cacheStore = $app['cache']->getStore();
            return CacheRepositoryFactory::make($cacheStore, $app['config']->get('translator.cache.suffix'));
        });
    }
581123
@PUT
    @Path("/{key}")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @RequiresPermissions(I18nPermissions.TRANSLATION_WRITE)
    public Response updateTranslation(@PathParam("key") String keyName, TranslationRepresentation representation) {
        WebAssertions.assertNotNull(representation, "The translation should not be null");
        TranslationValueRepresentation translationToUpdate = representation.getTarget();
        WebAssertions.assertNotNull(translationToUpdate, "The translation target should not be null");

        Key key = keyRepository.get(keyName).orElseThrow(() -> new NotFoundException("The key is not found"));
        key.addTranslation(locale, translationToUpdate.getTranslation(), translationToUpdate.isApprox());
        keyRepository.update(key);

        return Response.noContent().build();
    }
58244
def store(self, installed_stuff, metadata, interpreter, options):
        """"""
        new_content = {
            'timestamp': int(time.mktime(time.localtime())),
            'installed': installed_stuff,
            'metadata': metadata,
            'interpreter': interpreter,
            'options': options
        }
        logger.debug("Storing installed=%s metadata=%s interpreter=%s options=%s",
                     installed_stuff, metadata, interpreter, options)
        with filelock(self.lockpath):
            self._write_cache([json.dumps(new_content)], append=True)
141793
private static synchronized void addToCache(Cache cache, byte[] encoding,
            Object value) {
        if (encoding.length > ENC_MAX_LENGTH) {
            return;
        }
        Object key = new Cache.EqualByteArray(encoding);
        cache.put(key, value);
    }
259579
def store_iter(self, key, content):
        ''''''
        cachekey = self.xform_key(key)
        path = self.path(cachekey)

        with tempfile_writer(path) as fd:
            for data in content:
                LOG.debug('writing chunk of %d bytes for %s',
                          len(data), key)
                fd.write(data)
        LOG.debug('%s stored in cache', key)
1181119
def _update_cache(self):
        "  "
        expected_version = (self.registry._version, self._extra_registry._version)

        if self._last_version != expected_version:
            registry2 = Registry()

            # Copy all bindings from `self.registry`, adding our condition.
            for reg in (self.registry, self._extra_registry):
                for b in reg.key_bindings:
                    registry2.key_bindings.append(
                        _Binding(
                            keys=b.keys,
                            handler=b.handler,
                            filter=self.filter & b.filter,
                            eager=b.eager,
                            save_before=b.save_before))

            self._registry2 = registry2
            self._last_version = expected_version
655749
public function warmUp()
    {
        $translations = $this
            ->entityTranslationRepository
            ->findAll();

        /**
         * @var EntityTranslationInterface $translation
         */
        foreach ($translations as $translation) {
            $cacheKey = $this->buildKey(
                $translation->getEntityType(),
                $translation->getEntityId(),
                $translation->getEntityField(),
                $translation->getLocale()
            );

            $this
                ->cache
                ->save(
                    $cacheKey,
                    $translation->getTranslation()
                );
        }

        return $this;
    }
261417
function (newLocale) {
        if (config.storageMethod !== 'custom') {
          switchMethods[config.storageMethod].save(config.storageKey, newLocale, savedLocale, config.cookieExpirationInDays);
        } else {
          config.storageFunctions.save(config.storageKey, newLocale, savedLocale);
        }
      }
515840
function load(options) {
  if (cache[options.locales]) {
    options.verbose && gutil.log('Skip loading cached translations from', options.locales);
    return dictionaries = cache[options.locales];
  }
  try {
    options.verbose && gutil.log('Loading translations from', options.locales);
    var files = fs.readdirSync(options.locales);
    var count = 0;
    for (var i in files) {
      var file = files[i];
      switch (path.extname(file)) {
        case '.json':
        case '.js':
          dictionaries[path.basename(file, path.extname(file))] = flat(require(path.join(process.cwd(), options.locales, file)));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.ini':
          var iniData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = flat(ini2json(iniData));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.csv':
          var csvData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = csv2json(csvData);
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        default:
          options.verbose && gutil.log('Ignored file', file);
      }
    }
    options.verbose && gutil.log('Loaded', count,  'translations from', options.locales);
    if (options.cache) {
      options.verbose && gutil.log('Cashing translations from', options.locales);
      cache[options.locales] = dictionaries;
    }
  } catch (e) {
    e.message = 'No translation dictionaries have been found!';
    throw e;
  }
}
81218
function (key) {
      $uses = key;

      // make sure to store new language key before triggering success event
      if ($storageFactory) {
        Storage.put($translate.storageKey(), $uses);
      }

      $rootScope.$emit('$translateChangeSuccess', {language : key});

      // inform default interpolator
      defaultInterpolator.setLocale($uses);

      var eachInterpolator = function (interpolator, id) {
        interpolatorHashMap[id].setLocale($uses);
      };
      eachInterpolator.displayName = 'eachInterpolatorLocaleSetter';

      // inform all others too!
      angular.forEach(interpolatorHashMap, eachInterpolator);
      $rootScope.$emit('$translateChangeEnd', {language : key});
    }
473002
private function cacheTranslations() {
        $this->log("Downloading translations...");

        stream_wrapper_register("chdb", '\Tr8n\Cache\Generators\ChdbStream') or die("Failed to register Chdb protocol for streaming Tr8n translation keys");
        $fp = fopen("chdb://ChdbInMemory", "r+");

        $ch = curl_init();
        $url = Config::instance()->application->host . ApiClient::API_PATH . "application/translations?stream=true&client_id=" . Config::instance()->application->key;
        $this->log("GET: " . $url);

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FILE, $fp);

        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
    }
984385
public static function clearCache()
    {
        // cache/expensive should be used by the translator adapters.
        $app = Facade::getFacadeApplication();
        $app->make('cache/expensive')->getItem('zend')->clear();

        // Also remove the loaded translation adapters so that old strings are
        // not being used from the adapters already in memory.
        $loc = static::getInstance();
        $loc->removeLoadedTranslatorAdapters();
    }
333727
protected function storeActiveTranslationLocale($request)
    {
        $locale = $request->input(DefaultModelController::ACTIVE_TRANSLATION_LOCALE_KEY);

        if ( ! $locale) return;

        /** @var TranslationLocaleHelperInterface $helper */
        $helper = app(TranslationLocaleHelperInterface::class);

        $helper->setActiveLocale($locale);
    }
826571
public function afterSave()
    {
        foreach ($this->translationsBuffer as $translation) {
            $this->owner->link($this->translationRelationName, $translation);
        }
    }
456476
public void addTranslation (String oldname, String newname)
    {
        if (_translations == null) {
            _translations = Maps.newHashMap();
        }
        _translations.put(oldname, newname);
    }
376337
function () {
          for (var key in translationIds) {
            if (translationIds.hasOwnProperty(key) && translationIds[key] !== undefined) {
              updateTranslation(key, translationIds[key], scope, scope.interpolateParams, scope.defaultText, scope.translateNamespace);
            }
          }
        }