Skip to content

Commit

Permalink
rebase fixes
Browse files Browse the repository at this point in the history
rebase fixes

fix the language picker by making sure 'next' is the right URL (#6780)

allow authenticated users to hit the wagtail localize endpoints (#6778)

* allow authenticated users to hit the wagtail localize endpoints

Updated migrations (#6795)

Enable pontoon integration for wagtail-localize (#6794)

* add wagtail_localize_git

* heroku ssh generation script

rebase fixes

Update settings.py

Update settings.py

Better 500 logging (#6836)

* allow forced logging of stack traces to console for 500 errors

* Update urls.py

* Update urls.py

blog fixes for the localize branch (#6840)

* blog fixes for the localize branch

* import

* oh flake8, you joker

Show locale in admin title (until a proper solution is released in Wagtail Core) (#6843)

rebase fixes

Redirect /pt to /pt-BR (#6854)

only create the locale, rather than cloning all pages, when creating a synced locale (#6853)

Campaign page translation fix (#6855)

Permanent pt-BR redirect (#6856)

Added localized URLs for every page through the FoundationMetadataPageMixin (#6849)

* Added localized URLs for every page through the FoundationMetadataPageMixin

* Cache sitemap

* Localized sitemaps

Make tests pass (#6872)

* Flake8

* Sitemap.xml test fix

Localization synching and creating management commands (#6866)

* Localization synching and creating management commands

* Don't lower strings; requires exact string matching now

Allow banner pages to be further localized (#6876)

Marked fields are sync or translatable (#6875)

* Marked fields are sync or translatable

* Oop

* Flake8

* Add petition synchronized fields

Co-authored-by: Théo Chevalier <theo.chevalier11@gmail.com>

Fix makemessages command for Django >= 3.1 (#6907)

Use localized wagtail-footnotes (#6913)

Localize missing fields for YT pages (#6923)

Translate article page titles (#6924)

Translate What You Can Do title (#6925)

address all acceptance criteria (#6930)

rebase fixes

update all homepage fragments to pull from localized content (#7067)

* update all homepage fragments to pull from localized content

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/news_you_can_use.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/spotlight_posts.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

Fix all the localized properties (#7068)

* update all homepage fragments to pull from localized content

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/news_you_can_use.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/spotlight_posts.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

* rest of the localized updates... I think

* forgot to save a file

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

Translatable PNI fields (#7075)

Translate 3 more PNI fields (#7081)

Localized limks in Related products section (#7125)

Localize PNI categories & products (#7124)

Translate Host controls field (#7123)

regenerating requirements.txt

.

migration renames

migration fixes

Override translatable fields for PNI home (#7146)

Localize title field on Default pages (#7147)

Bump wagtail-localize to 1.0rc3 (#7176)

Category snippet localization (#7183)

* category-snippet-localization

* well then

* Update network-api/networkapi/wagtailpages/templatetags/localization.py

* update based on Karl's advice

* some WIP removals

* show correct categories on product pages, and relocalize urls to point to use the correct locale

* let's not cache-clear

Restore product filtering per language (#7208)

Fix category fallthrough (#7212)

* make missing categories fall through to the EN version

* small docs update

* ???

* oops

* data-name should stay English
  • Loading branch information
Pomax committed Aug 10, 2021
1 parent cb7b15c commit 373f8f9
Show file tree
Hide file tree
Showing 94 changed files with 5,262 additions and 313 deletions.
23 changes: 23 additions & 0 deletions .profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copy SSH private key to file, if set
# This is used for talking to GitHub over an SSH connection
if [ $WAGTAIL_LOCALIZE_PRIVATE_KEY ]; then
echo "Generating SSH config"
SSH_DIR=/app/.ssh

mkdir -p $SSH_DIR
chmod 700 $SSH_DIR

echo $WAGTAIL_LOCALIZE_PRIVATE_KEY | base64 --decode > $SSH_DIR/id_rsa

chmod 400 $SSH_DIR/id_rsa

cat << EOF > $SSH_DIR/config
StrictHostKeyChecking no
EOF

chmod 600 $SSH_DIR/config

echo "Done!"
fi
3 changes: 0 additions & 3 deletions docs/local_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ To get a list of invoke commands available, run `invoke -l`:
```
catch-up (catchup, docker-catchup) Rebuild images, install dependencies, and apply migrations
compilemessages (docker-compilemessages) Compile the latest translations
l10n-sync (docker-l10n-sync) Sync localizable fields in the database
l10n-update (docker-l10n-update) Update localizable field data (copies from original unlocalized to
default localized field)
makemessages (docker-makemessages) Extract all template messages in .po files for localization
makemigrations (docker-makemigrations) Creates new migration(s) for apps
manage (docker-manage) Shorthand to manage.py. inv docker-manage "[COMMAND] [ARG]"
Expand Down
2 changes: 1 addition & 1 deletion docs/stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If you are defining a new page class for the site, make sure it inherits both th

#### localization

We use [wagtail-modeltranslations](https://github.com/infoportugal/wagtail-modeltranslation) for CMS content localization. Please see its documentation for more information.
We use [wagtail-localize](https://wagtail-localize.org/) for CMS content localization. Please see its documentation for more information.

#### A/B testing

Expand Down
12 changes: 10 additions & 2 deletions network-api/networkapi/campaign/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
from networkapi.wagtailpages.models import Petition, Signup


def process_lang_code(lang):
# Salesforce expects "pt" instead of "pt-BR".
# See https://github.com/mozilla/foundation.mozilla.org/issues/5993
if lang == 'pt-BR':
return 'pt'
return lang


class SQSProxy:
"""
We use a proxy class to make sure that code that
Expand Down Expand Up @@ -128,7 +136,7 @@ def signup_submission(request, signup):
"format": "html",
"source_url": source,
"newsletters": signup.newsletter,
"lang": rq.get('lang', 'en'),
"lang": process_lang_code(rq.get('lang', 'en')),
"country": rq.get('country', ''),
# Empty string instead of None due to Basket issues
"first_name": rq.get('givenNames', ''),
Expand Down Expand Up @@ -178,7 +186,7 @@ def petition_submission(request, petition):
"email": request.data['email'],
"email_subscription": request.data['newsletterSignup'],
"source_url": request.data['source'],
"lang": request.data['lang'],
"lang": process_lang_code(request.data['lang']),
}

if petition:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.11 on 2021-05-31 17:35

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('highlights', '0004_remove_highlight_image'),
]

operations = [
migrations.AddField(
model_name='highlight',
name='locale',
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale'),
),
migrations.AddField(
model_name='highlight',
name='translation_key',
field=models.UUIDField(editable=False, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 3.1.11 on 2021-05-31 17:18

from django.db import migrations
from wagtail.core.models import BootstrapTranslatableModel


class Migration(migrations.Migration):

dependencies = [
('highlights', '0005_auto_20210531_1735'),
]

operations = [
BootstrapTranslatableModel('highlights.Highlight'),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 3.1.11 on 2021-05-31 18:02

from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('highlights', '0006_bootstrap_migration'),
]

operations = [
migrations.AlterField(
model_name='highlight',
name='locale',
field=models.ForeignKey(default=1, editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale'),
preserve_default=False,
),
migrations.AlterField(
model_name='highlight',
name='translation_key',
field=models.UUIDField(default=uuid.uuid4, editable=False),
),
migrations.AlterUniqueTogether(
name='highlight',
unique_together={('translation_key', 'locale')},
),
]
14 changes: 12 additions & 2 deletions network-api/networkapi/highlights/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
from adminsortable.models import SortableMixin
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.fields import RichTextField
from wagtail.core.models import TranslatableMixin
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.snippets.models import register_snippet

from wagtail_localize.fields import TranslatableField

from networkapi.utility.images import get_image_upload_path


Expand All @@ -33,7 +36,7 @@ def published(self):


@register_snippet
class Highlight(SortableMixin):
class Highlight(TranslatableMixin, SortableMixin):
"""
An data type to highlight things like pulse
projects, custom pages, etc
Expand Down Expand Up @@ -97,9 +100,16 @@ class Highlight(SortableMixin):
FieldPanel("expires"),
]

translatable_fields = [
TranslatableField('title'),
TranslatableField('description'),
TranslatableField('link_label'),
TranslatableField('footer'),
]

objects = HighlightQuerySet.as_manager()

class Meta:
class Meta(TranslatableMixin.Meta):
verbose_name_plural = 'highlights'
ordering = ('order',)

Expand Down
13 changes: 13 additions & 0 deletions network-api/networkapi/management/commands/create_locales.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from wagtail.core.models import Locale


class Command(BaseCommand):
help = 'Look for and create locales if they do not exist. This can be run multiple times if needed.'

def handle(self, *args, **options):
for language_code, name in settings.WAGTAIL_CONTENT_LANGUAGES:
locale, created = Locale.objects.get_or_create(language_code=language_code)
if created:
print(f"Create new locale: {name}")
38 changes: 38 additions & 0 deletions network-api/networkapi/management/commands/sync_locale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from wagtail.core.models import Locale
from wagtail_localize.models import LocaleSynchronization


class Command(BaseCommand):
help = 'Sync pages with original English pages'

def handle(self, *args, **options):
print("Select a language code to sync with English. ie: de")

for language_code, name in settings.WAGTAIL_CONTENT_LANGUAGES:
if language_code != 'en':
print(f"{language_code} ({name})")

language_code = input("Language code: ")

# Confirm the language code is in the WAGTAIL_CONTENT_LANGUAGES
language_codes_dict = dict(settings.WAGTAIL_CONTENT_LANGUAGES)
if language_code not in language_codes_dict:
print("Invalid language code")
return

print("Getting both locales...")
english_locale, _ = Locale.objects.get_or_create(language_code='en')
locale, _ = Locale.objects.get_or_create(language_code=language_code)

print("Getting LocaleSynchronization object")
sync, created = LocaleSynchronization.objects.get_or_create(
locale=locale,
sync_from=english_locale,
)
if created:
print("\tNew LocaleSynchronization object created")

print(f"Syncing {locale} from {english_locale}")
sync.sync_trees()
Loading

0 comments on commit 373f8f9

Please sign in to comment.