def handle_translation_project(self, tp, **options): """Push translation project units to local TM.""" for store in tp.stores.iterator(): self.stdout.write("Adding translations from %r" % (store)) with transaction.atomic(): for unit in Unit.objects.filter(store=store, state__gte=TRANSLATED).iterator(): tmunit = TMUnit().create(unit) tmunit.save()
def handle_translation_project(self, tp, **options): """Push translation project units to local TM.""" for store in tp.stores.iterator(): self.stdout.write("Adding translations from %r" % (store)) with transaction.atomic(): for unit in Unit.objects.filter( store=store, state__gte=TRANSLATED).iterator(): tmunit = TMUnit().create(unit) tmunit.save()
def create_local_tm(): """Create the local TM using translations from existing projects. Iterates over all the translation units and creates the corresponding local TM units. """ logging.info('About to create local TM using existing translations') with transaction.commit_on_success(): for unit in Unit.objects.filter(state__gte=TRANSLATED).iterator(): tmunit = TMUnit().create(unit) tmunit.save() logging.info('Successfully created local TM from existing translations')
def upgrade_to_25200(): """Post-upgrade actions for upgrades to 25200.""" from django.db import transaction from pootle_store.models import TMUnit, Unit from pootle_store.util import TRANSLATED # Populate local TM from existing translation units. logging.info('About to create local TM using existing translations') with transaction.commit_on_success(): for unit in Unit.objects.filter(state__gte=TRANSLATED).iterator(): tmunit = TMUnit().create(unit) tmunit.save() logging.info('Succesfully created local TM from existing translations')