Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

Transifex Common-Pool

Transifex Common-Pool is a project to provide a web service to localize Mozilla JetPacks. It is a set of Transifex addons which add the necessary functionality (common strings, overrides, filters etc) needed for this project.

The code consists of a number of addons, including:

foxcore:
Base models and API calls
foxlotte:
Build-in translation web-based editor with commonpool functionality

Installation Instructions

  1. Setup Transifex normally somewhere. This can be either in your Python path or elsewhere:

    mkdir ~/devel
    cd ~/devel
    hg clone http://code.indifex.com/transifex
    
  2. Setup your new project:

    hg clone http://code.indifex.com/transifex-commonpool
    
  3. Make sure the 'TX_ROOT' config option points to your upstream Transifex project directory.

    You may configure your project by editing the files in the 'settings' directory. Files matching the pattern settings/*-local.conf are ignored by Mercurial.

    Example: Create a config file to be executed before the base config file, and if needed, one executed afterwards. Here's an example of a '09-base-local.conf' file:

    TX_ROOT = '~/devel/transifex/transifex'
    
  4. Disable the default web editor ('lotte') since 'transifex-commonpool' comes with its own flavor of the editor.

    ./manage.py addons -d lotte

  5. Test the setup by listing the addons. You should see all addons provided by Transifex as well as the Commonpool-specific ones. Also, 'foxlotte' should have replaced 'lotte':

    ./manage.py addons
    
  6. Finally setup your DB, and run your project as described in the Installation Instructions:

    ./manage.py syncdb --noinput
    ./manage.py migrate
    ./manage.py txcreatenoticetypes
    ./manage.py txlanguages
    ./manage.py loaddata sample_users.json sample_mozilla_data.json
    ./manage.py build_static
    

7. If you installed the sample_mozilla_data fixture then you need to update some statistics because post save signals don't work that well with fixture loading. The steps you need to do are the following:

./manage.py shell

In [1]: from transifex.resources.models import Translation In [2]: for t in Translation.objects.all(): t.save()

./manage.py txstatsupdate

If you didn't use the aforementioned json fixture then you can safely skip this step.

That's it!

Overriding templates

The commonpool project comes with a few templates which override the Transifex default ones. For example, a handy 'base.html' template which removes the search bar. You can find these files and add additional custom ones in the 'templates' directory.

CommonPool API

You should be ready to go. 'foxcore' includes the push/pull strings, exception API calls and the enhancements in the data model. Here is how you can test the API:

  1. Create a project using the web interface (e.g. named 'Mozilla Jetpacks' with a slug 'mozjp'). This slug can be configured in the foxcore settings.

  2. Download the CommonPool client and insert some strings:

    hg clone http://bitbucket.org/indifex/commonpool-client
    cd commonpool-client
    ./extract.py -r localhost:8000 -p mozjp -l editor -P editor test_data/testpack/
    
  3. You have access to the API calls from the following urls. 'api-moz' is just a keyword we're using in order to avoid collision with the rest of the API calls which are under /api/:

    • http://<host:port>/api-moz/foo/strings - Pull/push strings
    • http://<host:port>/api-moz/foo/overrides - Pull overrides (exceptions)

Available API options are :

strings:
Search for specific strings (e.g. ?strings=next,cancel)
jetpacks:
Search for strings inside these jetpacks (e.g. ?jetpacks=testpack,testpack2)
languages:
Return translations in these languages (e.g. ?languages=el,fr,de)
partial (only available in strings handler):

If set to 1, the API will return partial translations for languages that are not 100% completed. The default behaviour is to return 100% translation by using the fallback mechanism.

The fallback mechanism has two modes of operation. It can do a complete fallback (eg if pt_BR is not 100% return the complete translation in pt) or do partial fallbacks (eg if a string is not translated in pt_BR fetch the pt translation. The returned stringset is a mix of various languages this way). This behaviour can be changed by editing settings/00-base.conf of foxcore.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.