mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 01:26:53 +03:00
update internationalisation instructions to prevent symlinking; add base .po file
This commit is contained in:
parent
2781903a5a
commit
0b8a83bd62
|
@ -9,12 +9,40 @@ 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:
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
```
|
||||
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`
|
||||
|
||||
---
|
||||
|
||||
|
@ -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
|
277
rest_framework/locale/en_US/LC_MESSAGES/django.po
Normal file
277
rest_framework/locale/en_US/LC_MESSAGES/django.po
Normal file
|
@ -0,0 +1,277 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-12-28 17:49+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: rest_framework/authtoken/serializers.py:20
|
||||
msgid "User account is disabled."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/authtoken/serializers.py:23
|
||||
msgid "Unable to log in with provided credentials."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/authtoken/serializers.py:26
|
||||
msgid "Must include \"username\" and \"password\""
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:39
|
||||
msgid "A server error occured"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:74
|
||||
msgid "Malformed request."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:79
|
||||
msgid "Incorrect authentication credentials."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:84
|
||||
msgid "Authentication credentials were not provided."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:89
|
||||
msgid "You do not have permission to perform this action."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:94
|
||||
#, python-format
|
||||
msgid "Method '%s' not allowed."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:105
|
||||
msgid "Could not satisfy the request Accept header"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:117
|
||||
#, python-format
|
||||
msgid "Unsupported media type '%s' in request."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:128
|
||||
msgid "Request was throttled."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/exceptions.py:130
|
||||
#, python-format
|
||||
msgid "Expected available in %(wait)d second."
|
||||
msgid_plural "Expected available in %(wait)d seconds."
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: rest_framework/fields.py:152 rest_framework/relations.py:131
|
||||
#: rest_framework/relations.py:155 rest_framework/validators.py:77
|
||||
#: rest_framework/validators.py:155
|
||||
msgid "This field is required."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:153
|
||||
msgid "This field may not be null."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:484 rest_framework/fields.py:512
|
||||
msgid "`{input}` is not a valid boolean."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:547
|
||||
msgid "This field may not be blank."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:548 rest_framework/fields.py:1250
|
||||
msgid "Ensure this field has no more than {max_length} characters."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:549
|
||||
msgid "Ensure this field has at least {min_length} characters."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:584
|
||||
msgid "Enter a valid email address."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:601
|
||||
msgid "This value does not match the required pattern."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:612
|
||||
msgid ""
|
||||
"Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:624
|
||||
msgid "Enter a valid URL."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:637
|
||||
msgid "A valid integer is required."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:638 rest_framework/fields.py:672
|
||||
#: rest_framework/fields.py:705
|
||||
msgid "Ensure this value is less than or equal to {max_value}."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:639 rest_framework/fields.py:673
|
||||
#: rest_framework/fields.py:706
|
||||
msgid "Ensure this value is greater than or equal to {min_value}."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:640 rest_framework/fields.py:674
|
||||
#: rest_framework/fields.py:710
|
||||
msgid "String value too large"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:671 rest_framework/fields.py:704
|
||||
msgid "A valid number is required."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:707
|
||||
msgid "Ensure that there are no more than {max_digits} digits in total."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:708
|
||||
msgid "Ensure that there are no more than {max_decimal_places} decimal places."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:709
|
||||
msgid ""
|
||||
"Ensure that there are no more than {max_whole_digits} digits before the "
|
||||
"decimal point."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:793
|
||||
msgid "Datetime has wrong format. Use one of these formats instead: {format}"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:794
|
||||
msgid "Expected a datetime but got a date."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:858
|
||||
msgid "Date has wrong format. Use one of these formats instead: {format}"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:859
|
||||
msgid "Expected a date but got a datetime."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:916
|
||||
msgid "Time has wrong format. Use one of these formats instead: {format}"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:972 rest_framework/fields.py:1016
|
||||
msgid "`{input}` is not a valid choice."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1017 rest_framework/serializers.py:474
|
||||
msgid "Expected a list of items but got type `{input_type}`."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1047
|
||||
msgid "No file was submitted."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1048
|
||||
msgid "The submitted data was not a file. Check the encoding type on the form."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1049
|
||||
msgid "No filename could be determined."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1050
|
||||
msgid "The submitted file is empty."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1051
|
||||
msgid ""
|
||||
"Ensure this filename has at most {max_length} characters (it has {length})."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1093
|
||||
msgid "Upload a valid image. The file you uploaded was either not an "
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/fields.py:1119
|
||||
msgid "Expected a list of items but got type `{input_type}`"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/generics.py:122
|
||||
msgid "Page is not 'last', nor can it be converted to an int."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/generics.py:126
|
||||
#, python-format
|
||||
msgid "Invalid page (%(page_number)s): %(message)s"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:132
|
||||
msgid "Invalid pk '{pk_value}' - object does not exist."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:133
|
||||
msgid "Incorrect type. Expected pk value, received {data_type}."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:156
|
||||
msgid "Invalid hyperlink - No URL match"
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:157
|
||||
msgid "Invalid hyperlink - Incorrect URL match."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:158
|
||||
msgid "Invalid hyperlink - Object does not exist."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:159
|
||||
msgid "Incorrect type. Expected URL string, received {data_type}."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:294
|
||||
msgid "Object with {slug_name}={value} does not exist."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/relations.py:295
|
||||
msgid "Invalid value."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/serializers.py:299
|
||||
msgid "Invalid data. Expected a dictionary, but got {datatype}."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/validators.py:22
|
||||
msgid "This field must be unique."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/validators.py:76
|
||||
msgid "The fields {field_names} must make a unique set."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/validators.py:219
|
||||
msgid "This field must be unique for the \"{date_field}\" date."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/validators.py:234
|
||||
msgid "This field must be unique for the \"{date_field}\" month."
|
||||
msgstr ""
|
||||
|
||||
#: rest_framework/validators.py:247
|
||||
msgid "This field must be unique for the \"{date_field}\" year."
|
||||
msgstr ""
|
Loading…
Reference in New Issue
Block a user