From ad2a87d317af1e012c69f1e55e016db40053513d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 27 Feb 2021 13:43:17 -0800 Subject: [PATCH 01/11] First pass at internationalization and localization --- bookwyrm/locale/en/LC_MESSAGES/django.po | 69 +++++++++++++++++++ bookwyrm/settings.py | 5 +- bookwyrm/templates/discover/icons.html | 21 ------ .../templates/discover/landing_layout.html | 50 +++++++------- bookwyrm/templates/user/user_layout.html | 28 ++------ bookwyrm/templates/user/user_preview.html | 20 ++++++ 6 files changed, 127 insertions(+), 66 deletions(-) create mode 100644 bookwyrm/locale/en/LC_MESSAGES/django.po delete mode 100644 bookwyrm/templates/discover/icons.html create mode 100644 bookwyrm/templates/user/user_preview.html diff --git a/bookwyrm/locale/en/LC_MESSAGES/django.po b/bookwyrm/locale/en/LC_MESSAGES/django.po new file mode 100644 index 00000000..dac50a1d --- /dev/null +++ b/bookwyrm/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,69 @@ +# 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 , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-02-27 13:41-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: bookwyrm/templates/discover/landing_layout.html:15 +msgid "Decentralized" +msgstr "" + +#: bookwyrm/templates/discover/landing_layout.html:21 +msgid "Friendly" +msgstr "" + +#: bookwyrm/templates/discover/landing_layout.html:27 +msgid "Anti-Corporate" +msgstr "" + +#: bookwyrm/templates/discover/landing_layout.html:42 +#, python-format +msgid "Join %(name)s" +msgstr "" + +#: bookwyrm/templates/discover/landing_layout.html:47 +msgid "This instance is closed" +msgstr "" + +#: bookwyrm/templates/discover/landing_layout.html:53 +msgid "Your Account" +msgstr "" + +#: bookwyrm/templates/user/user_layout.html:30 +msgid "Follow Requests" +msgstr "" + +#: bookwyrm/templates/user/user_layout.html:48 +msgid "Activity" +msgstr "" + +#: bookwyrm/templates/user/user_layout.html:54 +msgid "Reading Goal" +msgstr "" + +#: bookwyrm/templates/user/user_layout.html:60 +msgid "Lists" +msgstr "" + +#: bookwyrm/templates/user/user_layout.html:66 +msgid "Shelves" +msgstr "" + +#: bookwyrm/templates/user/user_preview.html:13 +#, python-format +msgid "Joined %(date)s" +msgstr "" diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 46c38b5a..2a2bf427 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -1,9 +1,10 @@ ''' bookwyrm settings and configuration ''' import os - from environs import Env import requests +from django.utils.translation import gettext_lazy as _ + env = Env() DOMAIN = env('DOMAIN') @@ -27,6 +28,7 @@ EMAIL_USE_TLS = env('EMAIL_USE_TLS', True) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +LOCALE_PATHS = [os.path.join(BASE_DIR, 'locale'),] # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ @@ -58,6 +60,7 @@ INSTALLED_APPS = [ 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', diff --git a/bookwyrm/templates/discover/icons.html b/bookwyrm/templates/discover/icons.html deleted file mode 100644 index a4086282..00000000 --- a/bookwyrm/templates/discover/icons.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
-

-

Decentralized

-
-
-
-
-

-

Friendly

-
-
-
-
-

-

Anti-Corporate

-
-
-
- diff --git a/bookwyrm/templates/discover/landing_layout.html b/bookwyrm/templates/discover/landing_layout.html index 2123ee98..f6b86009 100644 --- a/bookwyrm/templates/discover/landing_layout.html +++ b/bookwyrm/templates/discover/landing_layout.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load humanize %} +{% load i18n %} {% load bookwyrm_tags %} {% block content %} @@ -8,7 +8,26 @@

{{ site.instance_tagline }}

-{% include 'discover/icons.html' %} +
+
+
+

+

{% trans "Decentralized" %}

+
+
+
+
+

+

{% trans "Friendly" %}

+
+
+
+
+

+

{% trans "Anti-Corporate" %}

+
+
+
@@ -20,37 +39,22 @@ {% if not request.user.is_authenticated %}
{% if site.allow_registration %} -

Join {{ site.name }}

+

{% blocktrans with name=site.name %}Join {{ name }}{% endblocktrans %}

{% include 'snippets/register_form.html' %}
{% else %} -

This instance is closed

+

{% trans "This instance is closed" %}

{{ site.registration_closed_text | safe}}

{% endif %}
{% else %}
-

Your Account

-
- -
-

{% if user.name %}{{ user.name }}{% else %}{{ user.localname }}{% endif %}

-

{{ user.username }}

-

Joined {{ user.created_date | naturaltime }}

-

- {{ user.followers.count }} follower{{ user.followers.count | pluralize }}, - {{ user.following.count }} following -

-
-
+

{% trans "Your Account" %}

+ {% include 'user/user_preview.html' with user=request.user %}
- {% if user.summary %} - {{ user.summary | to_markdown | safe }} + {% if request.user.summary %} + {{ request.user.summary | to_markdown | safe }} {% endif %}
diff --git a/bookwyrm/templates/user/user_layout.html b/bookwyrm/templates/user/user_layout.html index f48dfd38..c8eea412 100644 --- a/bookwyrm/templates/user/user_layout.html +++ b/bookwyrm/templates/user/user_layout.html @@ -1,4 +1,5 @@ {% extends 'layout.html' %} +{% load i18n %} {% load humanize %} {% load bookwyrm_tags %} @@ -11,22 +12,7 @@
-
- -
-

{% if user.name %}{{ user.name }}{% else %}{{ user.localname }}{% endif %}

-

{{ user.username }}

-

Joined {{ user.created_date | naturaltime }}

-

- {{ user.followers.count }} follower{{ user.followers.count | pluralize }}, - {{ user.following.count }} following -

-
-
+ {% include 'user/user_preview.html' with user=user %}
@@ -41,7 +27,7 @@ {% if is_self and user.follower_requests.all %}
@@ -98,11 +99,11 @@
{% csrf_token %}

- +

- + {% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="add-description" controls_uid=book.id hide_inactive=True %}
@@ -134,20 +135,20 @@ {% if request.user.is_authenticated %}
-

Your reading activity

+

{% trans "Your reading activity" %}

{% include 'snippets/toggle/open_button.html' with text="Add read dates" icon="plus" class="is-small" controls_text="add-readthrough" %}
{% if not readthroughs.exists %} -

You don't have any reading activity for this book.

+

{% trans "You don't have any reading activity for this book." %}

{% endif %}