Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it i18n and add zh_hans locale file. #484

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include README.rst LICENSE
include oauth2_provider/locale/*/LC_MESSAGES/django.*
recursive-include oauth2_provider/templates *.html
4 changes: 2 additions & 2 deletions oauth2_provider/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig

from django.utils.translation import gettext_lazy as _

class DOTConfig(AppConfig):
name = "oauth2_provider"
verbose_name = "Django OAuth Toolkit"
verbose_name = _("Django OAuth Toolkit")
234 changes: 234 additions & 0 deletions oauth2_provider/locale/zh_Hans/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
# 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.
#
msgid ""
msgstr ""
"Project-Id-Version: oauth2_provider\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-06 11:45+0800\n"
"PO-Revision-Date: 2017-06-06 11:45+0800\n"
"Last-Translator: \n"
"Language-Team: lch@jfpal.com\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 2.0.2\n"
"X-Poedit-SourceCharset: UTF-8\n"

#: oauth2_provider/apps.py:6
msgid "Django OAuth Toolkit"
msgstr "Django OAuth工具集"

#: oauth2_provider/models.py:45
msgid "Confidential"
msgstr "内部应用"

#: oauth2_provider/models.py:46
msgid "Public"
msgstr "开放应用"

#: oauth2_provider/models.py:54
msgid "Authorization code"
msgstr "授权码模式"

#: oauth2_provider/models.py:55
msgid "Implicit"
msgstr "简化模式"

#: oauth2_provider/models.py:56
msgid "Resource owner password-based"
msgstr "密码模式"

#: oauth2_provider/models.py:57
msgid "Client credentials"
msgstr "客户端模式"

#: oauth2_provider/models.py:62
msgid "Client ID"
msgstr "客户端ID"

#: oauth2_provider/models.py:70
msgid "Allowed URIs list, space separated"
msgstr "允许的 Uri 列表,空格分隔"

#: oauth2_provider/models.py:72
msgid "Redirect URIs"
msgstr "重定向URI列表"

#: oauth2_provider/models.py:75
#: oauth2_provider/templates/oauth2_provider/application_detail.html:20
msgid "Client type"
msgstr "客户端类型"

#: oauth2_provider/models.py:77
msgid "Ref: https://tools.ietf.org/html/rfc6749#page-9"
msgstr "参考: http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html"

#: oauth2_provider/models.py:79
msgid "Authorization grant type"
msgstr "授权类型"

#: oauth2_provider/models.py:82
#: oauth2_provider/templates/oauth2_provider/application_detail.html:15
msgid "Client secret"
msgstr "客户端密码"

#: oauth2_provider/models.py:84
msgid "Name"
msgstr "名称"

#: oauth2_provider/models.py:85
msgid "Skip authorization"
msgstr "跳过用户认证"

#: oauth2_provider/models.py:133
#, python-brace-format
msgid "Redirect_uris could not be empty with {grant_type} grant_type"
msgstr "Redirect_uris 不能空与 {grant_type} grant_type"

#: oauth2_provider/models.py:157
msgid "Application"
msgstr "客户端"

#: oauth2_provider/models.py:158
msgid "Applications"
msgstr "客户端"

#: oauth2_provider/models.py:177 oauth2_provider/models.py:230
#: oauth2_provider/models.py:317
msgid "ID"
msgstr "ID"

#: oauth2_provider/models.py:182
msgid "Code"
msgstr "认证码"

#: oauth2_provider/models.py:186 oauth2_provider/models.py:239
msgid "Expires"
msgstr "过期时间"

#: oauth2_provider/models.py:187
msgid "Redirect URI"
msgstr "重定向URI列表"

#: oauth2_provider/models.py:188 oauth2_provider/models.py:240
msgid "Scope"
msgstr "授权域"

#: oauth2_provider/models.py:212
msgid "Grant"
msgstr "授权"

#: oauth2_provider/models.py:213
msgid "Grants"
msgstr "授权"

#: oauth2_provider/models.py:235 oauth2_provider/models.py:322
msgid "Token"
msgstr "Token"

#: oauth2_provider/models.py:299
msgid "Access token"
msgstr "Access token"

#: oauth2_provider/models.py:300
msgid "Access tokens"
msgstr "Access Tokens"

#: oauth2_provider/models.py:348
msgid "Refresh token"
msgstr "Refresh token"

#: oauth2_provider/models.py:349
msgid "Refresh tokens"
msgstr "Refresh tokens"

#: oauth2_provider/templates/oauth2_provider/application_confirm_delete.html:6
msgid "Are you sure to delete the application"
msgstr "确定删除此客户端"

#: oauth2_provider/templates/oauth2_provider/application_confirm_delete.html:12
msgid "Cancel"
msgstr "取消"

#: oauth2_provider/templates/oauth2_provider/application_confirm_delete.html:13
#: oauth2_provider/templates/oauth2_provider/application_detail.html:38
#: oauth2_provider/templates/oauth2_provider/authorized-token-delete.html:7
msgid "Delete"
msgstr "删除"

#: oauth2_provider/templates/oauth2_provider/application_detail.html:10
msgid "Client id"
msgstr "客户端ID"

#: oauth2_provider/templates/oauth2_provider/application_detail.html:25
msgid "Authorization Grant Type"
msgstr "授权类型"

#: oauth2_provider/templates/oauth2_provider/application_detail.html:30
msgid "Redirect Uris"
msgstr "重定向用户至"

#: oauth2_provider/templates/oauth2_provider/application_detail.html:36
#: oauth2_provider/templates/oauth2_provider/application_form.html:35
msgid "Go Back"
msgstr "返回"

#: oauth2_provider/templates/oauth2_provider/application_detail.html:37
msgid "Edit"
msgstr "编辑"

#: oauth2_provider/templates/oauth2_provider/application_form.html:9
msgid "Edit application"
msgstr "应用/软件"

#: oauth2_provider/templates/oauth2_provider/application_list.html:6
msgid "Your applications"
msgstr "您在%s的订单"

#: oauth2_provider/templates/oauth2_provider/application_list.html:16
msgid "No applications defined"
msgstr "未定义"

#: oauth2_provider/templates/oauth2_provider/application_list.html:16
msgid "Click here"
msgstr "点这里"

#: oauth2_provider/templates/oauth2_provider/application_list.html:16
msgid "if you want to register a new one"
msgstr "注册新用户"

#: oauth2_provider/templates/oauth2_provider/application_registration_form.html:5
msgid "Register a new application"
msgstr "注册新应用"

#: oauth2_provider/templates/oauth2_provider/authorize.html:8
msgid "Authorize"
msgstr "授权"

#: oauth2_provider/templates/oauth2_provider/authorize.html:17
msgid "Application requires following permissions"
msgstr "应用将获得如下授权"

#: oauth2_provider/templates/oauth2_provider/authorized-token-delete.html:6
msgid "Are you sure you want to delete this token?"
msgstr "您确定要删除这个会话吗?"

#: oauth2_provider/templates/oauth2_provider/authorized-tokens.html:6
msgid "Tokens"
msgstr "会话"

#: oauth2_provider/templates/oauth2_provider/authorized-tokens.html:19
msgid "There are no authorized tokens yet."
msgstr "没有已认证会话."

#: oauth2_provider/validators.py:23
msgid "Enter a valid URL."
msgstr "请输入正确的URL."

#~ msgid "Redirect uris"
#~ msgstr "重定向URI"
67 changes: 42 additions & 25 deletions oauth2_provider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AbstractApplication(models.Model):

id = models.BigAutoField(primary_key=True)
client_id = models.CharField(
max_length=100, unique=True, default=generate_client_id, db_index=True
_("Client ID"), max_length=100, unique=True, default=generate_client_id, db_index=True
)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
Expand All @@ -69,17 +69,20 @@ class AbstractApplication(models.Model):

help_text = _("Allowed URIs list, space separated")
redirect_uris = models.TextField(
blank=True, help_text=help_text, validators=[validate_uris]
_("Redirect URIs"), blank=True, help_text=help_text, validators=[validate_uris]
)
client_type = models.CharField(max_length=32, choices=CLIENT_TYPES)
client_type = models.CharField(
_("Client type"), max_length=32, choices=CLIENT_TYPES
)
help_text = _("Ref: https://tools.ietf.org/html/rfc6749#page-9")
authorization_grant_type = models.CharField(
max_length=32, choices=GRANT_TYPES
_("Authorization grant type"), help_text=help_text, max_length=32, choices=GRANT_TYPES
)
client_secret = models.CharField(
max_length=255, blank=True, default=generate_client_secret, db_index=True
_("Client secret"), max_length=255, blank=True, default=generate_client_secret, db_index=True
)
name = models.CharField(max_length=255, blank=True)
skip_authorization = models.BooleanField(default=False)
name = models.CharField(_("Name"), max_length=255, blank=True)
skip_authorization = models.BooleanField(_("Skip authorization"), default=False)

class Meta:
abstract = True
Expand Down Expand Up @@ -151,6 +154,8 @@ def is_usable(self, request):
class Application(AbstractApplication):
class Meta(AbstractApplication.Meta):
swappable = "OAUTH2_PROVIDER_APPLICATION_MODEL"
verbose_name = _('Application')
verbose_name_plural = _('Applications')


@python_2_unicode_compatible
Expand All @@ -169,18 +174,20 @@ class AbstractGrant(models.Model):
* :attr:`redirect_uri` Self explained
* :attr:`scope` Required scopes, optional
"""
id = models.BigAutoField(primary_key=True)
id = models.BigAutoField(_("ID"), primary_key=True)
user = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE,
related_name="%(app_label)s_%(class)s"
related_name="%(app_label)s_%(class)s",
verbose_name=_("User"),
)
code = models.CharField(max_length=255, unique=True) # code comes from oauthlib
code = models.CharField(_("Code"), max_length=255, unique=True) # code comes from oauthlib
application = models.ForeignKey(
oauth2_settings.APPLICATION_MODEL, on_delete=models.CASCADE
oauth2_settings.APPLICATION_MODEL, on_delete=models.CASCADE,
verbose_name=_("Application"),
)
expires = models.DateTimeField()
redirect_uri = models.CharField(max_length=255)
scope = models.TextField(blank=True)
expires = models.DateTimeField(_("Expires"))
redirect_uri = models.CharField(_("Redirect URI"), max_length=255)
scope = models.TextField(_("Scope"), blank=True)

def is_expired(self):
"""
Expand All @@ -204,6 +211,8 @@ class Meta:
class Grant(AbstractGrant):
class Meta(AbstractGrant.Meta):
swappable = "OAUTH2_PROVIDER_GRANT_MODEL"
verbose_name = _('Grant')
verbose_name_plural = _('Grants')


@python_2_unicode_compatible
Expand All @@ -220,17 +229,18 @@ class AbstractAccessToken(models.Model):
* :attr:`expires` Date and time of token expiration, in DateTime format
* :attr:`scope` Allowed scopes
"""
id = models.BigAutoField(primary_key=True)
id = models.BigAutoField(_('ID'), primary_key=True)
user = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True,
related_name="%(app_label)s_%(class)s"
related_name="%(app_label)s_%(class)s", verbose_name=_("User"),
)
token = models.CharField(max_length=255, unique=True, )
token = models.CharField(_('Token'), max_length=255, unique=True, )
application = models.ForeignKey(
oauth2_settings.APPLICATION_MODEL, on_delete=models.CASCADE, blank=True, null=True,
oauth2_settings.APPLICATION_MODEL, verbose_name=_("Application"),
on_delete=models.CASCADE, blank=True, null=True,
)
expires = models.DateTimeField()
scope = models.TextField(blank=True)
expires = models.DateTimeField(_('Expires'), )
scope = models.TextField(_('Scope'), blank=True)

def is_valid(self, scopes=None):
"""
Expand Down Expand Up @@ -289,6 +299,8 @@ class Meta:
class AccessToken(AbstractAccessToken):
class Meta(AbstractAccessToken.Meta):
swappable = "OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL"
verbose_name = _('Access token')
verbose_name_plural = _('Access tokens')


@python_2_unicode_compatible
Expand All @@ -305,17 +317,20 @@ class AbstractRefreshToken(models.Model):
* :attr:`access_token` AccessToken instance this refresh token is
bounded to
"""
id = models.BigAutoField(primary_key=True)
id = models.BigAutoField(_('ID'), primary_key=True)
user = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE,
related_name="%(app_label)s_%(class)s"
related_name="%(app_label)s_%(class)s",
verbose_name=_("User"),
)
token = models.CharField(max_length=255, unique=True)
token = models.CharField(_('Token'), max_length=255, unique=True)
application = models.ForeignKey(
oauth2_settings.APPLICATION_MODEL, on_delete=models.CASCADE)
oauth2_settings.APPLICATION_MODEL, on_delete=models.CASCADE,
verbose_name=_("Application"), )
access_token = models.OneToOneField(
oauth2_settings.ACCESS_TOKEN_MODEL, on_delete=models.CASCADE,
related_name="refresh_token"
related_name="refresh_token",
verbose_name=_("Access Token"),
)

def revoke(self):
Expand All @@ -336,6 +351,8 @@ class Meta:
class RefreshToken(AbstractRefreshToken):
class Meta(AbstractRefreshToken.Meta):
swappable = "OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL"
verbose_name = _('Refresh token')
verbose_name_plural = _('Refresh tokens')


def get_application_model():
Expand Down