| 1 | .. _intro-install: |
|---|
| 2 | |
|---|
| 3 | Quick install guide |
|---|
| 4 | =================== |
|---|
| 5 | |
|---|
| 6 | Before you can use Transifex, you'll need to get it installed. This guide |
|---|
| 7 | will guide you to a simple, minimal installation that'll work while you |
|---|
| 8 | walk through the introduction. |
|---|
| 9 | |
|---|
| 10 | Installing Python |
|---|
| 11 | ----------------- |
|---|
| 12 | |
|---|
| 13 | Being a Python Web tool, Transifex requires Python. We recommend |
|---|
| 14 | installing Python 2.5 or later. |
|---|
| 15 | |
|---|
| 16 | Get Python at http://www.python.org. If you're running Linux or Mac OS X, |
|---|
| 17 | you probably already have it installed. |
|---|
| 18 | |
|---|
| 19 | You can verify that Python's installed by typing ``python`` from your |
|---|
| 20 | shell; you should see something like:: |
|---|
| 21 | |
|---|
| 22 | Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:51) |
|---|
| 23 | [GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2 |
|---|
| 24 | Type "help", "copyright", "credits" or "license" for more information. |
|---|
| 25 | >>> |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | Installing the Version Control Systems - VCS |
|---|
| 29 | -------------------------------------------- |
|---|
| 30 | |
|---|
| 31 | To run Transifex you need some VCS. Depending of which ones you want |
|---|
| 32 | to use, you will need to install some of the following packages: |
|---|
| 33 | |
|---|
| 34 | * Bazaar (bzr) |
|---|
| 35 | * CVS (cvs) |
|---|
| 36 | * Git (git) |
|---|
| 37 | * Mercurial (hg) |
|---|
| 38 | * Subversion (svn) |
|---|
| 39 | |
|---|
| 40 | On Fedora you can run the following command to install all those VCS:: |
|---|
| 41 | |
|---|
| 42 | yum install cvs subversion pysvn mercurial git bzr bzrtools |
|---|
| 43 | |
|---|
| 44 | If you're enabling the tarball support, you also need urlgrabber:: |
|---|
| 45 | |
|---|
| 46 | yum install python-urlgrabber |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | Installing Django |
|---|
| 50 | ----------------- |
|---|
| 51 | |
|---|
| 52 | Transifex is developed on top of a Python Web Framework called Django. We |
|---|
| 53 | recommend installing Django 1.0. You can get more information about how |
|---|
| 54 | to install Django in your system from the official Django documentation. |
|---|
| 55 | |
|---|
| 56 | Usually you can use the package your distribution provides you, or you can |
|---|
| 57 | even use `easy_install` to setup the package. On Fedora you can just run:: |
|---|
| 58 | |
|---|
| 59 | yum install Django |
|---|
| 60 | |
|---|
| 61 | .. _install-django-deps: |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | Installing Python dependencies |
|---|
| 65 | ------------------------------ |
|---|
| 66 | |
|---|
| 67 | This is the generic method for creating a development environment for |
|---|
| 68 | Transifex. We strongly suggest running those commands inside a virtualenv |
|---|
| 69 | environment instead of running them as root. For an example of a Virtualenv |
|---|
| 70 | setup, take a look at the `Virtualenv example`_ wiki page. You can also |
|---|
| 71 | install some of these dependencies as packages in your distribution, if they |
|---|
| 72 | are available. |
|---|
| 73 | |
|---|
| 74 | .. code-block:: bash |
|---|
| 75 | |
|---|
| 76 | easy_install Markdown httplib2 pygments polib |
|---|
| 77 | easy_install Django python-openid django-authopenid django-pagination |
|---|
| 78 | easy_install django-notification |
|---|
| 79 | easy_install -f http://transifex.org/files/deps/ contact_form tagging django_evolution userprofile |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | Installing translation-specific packages |
|---|
| 83 | ---------------------------------------- |
|---|
| 84 | |
|---|
| 85 | Transifex requires a couple of standard packages to support translations. |
|---|
| 86 | Currently these are the following.: |
|---|
| 87 | |
|---|
| 88 | * gettext (standard Internationalization library) |
|---|
| 89 | * intltool (for dynamic ``POT``-file generation) |
|---|
| 90 | |
|---|
| 91 | On Fedora you can just run:: |
|---|
| 92 | |
|---|
| 93 | yum install gettext intltool |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | A note on ``PythonPath`` |
|---|
| 97 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 98 | |
|---|
| 99 | These applications can be installed anywhere on your system, as long as Python |
|---|
| 100 | can find them. Python uses the ``PythonPath`` environment variable for this. |
|---|
| 101 | The value you use for ``PythonPath`` should include the parent directories of |
|---|
| 102 | all the modules you are going to import in your application. It should also |
|---|
| 103 | include the parent directory of Transifex itself. |
|---|
| 104 | This is exactly the same situation as |
|---|
| 105 | setting the Python path for interactive usage. Whenever you try to import |
|---|
| 106 | something, Python will run through all the directories in ``sys.path`` in turn, |
|---|
| 107 | from first to last, and try to import from each directory until one succeeds. |
|---|
| 108 | |
|---|
| 109 | An example might make this clearer. Suppose you have some applications under |
|---|
| 110 | ``/usr/local/django-apps/`` (for example, ``/usr/local/django-apps/weblog/`` and |
|---|
| 111 | so forth), your settings file is at ``/var/www/mysite/settings.py`` and you have |
|---|
| 112 | specified DJANGO_SETTINGS_MODULE_ as in the above |
|---|
| 113 | example. In this case, you would need to write your ``PythonPath`` directive |
|---|
| 114 | as:: |
|---|
| 115 | |
|---|
| 116 | PythonPath "['/usr/local/django-apps/', '/var/www'] + sys.path" |
|---|
| 117 | |
|---|
| 118 | With this path, ``import weblog`` and ``import mysite.settings`` will both |
|---|
| 119 | work. If you had ``import blogroll`` in your code somewhere and ``blogroll`` |
|---|
| 120 | lived under the ``weblog/`` directory, you would *also* need to add |
|---|
| 121 | ``/usr/local/django-apps/weblog/`` to your ``PythonPath``. Remember: the |
|---|
| 122 | **parent directories** of anything you import directly must be on the Python |
|---|
| 123 | path. |
|---|
| 124 | |
|---|
| 125 | .. _DJANGO_SETTINGS_MODULE: http://docs.djangoproject.com/en/dev/topics/settings/#django-settings-module |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | Installing Transifex |
|---|
| 129 | -------------------- |
|---|
| 130 | |
|---|
| 131 | You'll need to get Transifex, initialize its database and optionally import |
|---|
| 132 | some sample data. |
|---|
| 133 | |
|---|
| 134 | Get Transifex |
|---|
| 135 | ~~~~~~~~~~~~~ |
|---|
| 136 | |
|---|
| 137 | You can get the source code in a number of ways. |
|---|
| 138 | |
|---|
| 139 | Stable releases are available from the following location(s): |
|---|
| 140 | |
|---|
| 141 | - http://transifex.org/files/ |
|---|
| 142 | - http://pypi.python.org/pypi/transifex |
|---|
| 143 | |
|---|
| 144 | Soon, Tx will land in a yum repo near you, and you'll be able to |
|---|
| 145 | install it with something like ``yum install transifex``. See also the |
|---|
| 146 | README file in the root of your source. |
|---|
| 147 | |
|---|
| 148 | Development version |
|---|
| 149 | +++++++++++++++++++ |
|---|
| 150 | |
|---|
| 151 | The current development version of Transifex can be fetched by cloning the |
|---|
| 152 | development repo:: |
|---|
| 153 | |
|---|
| 154 | hg clone http://code.transifex.org/mainline |
|---|
| 155 | |
|---|
| 156 | From here you can also switch to stable versions, which are tagged |
|---|
| 157 | appropriately.:: |
|---|
| 158 | |
|---|
| 159 | hg tags |
|---|
| 160 | hg update <tag> |
|---|
| 161 | |
|---|
| 162 | To grab a branched development version of Transifex, you can navigate to |
|---|
| 163 | http://code.transifex.org/ to see the active branches. |
|---|
| 164 | |
|---|
| 165 | Initialize the database |
|---|
| 166 | ~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 167 | |
|---|
| 168 | After you have all dependencies and packages installed, the Transifex |
|---|
| 169 | installation should be very simple. Customize ``settings/*.conf`` and |
|---|
| 170 | ``urls.py`` to accommodate your server's needs. |
|---|
| 171 | |
|---|
| 172 | To enable Transifex's notifications you'll need to switch the relevant setting |
|---|
| 173 | called ENABLE_NOTICES to ``True``. |
|---|
| 174 | |
|---|
| 175 | Once you're done configuring, run inside the project directory:: |
|---|
| 176 | |
|---|
| 177 | ./manage.py syncdb |
|---|
| 178 | ./manage.py txcreatedirs |
|---|
| 179 | ./manage.py runserver 8088 |
|---|
| 180 | |
|---|
| 181 | The first command will create the necessary database tables. It will also ask |
|---|
| 182 | you to create an admin user (superuser), who will have access to the admin panel |
|---|
| 183 | (by default accessible through ``/admin/``). |
|---|
| 184 | |
|---|
| 185 | Fire up your browser at ``http://localhost:8088/`` and grab a cup of coffee. |
|---|
| 186 | |
|---|
| 187 | .. warning:: |
|---|
| 188 | |
|---|
| 189 | Make sure you have created in your system all the directories configured |
|---|
| 190 | in your ``settings.py`` file, like the ``REPO_PATH`` for example. |
|---|
| 191 | Without those paths created, the checkout for these VCS, among others will |
|---|
| 192 | fail. |
|---|
| 193 | |
|---|
| 194 | Import some data |
|---|
| 195 | ~~~~~~~~~~~~~~~~ |
|---|
| 196 | |
|---|
| 197 | Transifex uses the fixtures feature of Django to load some initial datas |
|---|
| 198 | in the database. The following commands require you having run |
|---|
| 199 | ``./manage.py syncdb`` at least once before in order for the database tables |
|---|
| 200 | to exist. |
|---|
| 201 | |
|---|
| 202 | The following commands loads a bunch of sample data to play around with. |
|---|
| 203 | |
|---|
| 204 | .. code-block:: bash |
|---|
| 205 | |
|---|
| 206 | ./manage.py loaddata txcommon/fixtures/sample_data.json |
|---|
| 207 | ./manage.py loaddata txcommon/fixtures/sample_users.json |
|---|
| 208 | |
|---|
| 209 | The last command created two users: 'guest' and 'editor'. The 'guest' has the |
|---|
| 210 | basic rights of a logged-in user of the site, while the 'editor' account has |
|---|
| 211 | more advanced privileges like modifying projects, etc. Together with the 'admin' |
|---|
| 212 | user created with the 'syncdb' step above, you should have 3 accounts now, each |
|---|
| 213 | with its own access level. |
|---|
| 214 | |
|---|
| 215 | You can now fire up your browser to check out the newly imported data. |
|---|
| 216 | |
|---|
| 217 | Note that the registered projects have not been actually checked out by |
|---|
| 218 | Transifex yet. To have translation files downloaded and fresh statistics |
|---|
| 219 | produced, run a fresh checkout:: |
|---|
| 220 | |
|---|
| 221 | ./manage.py txstatsrefresh |
|---|
| 222 | |
|---|
| 223 | This command is usually used in a cronjob to refresh Transifex's cache and |
|---|
| 224 | translation statistics every once in a while for translators. |
|---|
| 225 | |
|---|
| 226 | Internationalization (i18n) support |
|---|
| 227 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 228 | |
|---|
| 229 | To be able to use Transifex with a localized interface, it is necessary to |
|---|
| 230 | create the translations objects files (.mo) using one of the following commands, |
|---|
| 231 | for example: |
|---|
| 232 | |
|---|
| 233 | .. code-block:: bash |
|---|
| 234 | |
|---|
| 235 | ./manage.py compilemessages -l pt_BR |
|---|
| 236 | or |
|---|
| 237 | ./manage.py compilemessages --all |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | Customizing your Transifex instance |
|---|
| 241 | ----------------------------------- |
|---|
| 242 | |
|---|
| 243 | Site Domain and Name |
|---|
| 244 | ~~~~~~~~~~~~~~~~~~~~ |
|---|
| 245 | |
|---|
| 246 | Transifex leverages the power of Django's Sites_ framework to make it easy |
|---|
| 247 | to have instances of Transifex on differnet domains using the same models |
|---|
| 248 | and database. |
|---|
| 249 | |
|---|
| 250 | Upon installation, a single website is created in the database called |
|---|
| 251 | 'example.com'. This value is used in a number of places, including emails sent |
|---|
| 252 | by the system. You can customize this value in two ways: |
|---|
| 253 | |
|---|
| 254 | * Using the `Django admin panel`_: By default Transifex comes with a handy |
|---|
| 255 | admin panel. This is mounted by default at ``/admin/`` (this value can be |
|---|
| 256 | changed from your settings file. |
|---|
| 257 | |
|---|
| 258 | Login to the admin panel using the credentials you created during the |
|---|
| 259 | database creation step. You'll find the 'example.com' entry in the ``Sites`` |
|---|
| 260 | model, which you can edit to your needs. |
|---|
| 261 | |
|---|
| 262 | * Using the command line:: |
|---|
| 263 | |
|---|
| 264 | from django.contrib.sites.models import Site |
|---|
| 265 | current_site = Site.objects.get_current() |
|---|
| 266 | current_site.name = 'Transifex' |
|---|
| 267 | current_site.domain = 'mydomain.com' |
|---|
| 268 | current_site.save() |
|---|
| 269 | |
|---|
| 270 | User Interface |
|---|
| 271 | ~~~~~~~~~~~~~~ |
|---|
| 272 | |
|---|
| 273 | The default Transifex interface lives in the ``templates`` directory and can |
|---|
| 274 | be customized at will. |
|---|
| 275 | |
|---|
| 276 | You can also customize the theme by copying this directory to a differnet |
|---|
| 277 | location and updating the ``TEMPLATE_DIR`` setting with this new location. |
|---|
| 278 | |
|---|
| 279 | Finally, Django supports multiple locations of template source files, which it |
|---|
| 280 | searches in order. Instead of copying the entire template directory, you can |
|---|
| 281 | simply copy particular files you'd like to override and define the |
|---|
| 282 | ``TEMPLATE_DIR`` setting as a tuple in the order you'd like the directories |
|---|
| 283 | to be searched (first entry takes preference over second, etc). |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | Debugging |
|---|
| 287 | --------- |
|---|
| 288 | |
|---|
| 289 | Debugging is enabled through a separete ``SETTINGS`` file, which enables some |
|---|
| 290 | additional applications and features. Some of these additional applications |
|---|
| 291 | might require installation using ``easy_install``, but you can enable any |
|---|
| 292 | number you want by editing the ``settings_debug.py`` file. |
|---|
| 293 | |
|---|
| 294 | Some of these applications define their own models, so the first time you'll |
|---|
| 295 | use the file, a 'syncdb' using that file will be needed to have the respective |
|---|
| 296 | database tables created:: |
|---|
| 297 | |
|---|
| 298 | ./manage.py syncdb --settings settings_debug |
|---|
| 299 | |
|---|
| 300 | From that point on, you can run the debug server as follows:: |
|---|
| 301 | |
|---|
| 302 | ./manage.py runserver --settings settings_debug |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | Testing |
|---|
| 306 | ------- |
|---|
| 307 | |
|---|
| 308 | For testing the whole project you can run:: |
|---|
| 309 | |
|---|
| 310 | ./manage.py test |
|---|
| 311 | |
|---|
| 312 | For testing a specific application inside Transifex you can run:: |
|---|
| 313 | |
|---|
| 314 | ./manage.py test projects |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | .. _Sites: http://docs.djangoproject.com/en/dev/ref/contrib/sites |
|---|
| 318 | .. _`Django admin panel`: http://www.djangobook.com/en/1.0/chapter06/ |
|---|
| 319 | .. _`Virtualenv example`: http://transifex.org/wiki/Development/InstallationOnCentOS_VirtaualEnv |
|---|