aboutsummaryrefslogtreecommitdiffstats
path: root/docs/topics
diff options
context:
space:
mode:
authorCraig Blaszczyk2014-12-28 18:20:41 +0000
committerCraig Blaszczyk2015-01-02 11:08:04 +0000
commit0b8a83bd624673cb0a05e01c691729ccee3a8782 (patch)
tree19bfad6ef640e3e00b6ea8b5588b9be76ad4d8db /docs/topics
parent2781903a5a0be7f5314de54ff2dbc8ef393eab0a (diff)
downloaddjango-rest-framework-0b8a83bd624673cb0a05e01c691729ccee3a8782.tar.bz2
update internationalisation instructions to prevent symlinking; add base .po file
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/internationalisation.md52
1 files changed, 41 insertions, 11 deletions
diff --git a/docs/topics/internationalisation.md b/docs/topics/internationalisation.md
index a0aab753..6470ee03 100644
--- a/docs/topics/internationalisation.md
+++ b/docs/topics/internationalisation.md
@@ -9,13 +9,41 @@ This guide assumes you are already familiar with how to translate a Django app.
#### To translate REST framework error messages:
-1. Pick an app where you want the translations to be, for example `myapp`
+1. Make a new folder where you want to store the translated errors. Add this
+path to your [`LOCALE_PATHS`][django-locale-paths] setting.
+
+ ---
+
+ **Note:** For the rest of
+this document we will assume the path you created was
+`/home/www/project/conf/locale/`, and that you have updated your `settings.py` to include the setting:
+
+ ```
+ LOCALE_PATHS = (
+ '/home/www/project/conf/locale/',
+ )
+ ```
+
+ ---
+
+2. Now create a subfolder for the language you want to translate. The folder should be named using [locale
+name][django-locale-name] notation. E.g. `de`, `pt_BR`, `es_AR`, etc.
-2. Add a symlink from that app to the installed `rest_framework`
```
- ln -s /home/user/.virtualenvs/myproject/lib/python2.7/site-packages/rest_framework/ rest_framework
+ mkdir /home/www/project/conf/locale/pt_BR/LC_MESSAGES
+ ```
+
+3. Now copy the base translations file from the REST framework source code
+into your translations folder
+
+ ```
+ cp /home/user/.virtualenvs/myproject/lib/python2.7/site-packages/rest_framework/locale/en_US/LC_MESSAGES/django.po
+ /home/www/project/conf/locale/pt_BR/LC_MESSAGES
```
+ This should create the file
+ `/home/www/project/conf/locale/pt_BR/LC_MESSAGES/django.po`
+
---
**Note:** To find out where `rest_framework` is installed, run
@@ -27,17 +55,17 @@ This guide assumes you are already familiar with how to translate a Django app.
---
+4. Edit `/home/www/project/conf/locale/pt_BR/LC_MESSAGES/django.po` and
+translate all the error messages.
-3. Run Django's `makemessages` command in the normal way, but add the `--symlink` option. For example, if you want to translate into Brazilian Portuguese you would run
- ```
- manage.py makemessages --symlink -l pt_BR
- ```
-
-4. Translate the `django.po` file which is created as normal. This will be in the folder `myapp/locale/pt_BR/LC_MESSAGES`.
+5. Run `manage.py compilemessages -l pt_BR` to make the translations
+available for Django to use. You should see a message
-5. Run `manage.py compilemessages` as normal
+ ```
+ processing file django.po in /home/www/project/conf/locale/pt_BR/LC_MESSAGES
+ ```
-6. Restart your server
+6. Restart your server.
@@ -59,3 +87,5 @@ REST framework will use the same preferences to select which language to display
[django-translation]: https://docs.djangoproject.com/en/1.7/topics/i18n/translation
[django-language-preference]: https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#how-django-discovers-language-preference
+[django-locale-paths]: https://docs.djangoproject.com/en/1.7/ref/settings/#std:setting-LOCALE_PATHS
+[django-locale-name]: https://docs.djangoproject.com/en/1.7/topics/i18n/#term-locale-name \ No newline at end of file