projects — Transifex v0.8.0 documentation

# Transifex v0.8.0 documentation

# `projects`

## Feeds

class `ReleaseFeed`(slug, request)
  A feed for all the languages for this release.

class `ReleaseLanguageFeed`(slug, request)
  A feed for all the languages for this release.

## Forms

## Models

class `Component`(*args, **kwargs)

  A component is a translatable resource.

  `clear_cache`()

    Clear the local cache of the component.

    Delete statistics, teardown repo, remove static dir, rest unit.

  `delete_static_dir`()
    Delete the directory of static content for a component
  `get_files`()
    Return a list of filtered files for the component.
  `get_rev`(path=None)
    Get revision of a path from the underlying Unit
  `pofiles`
    This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.
  `prepare`()

    Abstract unit.prepare().

    This function creates/updates the Component local repository and then unset the TransHandler property cache for it be created again, with a new set of files, next time that it will be used.

  `rename_static_dir`(new_name)
    Rename the directory of static content for a component
  `set_unit`(root, type, branch=None, web_frontend=None)

    Associate a unit with this component.

    Another place the same functionality happens is when the Component form is saved.

class `Project`(*args, **kwargs)

  A project is a group of translatable resources.

      >>> p = Project.objects.create(slug="foo", name="Foo Project")
      >>> p = Project.objects.get(slug='foo')
      >>> p
      <Project: Foo Project>
      >>> Project.objects.create(slug="foo", name="Foo Project")
      Traceback (most recent call last):
          ...
      IntegrityError: column slug is not unique
      >>> p.delete()

  `blacklist_vcsunits`
    Return all the vcsunits that arent allowed to be used.
  `save`(*args, **kwargs)
    Save the object in the database.

class `Release`(*args, **kwargs)

  A release of a project, as in ‘a set of specific components’.

  Represents the packaging and releasing of a software project (big or small) on a particular date, for which makes sense to track translations across the whole release.

  Examples of Releases is Transifex 1.0, GNOME 2.26, Fedora 10 etc.

`cached_property`(func)

  Cached property.

  This function is able to verify if an instance of a property field was already created before and, if not, it creates the new one. When needed it also is able to delete the cached property field from the memory.

  Usage: @cached_property def trans(self):

  > ...

  del(self.trans)

## Views

`slug_feed`(request, slug=None, param='', feed_dict=None)

  Override default feed, using custom (including inexistent) slug.

  Provides the functionality needed to decouple the Feed’s slug from the urlconf, so a feed mounted at “^/feed” can exist.

  See also http://code.djangoproject.com/ticket/6969.

## I18n Library

`get_trans_handler`(i18n_type)

  Return an appropriate TransHandler class.

  TransHandler is chosen depending on the component translation type.

  It will raise an exception if the Translation type is not specified.

  Keyword arguments: i18n_type – The type of the TransHandler, used to decide the class to be returned.

      >>> print get_trans_handler('POT')
      projects.handlers.trans_handler.TransHandler

### Types

#### POT

class `POTHandler`(component)

  POTManager abstraction layer, specific to the projects app.

  You can use this higher-level object to interact with a component’s statistics instead of meddling with the lower- level POTManager. Each Component object gets one of these as `component.trans`.

  `clean_old_stats`()

    Clean old stats present on the database and msgmerge directory.

    Useful for removing files that are not present in the upstream repository anymore.

  `clean_stats`()
    Clean all stats of translations for the component in the database.
  `get_file_contents`(filename, is_msgmerged)
    Abstraction for getting the contents of a filename.
  `get_lang_stats`(lang_code)
    Return stats of the component in a specific language from the database.
  `get_po_entries`(filename)
    Abstration for getting a polib.POFile with the entries of filename.
  `get_po_stats`(po_contents)
    Abstraction for getting a dictionary with the stats for a POT/PO file content.
  `get_rest_stats`()
    Return stats for the component as a restructured text table.
  `get_source_file`()
    Abstration for getting source files.
  `get_source_stats`()
    Return the source file (pot) stats from the database.
  `get_stats`()
    Return stats for the component from the database.
  `get_stats_completion`(stats)
    Abstraction for getting the completion of a po file stats disctionaty.
  `get_stats_status`(stats)
    Abstraction for getting the status of the stats completion.
  `guess_language`(filename)
    Abstraction for guessing a language code from a filename.
  `msgfmt_check`(po_contents)
    Abstraction for POT/PO file checking with ‘msgfmt -c’.
  `set_file_stats`(filename, is_msgmerged=True, is_pot=False)
    Set the statistics of a specificy file for an object.
  `set_lang_stats`(lang_code, is_msgmerged=True)
    Set stats for a specificy language.
  `set_po_stats`(is_msgmerged)
    Set the stats for po files (po) in the database
  `set_source_stats`(is_msgmerged)
    Set the stats for source files (pot) in the database.
  `set_stats`()
    Calculate stats for all translations of the component.
  `set_stats_base`(is_msgmerged=True, is_pot=False)
    Set the source file (pot) in the database

#### Intltool

class `IntltoolHandler`(component)

  POTHandler abstraction layer, hense specific to the projects app.

  You can use this higher-level object to interact with a component’s statistics that use intltool instead of meddling with the lower-level POTManager. Each Component object gets one of these as `component.trans`.

  `set_stats`()
    Calculate stats for all translations of the component after these translations are merged with a new POT file extracted using intltool-update. .

## Management commands

class `Command`

  Refresh translation statistics of registered components.

  `handle`(*comps, **options)
    Override default method to make it work without arguments.
  `refresh_stats`(comp_name, **options)
    Refresh the statistics of a component with full_name ‘comp_name’.