Localization synching and creating management commands#6866
Localization synching and creating management commands#6866TheoChevalier merged 2 commits intowagtail-localize-2021from
Conversation
TheoChevalier
left a comment
There was a problem hiding this comment.
I like the idea, and it seem to work pretty well, I’ve just found an issue with hyphenated locale codes, they are wrongfully flagged as invalid
I’m also wondering whether we could (later/in a follow up) run these commands automatically when deploying the app? We will always want to match the locale list in the settings anyway, so if it fixes the front end timeout at the same time, why not?
One concern would be the additional time it’s taking to deploy the app, but hopefully it wouldn’t do anything until we actually add a new locale to the settings file?
|
Oh good catch @TheoChevalier ! I'll test out the Frissian and Portoguese locales. And yes, that would be a great idea to throw these commands into our deployment process. I actually don't know how to do that, but I suspect it's no different than the other commands we have running. The sync command might need to take an argument though, but that's easy to adjust in the future if we go this route. I'll work on the immediate fixes right away. Thanks again! |
TheoChevalier
left a comment
There was a problem hiding this comment.
Looking good, thanks!
* Localization synching and creating management commands * Don't lower strings; requires exact string matching now
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
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
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 Moved consts inside of functions to prevent runtime/migration conflicts (#7215) * Moved consts inside of functions to prevent runtime/migration conflicts * That's better
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 Moved consts inside of functions to prevent runtime/migration conflicts (#7215) * Moved consts inside of functions to prevent runtime/migration conflicts * That's better rebase and flakefix

Closes #6869
Two new management commands.
1. create_locales
python manage.py create_localeswill loop through all our language settings and create new locales if they don't exist. This can be run multiple times.2. sync_locale
python manage.py sync_localewill list all your available language codes and ask you to type one in. It will skip English because we shouldn't sync English with English (and the English Locale should exist for us already)It will then verify the language_code you entered is in our settings.
It'll get_or_create the source locale and the target locale objects.
Then it'll create a LocalSynchonization object using those locals, or find the one that already exists.
Lastly, it'll run
.sync_trees()to sync a locale against English (it always uses English as the source locale).This should be safe to run multiple times too.
Testing steps
python manage.py create_localespython manage.py sync_locale. You'll need to specify a specific language from the list it will give you.