diff --git a/bedrock/cms/management/commands/run_smartling_sync.py b/bedrock/cms/management/commands/run_smartling_sync.py index 9f8b339cf65..15beb235e04 100644 --- a/bedrock/cms/management/commands/run_smartling_sync.py +++ b/bedrock/cms/management/commands/run_smartling_sync.py @@ -29,6 +29,6 @@ def handle(self, *args, **kwargs): ) if SMARTLING_SYNC_SNITCH_URL: requests.get(SMARTLING_SYNC_SNITCH_URL) - sys.stdout.write("Snitch pinged\n") + sys.stdout.write("Snitch pinged\n") except Exception as ex: sys.stderr.write(f"\nsync_smartling did not execute successfully: {ex}\n") diff --git a/bedrock/cms/models/base.py b/bedrock/cms/models/base.py index 979a67d3d73..de28b537544 100644 --- a/bedrock/cms/models/base.py +++ b/bedrock/cms/models/base.py @@ -8,6 +8,7 @@ from django.views.decorators.cache import never_cache from wagtail.models import Page as WagtailBasePage +from wagtail_localize.fields import SynchronizedField from lib import l10n_utils @@ -32,6 +33,13 @@ class AbstractBedrockCMSPage(WagtailBasePage): `serve_password_required_response` method, via the @method_decorator above """ + # Make the `slug` field 'synchronised', so it automatically gets copied over to + # every localized variant of the page and shouldn't get sent for translation. + # See https://wagtail-localize.org/stable/how-to/field-configuration/ + override_translatable_fields = [ + SynchronizedField("slug"), + ] + class Meta: abstract = True diff --git a/bedrock/settings/base.py b/bedrock/settings/base.py index 7884f155b30..4b01006f4b9 100644 --- a/bedrock/settings/base.py +++ b/bedrock/settings/base.py @@ -2101,14 +2101,21 @@ def before_send(event, hint): def lazy_wagtail_langs(): enabled_wagtail_langs = [ - ("en-US", "English"), - # TODO: expand to other locales supported by our translation vendor - # ("de", "Deutsch"), - ("fr", "Français"), - # ("es", "Español"), - # ("es", "Español mexicano"), - # ("it", "Italiano"), - # more to come + # Notes: + # 1) The labels are only used internally so can be in English + # 2) These are the Bedrock-side lang codes. They are mapped to + # Smartling-specific ones in the WAGTAIL_LOCALIZE_SMARTLING settings, below + ("en-US", "English (US)"), + ("de", "German"), + ("fr", "French"), + ("es-ES", "Spanish (Spain)"), + ("it", "Italian"), + ("ja", "Japanese"), + ("nl", "Dutch (Netherlands)"), + ("pl", "Polish"), + ("pt-BR", "Portuguese (Brazil)"), + ("ru", "Russian"), + ("zh-CN", "Chinese (China-Simplified)"), ] enabled_language_codes = [x[0] for x in LANGUAGES] retval = [wagtail_lang for wagtail_lang in enabled_wagtail_langs if wagtail_lang[0] in enabled_language_codes] @@ -2144,6 +2151,16 @@ def lazy_wagtail_langs(): default="5", parser=float, ), # Timeout in seconds for requests to the Smartling API + "LOCALE_TO_SMARTLING_LOCALE": { + "de": "de-DE", + "fr": "fr-FR", + "it": "it-IT", + "ja": "ja-JP", + "nl": "nl-NL", + "pl": "pl-PL", + "ru": "ru-RU", + }, + "REFORMAT_LANGUAGE_CODES": False, # don't force language codes into Django's all-lowercase pattern } # Custom settings, not a core Wagtail ones, to scope out RichText options