mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
Add more translation hooks
This commit is contained in:
parent
c719b74a8e
commit
722b2d7a3d
@ -1,24 +1,25 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
from pytz import common_timezones
|
from pytz import common_timezones
|
||||||
from .models import Theme, Preference
|
from .models import Theme, Preference
|
||||||
|
|
||||||
|
|
||||||
PRIVACY_CHOICES = (('public', 'Public'),
|
PRIVACY_CHOICES = (('public', _('Public')),
|
||||||
('unlisted', 'Unlisted'),
|
('unlisted', _('Unlisted')),
|
||||||
('private', 'Private'),
|
('private', _('Private')),
|
||||||
('direct', 'Direct'))
|
('direct', _('Direct')))
|
||||||
|
|
||||||
timezones = [ (tz, tz) for tz in common_timezones]
|
timezones = [ (tz, tz) for tz in common_timezones]
|
||||||
|
|
||||||
class LoginForm(forms.Form):
|
class LoginForm(forms.Form):
|
||||||
instance = forms.CharField(label="Instance",
|
instance = forms.CharField(label=_("Instance"),
|
||||||
max_length=256)
|
max_length=256)
|
||||||
email = forms.EmailField(label="Email")
|
email = forms.EmailField(label=_("Email"))
|
||||||
password = forms.CharField(widget=forms.PasswordInput())
|
password = forms.CharField(widget=forms.PasswordInput())
|
||||||
|
|
||||||
class OAuthLoginForm(forms.Form):
|
class OAuthLoginForm(forms.Form):
|
||||||
instance = forms.CharField(label="Instance",
|
instance = forms.CharField(label=_("Instance"),
|
||||||
max_length=256)
|
max_length=256)
|
||||||
|
|
||||||
class PreferencesForm(forms.ModelForm):
|
class PreferencesForm(forms.ModelForm):
|
||||||
@ -31,24 +32,24 @@ class PostForm(forms.Form):
|
|||||||
"""def status_post(self, status, in_reply_to_id=None, media_ids=None,
|
"""def status_post(self, status, in_reply_to_id=None, media_ids=None,
|
||||||
sensitive=False, visibility=None, spoiler_text=None):"""
|
sensitive=False, visibility=None, spoiler_text=None):"""
|
||||||
status = forms.CharField(label="Toot", widget=forms.Textarea)
|
status = forms.CharField(label="Toot", widget=forms.Textarea)
|
||||||
visibility = forms.ChoiceField(label="Toot visibility", choices=PRIVACY_CHOICES,
|
visibility = forms.ChoiceField(label=_("Toot visibility"), choices=PRIVACY_CHOICES,
|
||||||
required=False)
|
required=False)
|
||||||
spoiler_text = forms.CharField(label="CW or Subject",
|
spoiler_text = forms.CharField(label=_("CW or Subject"),
|
||||||
required=False)
|
required=False)
|
||||||
media_file_1 = forms.FileField(label = "Media 1",
|
media_file_1 = forms.FileField(label = _("Media 1"),
|
||||||
required=False)
|
required=False)
|
||||||
media_text_1 = forms.CharField(label="Describe media 1.",
|
media_text_1 = forms.CharField(label=_("Describe media 1."),
|
||||||
required=False)
|
required=False)
|
||||||
media_file_2 = forms.FileField(label = "Media 2",
|
media_file_2 = forms.FileField(label = _("Media 2"),
|
||||||
required=False)
|
required=False)
|
||||||
media_text_2 = forms.CharField(label="Describe media 2.",
|
media_text_2 = forms.CharField(label=_("Describe media 2."),
|
||||||
required=False)
|
required=False)
|
||||||
media_file_3 = forms.FileField(label = "Media 3",
|
media_file_3 = forms.FileField(label = _("Media 3"),
|
||||||
required=False)
|
required=False)
|
||||||
media_text_3 = forms.CharField(label="Describe media 3.",
|
media_text_3 = forms.CharField(label=_("Describe media 3."),
|
||||||
required=False)
|
required=False)
|
||||||
media_file_4 = forms.FileField(label = "Media 4",
|
media_file_4 = forms.FileField(label = _("Media 4"),
|
||||||
required=False)
|
required=False)
|
||||||
media_text_4 = forms.CharField(label="Describe media 4.",
|
media_text_4 = forms.CharField(label=_("Describe media 4."),
|
||||||
required=False)
|
required=False)
|
||||||
media_sensitive = forms.BooleanField(label="Sensitive media?", required=False)
|
media_sensitive = forms.BooleanField(label=_("Sensitive media?", required=False))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from django.utils.timezone import get_default_timezone, get_current_timezone, localtime
|
from django.utils.timezone import get_default_timezone, get_current_timezone, localtime
|
||||||
from django.utils.timezone import now as django_now
|
from django.utils.timezone import now as django_now
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
from django import template
|
from django import template
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
@ -24,6 +25,8 @@ def humane_time(arg):
|
|||||||
|
|
||||||
It is not safe to use on future times.
|
It is not safe to use on future times.
|
||||||
|
|
||||||
|
FIXME: work out how best to make these strings translatable
|
||||||
|
|
||||||
'''
|
'''
|
||||||
now = django_now()
|
now = django_now()
|
||||||
arg = localtime(arg)
|
arg = localtime(arg)
|
||||||
@ -52,14 +55,14 @@ def time_of_day(hour):
|
|||||||
This is very english-centric and probably not translatable.
|
This is very english-centric and probably not translatable.
|
||||||
"""
|
"""
|
||||||
if hour < 3:
|
if hour < 3:
|
||||||
return "wee hours"
|
return _("wee hours")
|
||||||
elif hour < 6:
|
elif hour < 6:
|
||||||
return "early morning"
|
return _("early morning")
|
||||||
elif hour < 12:
|
elif hour < 12:
|
||||||
return "morning"
|
return _("morning")
|
||||||
elif hour < 18:
|
elif hour < 18:
|
||||||
return "afternoon"
|
return _("afternoon")
|
||||||
elif hour < 22:
|
elif hour < 22:
|
||||||
return "evening"
|
return _("evening")
|
||||||
else:
|
else:
|
||||||
return "night"
|
return _("night")
|
||||||
|
@ -2,6 +2,7 @@ from django import template
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
from pdb import set_trace
|
from pdb import set_trace
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
@ -5,7 +5,7 @@ from django.urls import reverse
|
|||||||
from django.views.decorators.cache import never_cache, cache_page
|
from django.views.decorators.cache import never_cache, cache_page
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.core.files.uploadhandler import TemporaryFileUploadHandler
|
from django.core.files.uploadhandler import TemporaryFileUploadHandler
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext as _
|
||||||
from brutaldon.forms import LoginForm, OAuthLoginForm, PreferencesForm, PostForm
|
from brutaldon.forms import LoginForm, OAuthLoginForm, PreferencesForm, PostForm
|
||||||
from brutaldon.models import Client, Account, Preference, Theme
|
from brutaldon.models import Client, Account, Preference, Theme
|
||||||
from mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonAPIError
|
from mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonAPIError
|
||||||
|
Loading…
Reference in New Issue
Block a user