Update setting lang file with format json.
972892
public function langUpdate()
    {
        $path = skin_path('lang'.DS.$this->module->name).DS.app_locale().'.json';
        $data = file_exists($path) ? json_decode(file_get_contents($path), true) : [];

        $data = array_filter(array_merge($data, [
            $this->name => $this->title,
            $this->name.'#descr' => $this->attributes['descr'],
            'section.' . $this->section => request('section_lang', __('section.' . $this->section)),
            'legend.' . $this->fieldset => request('legend_lang', __('legend.' . $this->fieldset)),
        ]));

        ksort($data);

        $data = json_encode($data, JSON_UNESCAPED_UNICODE);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \RuntimeException(sprintf(
                'Translation file `%s` contains an invalid JSON structure.', $path
            ));
        }

        file_put_contents($path, $data);

        return $this;
    }
516839
async function updateVersion(file) {
  const { default: config } = await import(`${CONFIGS_PATH}/${file}`);
  const { packageName } = config;

  const packageInfoFile = `${PACKAGES_PATH}/${packageName}/package.json`;
  const { default: packageInfo } = await import(packageInfoFile);

  if (info.version !== packageInfo.version) {
    const newPackageInfo = {
      ...packageInfo,
      version: info.version,
    };

    writeFileAsync(packageInfoFile, JSON.stringify(newPackageInfo, null, '  '))
      .then(
        () => console.log(`Updated ${packageName} to ${info.version}`),
        error => console.log(error),
      );
  }
}
859303
def set_json(self, json):
        """"""
        import time

        if 'access_token' in json:
            self.access_token = json['access_token']
            self.refresh_token = json['refresh_token']
            self.expires_in = json['expires_in']

            if 'authenticated' in json:
                self.authenticated = json['authenticated']
            else:
                self.authenticated = time.time()
        else:
            self.access_token = None
920488
def load(filename):
  '''  '''
  global _DICTIONARY
  try:
    json_file = filename + '.json'
    with open(os.path.join(_DEFAULT_DIR, json_file), 'rb') as f:
      _DICTIONARY = json.load(f)
  except IOError:
    raise IOError('Language file not found. Make sure that your ',
                  'translation file is in the languages directory, ')
94066
def replace_with_json(self, json):
        ''' 

        '''
        replacement = self.from_json(json)
        replacement._destructively_move(self)
837228
def set_json(self, value: object):
        '''
        
        '''
        self.set_content(modjson.dumps(value, cls=ExtendedJSONEncoder),
                         content_type='application/json')
1148693
public function updateLanguageAction()
    {
        $response = array();
        $success = 0;
        $excludeModules = array('.', '..', '.gitignore', 'MelisSites', 'MelisInstaller');

        $textTitle = 'tr_meliscore_header_language_Language';
        $textMessage = 'tr_meliscore_tool_language_update_failed';

        $this->getEventManager()->trigger('meliscore_language_update_start', $this, $response);
        $translationSvc = $this->getServiceLocator()->get('MelisCoreTranslation');
        $moduleSvc = $this->getServiceLocator()->get('ModulesService');
        $vendorModules = $moduleSvc->getVendorModules();
        $melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
        $directory = $melisCoreConfig->getItem('meliscore/datas/default/langauges/default_trans_dir');
        $melisTool = $this->getServiceLocator()->get('MelisCoreTool');
        $fullPathVendorModules = null;
        
        if($this->getRequest()->isPost()){
            $id = (int) $this->getRequest()->getPost('id');
            $locale = $melisTool->sanitize($this->getRequest()->getPost('locale'));
            if(!empty($locale)){
                foreach($vendorModules as $vModule) {

                    $vPath = $moduleSvc->getModulePath($vModule) . '/language/';
                    if(file_exists($vPath) && is_writable($vPath)) {
                        $fullPathVendorModules[] = array('module' => $vModule, 'path' => $vPath);
                    }
                }

                if($fullPathVendorModules) {
                    foreach($fullPathVendorModules as $vModuleConf) {
                        $success = $translationSvc->createOrUpdateTranslationFiles($vModuleConf['path'], $vModuleConf['module'], $locale);
                        if(!$success){
                            break;
                        }
                    }
                }

                if($success){
                    $textMessage = 'tr_meliscore_tool_language_edit_success';
                }
            }

        }

        $response = array(
            'textTitle' => $textTitle,
            'textMessage' => $textMessage,
            'success' => $success
        );
        $this->getEventManager()->trigger('meliscore_language_update_end', $this, $response);

        return new JsonModel($response);

    }
770341
def update_build_configuration_set(id, **kwargs):
    
    data = update_build_configuration_set_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
251387
def update_json_file(filename, items):
    
    if not items:
        return

    with open(filename) as fd:
        policy = json.load(fd)

    # Compare before and after and if nothing has changed don't write the file
    # since that could cause unnecessary service restarts.
    before = json.dumps(policy, indent=4, sort_keys=True)
    policy.update(items)
    after = json.dumps(policy, indent=4, sort_keys=True)
    if before == after:
        return

    with open(filename, "w") as fd:
        fd.write(after)
623916
@ResponseBody
    @RequestMapping(value = "/filetext/{configId}", method = RequestMethod.PUT)
    public JsonObjectBase updateFileWithText(@PathVariable long configId, @NotNull String fileContent) {

        //
        // 更新
        //
        String emailNotification = "";
        try {

            String str = new String(fileContent.getBytes(), "UTF-8");
            LOG.info("receive file: " + str);

            emailNotification = configMgr.updateItemValue(configId, str);
            LOG.info("update " + configId + " ok");

        } catch (Exception e) {

            throw new FileUploadException("upload.file.error", e);
        }

        //
        // 通知ZK
        //
        configMgr.notifyZookeeper(configId);

        return buildSuccess(emailNotification);
    }
914737
def help_center_article_translation_update(self, article_id, locale, data, **kwargs):
        ""
        api_path = "/api/v2/help_center/articles/{article_id}/translations/{locale}.json"
        api_path = api_path.format(article_id=article_id, locale=locale)
        return self.call(api_path, method="PUT", data=data, **kwargs)
1109192
def set_version(version):
    

    with open(FILENAME) as pythonfile:
        content = pythonfile.read()

    output = re.sub(RE_VERSION, r"\1'{}'".format(version), content)

    if content == output:
        error('failed updating {}'.format(FILENAME))

    with open(FILENAME, 'w') as pythonfile:
        pythonfile.write(output)
159374
private void updateTranslationProgressMap(String appid, String langCode, int value) {
		if (dao == null || getDefaultLanguageCode().equals(langCode)) {
			return;
		}

		double defsize = getDefaultLanguage(appid).size();
		double approved = value;

		Map<String, Integer> progress = getTranslationProgressMap(appid);
		Integer percent = progress.get(langCode);
		if (value == PLUS) {
			approved = Math.round(percent * (defsize / 100) + 1);
		} else if (value == MINUS) {
			approved = Math.round(percent * (defsize / 100) - 1);
		}
		int allowedUntranslated = defsize > 10 ? 5 : 0;
		// allow 3 identical words per language (i.e. Email, etc)
		if (approved >= defsize - allowedUntranslated) {
			approved = defsize;
		}

		if (((int) defsize) == 0) {
			progress.put(langCode, 0);
		} else {
			progress.put(langCode, (int) ((approved / defsize) * 100));
		}
		Sysprop updatedProgress = new Sysprop(progressKey);
		for (Map.Entry<String, Integer> entry : progress.entrySet()) {
			updatedProgress.addProperty(entry.getKey(), entry.getValue());
		}
		langProgressCache = updatedProgress;
		if (percent < 100 && !percent.equals(progress.get(langCode))) {
			dao.create(appid, updatedProgress);
		}
	}
627443
def update(self, other: 'Language') -> 'Language':
        
        return Language.make(
            language=other.language or self.language,
            extlangs=other.extlangs or self.extlangs,
            script=other.script or self.script,
            region=other.region or self.region,
            variants=other.variants or self.variants,
            extensions=other.extensions or self.extensions,
            private=other.private or self.private
        )
133842
public function updateFromCatalog(): void
    {
        $domain = $this->params['domain'];

        $localePath = ROOT . '/src/Locale/';

        $catalogFile = $localePath . $domain . '.pot';
        if (!file_exists($catalogFile)) {
            $this->abort(sprintf('Catalog File %s not found.', $catalogFile));
        }

        $poFiles = [];
        $folder = new Folder($localePath);
        $tree = $folder->tree();

        foreach ($tree[1] as $file) {
            $basename = basename($file);
            if ($domain . '.po' === $basename) {
                $poFiles[] = $file;
            }
        }
        if (empty($poFiles)) {
            $this->abort(sprintf('I could not find any matching po files in the given locale path (%s) for the domain (%s)', $localePath, $domain));
        }

        if (!$this->params['overwrite']) {
            $this->out('I will update the following .po files and their corresponding .mo file with the keys from catalog: ' . $catalogFile);
            foreach ($poFiles as $poFile) {
                $this->out('    - ' . $poFile);
            }
            $response = $this->in('Would you like to continue?', ['y', 'n'], 'n');
            if ($response !== 'y') {
                $this->abort('Aborted');
            }
        }

        foreach ($poFiles as $poFile) {
            $catalogEntries = Translations::fromPoFile($catalogFile);
            $moFile = str_replace('.po', '.mo', $poFile);
            $translationEntries = Translations::fromPoFile($poFile);

            $newTranslationEntries = $catalogEntries->mergeWith($translationEntries, Merge::REFERENCES_THEIRS);

            $newTranslationEntries->deleteHeaders();
            foreach ($translationEntries->getHeaders() as $key => $value) {
                $newTranslationEntries->setHeader($key, $value);
            }

            if ($this->params['strip-references']) {
                foreach ($newTranslationEntries as $translation) {
                    $translation->deleteReferences();
                }
            }

            $newTranslationEntries->toPoFile($poFile);
            $newTranslationEntries->toMoFile($moFile);
            $this->out('Updated ' . $poFile);
            $this->out('Updated ' . $moFile);
        }
    }
1079662
function saveNewVersion(version, versionFile) {
    fs.writeFileSync(versionFile, JSON.stringify({
        version
    }, null, 2), 'UTF-8');
}
920737
def format(item, **params):
    """"""
    encoding = params.get('charset', 'UTF-8')
    return json.dumps(item, encoding=encoding)