diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 2c5b83281..2eeac2a9c 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -106,6 +106,36 @@ If you wish to use localizations/translations, simply add ... ] +Alternatively, if you do not want to add ``rest_framework_simplejwt`` to +``INSTALLED_APPS``, you can enable translations by adding its locale directory to +``LOCALE_PATHS`` in your ``settings.py``: + +.. code-block:: python + + import os + from rest_framework_simplejwt import __file__ as simplejwt_file + + LOCALE_PATHS = [ + os.path.join(os.path.dirname(simplejwt_file), 'locale'), + ] + +In order for per-request language selection (via the ``Accept-Language`` header) +to work in views and error responses, ensure Django's ``LocaleMiddleware`` is +enabled and appears after ``SessionMiddleware`` and before ``CommonMiddleware``: + +.. code-block:: python + + MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + ] + Usage ----- diff --git a/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.mo b/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.mo index a7dea8eca..0f24d038f 100644 Binary files a/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.mo and b/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.mo differ diff --git a/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.po b/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.po index 27bacc099..4b760fcc7 100644 --- a/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.po +++ b/rest_framework_simplejwt/locale/es_CL/LC_MESSAGES/django.po @@ -100,7 +100,7 @@ msgstr "jti" #: token_blacklist/admin.py:85 msgid "user" -msgstr "Usuario" +msgstr "usuario" #: token_blacklist/admin.py:91 msgid "created at" diff --git a/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.mo b/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.mo index 145b393f9..4da4bba2c 100644 Binary files a/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.mo and b/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.mo differ diff --git a/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.po b/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.po index 67cd7caa1..54e69bc48 100644 --- a/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.po +++ b/rest_framework_simplejwt/locale/fa/LC_MESSAGES/django.po @@ -85,7 +85,7 @@ msgstr "توکن در لیست سیاه قرار گرفته است" msgid "" "The '{}' setting has been removed. Please refer to '{}' for available " "settings." -msgstr "تنظیمات '{}' حذف شده است. لطفاً به '{}' برای تنظیمات موجود مراجعه کنید." +msgstr "تنظیمات '{}' حذف شده است. لطفا به '{}' برای تنظیمات موجود مراجعه کنید." #: token_blacklist/admin.py:79 msgid "jti" @@ -122,16 +122,16 @@ msgstr "توکن برای %(user)s (%(jti)s)" #: token_blacklist/models.py:45 msgid "Blacklisted Token" -msgstr "توکن لیست سیاه شده" +msgstr "توکن در لیست سیاه" #: token_blacklist/models.py:46 msgid "Blacklisted Tokens" -msgstr "توکن‌های لیست سیاه شده" +msgstr "توکن‌های لیست سیاه" #: token_blacklist/models.py:57 #, python-format msgid "Blacklisted token for %(user)s" -msgstr "توکن لیست سیاه شده برای %(user)s" +msgstr "توکن لیست سیاه برای %(user)s" #: tokens.py:53 msgid "Cannot create token with no type or lifetime" diff --git a/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.mo b/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.mo index e76a81308..ea0b22a54 100644 Binary files a/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.mo and b/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.mo differ diff --git a/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.po b/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.po index e6cc74898..191174647 100644 --- a/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.po +++ b/rest_framework_simplejwt/locale/fa_IR/LC_MESSAGES/django.po @@ -70,11 +70,11 @@ msgstr "هیچ اکانت فعالی برای اطلاعات داده شده ی #: serializers.py:109 serializers.py:179 msgid "No active account found for the given token." -msgstr "هیچ اکانت فعالی برای توکن داده شده یافت نشد" +msgstr "هیچ اکانت فعالی برای این توکن یافت نشد" #: serializers.py:245 tokens.py:280 msgid "Token is blacklisted" -msgstr "توکن به لیست سیاه رفته است" +msgstr "توکن در لیست سیاه قرار گرفته است" #: settings.py:74 msgid "" @@ -130,7 +130,7 @@ msgstr "توکن لیست سیاه برای %(user)s" #: tokens.py:53 msgid "Cannot create token with no type or lifetime" -msgstr "توکن بدون هیچ نوع و طول عمر قابل ساخت نیست" +msgstr "توکن بدون نوع یا طول عمر قابل ایجاد نیست" #: tokens.py:127 msgid "Token has no id" @@ -138,11 +138,11 @@ msgstr "توکن id ندارد" #: tokens.py:139 msgid "Token has no type" -msgstr "توکن نوع ندارد" +msgstr "توکن نوعی ندارد" #: tokens.py:142 msgid "Token has wrong type" -msgstr "توکن نوع اشتباهی دارد" +msgstr "توکن دارای نوع نادرستی است" #: tokens.py:201 msgid "Token has no '{}' claim" diff --git a/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.mo b/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.mo index 5165dd912..13ddf15d2 100644 Binary files a/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.mo and b/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.mo differ diff --git a/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.po b/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.po index 6cb99de26..aa76a64e1 100644 --- a/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.po +++ b/rest_framework_simplejwt/locale/fr/LC_MESSAGES/django.po @@ -98,7 +98,7 @@ msgstr "jti" #: token_blacklist/admin.py:85 msgid "user" -msgstr "Utilisateur" +msgstr "utilisateur" #: token_blacklist/admin.py:91 msgid "created at" diff --git a/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.mo b/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.mo index f68b4bf84..840072603 100644 Binary files a/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.mo and b/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.mo differ diff --git a/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.po b/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.po index 42c818963..1a87db9ce 100644 --- a/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.po +++ b/rest_framework_simplejwt/locale/nl_NL/LC_MESSAGES/django.po @@ -38,7 +38,7 @@ msgstr "Gebruiker is inactief" #: backends.py:90 msgid "Unrecognized algorithm type '{}'" -msgstr "Niet herkend algoritme type '{}" +msgstr "Niet herkend algoritme type '{}'" #: backends.py:96 msgid "You must have cryptography installed to use {}."