Create dynamic translation model.
355534
protected function initTranslationClass()
    {
        if (!class_exists($this->translationClassName)) {
            $namespace = substr($this->translationClassName, 0, strrpos($this->translationClassName, '\\'));
            $translationClassName = $this->getShortClassName($this->translationClassName);

            eval('
            namespace ' . $namespace . ';
            use yii\db\ActiveRecord;
            class ' . $translationClassName . ' extends ActiveRecord
            {
                public static function tableName()
                {
                    return \'' . $this->tableName . '\';
                }
            }');
        }
    }
1005097
def _translate(self, input_filename, output_filename):
        """"""
        command = [
            self.translate_binary,
            '-f', 'GeoJSON',
            output_filename,
            input_filename
        ]

        result = self._runcommand(command)
        self.log('Result (Translate): ', result, lvl=debug)
43499
protected function initTranslator(): void
    {
        $translator = new \Bluz\Translator\Translator();
        $translator->setOptions(Config::get('translator'));
        $translator->init();

        Translator::setInstance($translator);
    }
1195356
def import_model(self, source):
        """"""
        source = self._resolve_source(source)
        self._context = FilePathContext(source)
        with self._context.open() as f:
            self._reader = self._open_reader(f)

        return self._reader.create_model()
531320
def create_translation_value
      batch_key = params[:batch_key]
      # batch_key might be "extra" or ..
      i18n_key = params[:i18n_key].sub(/^[.]*/, "")
      # regex above just incase there is a leading .
      full_i18n_key = batch_key.underscore.camelcase(:lower) + "." + i18n_key
      # eg propertyTypes.flat
      # subdomain = request.subdomain.downcase

      # http://stackoverflow.com/questions/5917355/find-or-create-race-conditions
      begin
        field_key = FieldKey.find_or_initialize_by(global_key: full_i18n_key)
        field_key.tag = batch_key
        field_key.save!
      rescue ActiveRecord::StatementInvalid => error
        @save_retry_count = (@save_retry_count || 5)
        retry if (@save_retry_count -= 1) > 0
        raise error
      end
      phrase = I18n::Backend::ActiveRecord::Translation.find_or_create_by(
        key: full_i18n_key,
      locale: params[:locale]
)
      phrase.value = params[:i18n_value]
      if phrase.save!
        I18n.backend.reload!
        return render json: { success: true }
      else
        return render json: { error: "unable to create phrase" }
      end
    end
297511
protected function generateTranslation()
    {
        $name = $this->qualifyClass($this->getNameInput());
        $path = $this->getTranslationPath($name);

        $this->makeDirectory($path);
        $this->files->put($path, $this->buildTranslation($name));

        $this->info('Translation also generated successfully.');
        $this->warn($path);
    }
264835
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'models' in _dict:
            args['models'] = [
                TranslationModel._from_dict(x) for x in (_dict.get('models'))
            ]
        else:
            raise ValueError(
                'Required property \'models\' not present in TranslationModels JSON'
            )
        return cls(**args)
1069893
def build(self, builder):
        """"""

        params = dict(OID=self.oid, Name=self.name)
        if self.field_number is not None:
            params["FieldNumber"] = str(self.field_number)

        builder.start("mdsol:LabelDef", params)

        for translation in self.translations:
            translation.build(builder)

        for view_restriction in self.view_restrictions:
            view_restriction.build(builder)

        builder.end("mdsol:LabelDef")
863147
def metamodel_from_str(lang_desc, metamodel=None, **kwargs):
    

    if not metamodel:
        metamodel = TextXMetaModel(**kwargs)

    language_from_str(lang_desc, metamodel)

    return metamodel
339752
def build(self, builder):
        """"""
        params = {}
        if self.lang is not None:
            params["xml:lang"] = self.lang
        builder.start("TranslatedText", params)
        builder.data(self.text)
        builder.end("TranslatedText")
1328198
def make_model(self):
        """"""
        for stmt in self.statements:
            if isinstance(stmt, Modification):
                card = assemble_modification(stmt)
            elif isinstance(stmt, SelfModification):
                card = assemble_selfmodification(stmt)
            elif isinstance(stmt, Complex):
                card = assemble_complex(stmt)
            elif isinstance(stmt, Translocation):
                card = assemble_translocation(stmt)
            elif isinstance(stmt, RegulateActivity):
                card = assemble_regulate_activity(stmt)
            elif isinstance(stmt, RegulateAmount):
                card = assemble_regulate_amount(stmt)
            else:
                continue
            if card is not None:
                card.card['meta'] = {'id': stmt.uuid, 'belief': stmt.belief}
                if self.pmc_override is not None:
                    card.card['pmc_id'] = self.pmc_override
                else:
                    card.card['pmc_id'] = get_pmc_id(stmt)
                self.cards.append(card)
1106574
private function configureTranslations()
    {
        if (null !== array_key_exists('translation', $this->options) && is_array($this->options['translation'])) {
            $translatable = $this->options['entity'];
            $translation = $this->options['translation']['entity'];

            $id = sprintf('%s.%s_translation', $this->prefix, $this->resourceName);

            // Load metadata event mapping
            $mapping = [
                $translatable => $translation,
                $translation  => $translatable,
            ];
            if ($this->container->hasParameter('ekyna_admin.translation_mapping')) {
                $mapping = array_merge($this->container->getParameter('ekyna_admin.translation_mapping'), $mapping);
            }
            $this->container->setParameter('ekyna_admin.translation_mapping', $mapping);

            // Translation class parameter
            if (!$this->container->hasParameter($id.'.class')) {
                $this->container->setParameter($id.'.class', $translation);
            }

            // Inheritance mapping
            $this->configureInheritanceMapping($id, $translation, $this->options['translation']['repository']);
        }
    }
643002
function translate(key, options, hasOwnOptions) {

			var lng = options.lng || 'auto';

			if (!translations[lng]) {
				translations[lng] = {};
			}

			if (!t) {
				translations[lng][key] = key;
			} else if (!translations[lng][key] || hasOwnOptions) {
				translations[lng][key] = t(key, options);
			}

		}
631977
def save_translations(self, instance, translated_data):
        
        for meta in self.Meta.model._parler_meta:
            translations = translated_data.get(meta.rel_name, {})
            for lang_code, model_fields in translations.items():
                translation = instance._get_translated_model(lang_code, auto_create=True, meta=meta)
                for field, value in model_fields.items():
                    setattr(translation, field, value)

        # Go through the same hooks as the regular model,
        # instead of calling translation.save() directly.
        instance.save_translations()
372560
def _init_update_po_files(self, domains):
        """"""
        for language in settings.TRANSLATIONS:
            for domain, options in domains.items():
                if language == options['default']: continue  # Default language of the domain doesn't need translations
                if os.path.isfile(_po_path(language, domain)):
                    # If the translation already exists, update it, keeping the parts already translated
                    self._update_po_file(language, domain, options['pot'])
                else:
                    # The translation doesn't exist, create a new translation file
                    self._init_po_file(language, domain, options['pot'])
219305
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'custom_language_model' in _dict:
            args['custom_language_model'] = _dict.get('custom_language_model')
        else:
            raise ValueError(
                'Required property \'custom_language_model\' not present in SupportedFeatures JSON'
            )
        if 'speaker_labels' in _dict:
            args['speaker_labels'] = _dict.get('speaker_labels')
        else:
            raise ValueError(
                'Required property \'speaker_labels\' not present in SupportedFeatures JSON'
            )
        return cls(**args)
435711
def create_default_translation
      translation = self.translations.build(value: self.name.to_s.split('.').last.titleize,
                                            lang: :en, status: 'accepted')
      translation.translator = TranslationCenter.prepare_translator

      translation.save
    end