From 46287c5c61b165fe987f659063e19816c67ff150 Mon Sep 17 00:00:00 2001 From: jonaspiterek Date: Fri, 1 Dec 2023 14:06:43 +0100 Subject: [PATCH 1/3] Add translation for Authors folder --- .../blog/locales/collective.blog.pot | 57 ++++++++++++----- .../locales/de/LC_MESSAGES/collective.blog.po | 59 +++++++++++++----- .../locales/en/LC_MESSAGES/collective.blog.po | 57 ++++++++++++----- .../locales/es/LC_MESSAGES/collective.blog.po | 57 ++++++++++++----- .../pt_BR/LC_MESSAGES/collective.blog.po | 62 +++++++++++++------ src/collective/blog/subscribers/blog.py | 11 +++- 6 files changed, 218 insertions(+), 85 deletions(-) diff --git a/src/collective/blog/locales/collective.blog.pot b/src/collective/blog/locales/collective.blog.pot index 9f70b1a..971b8de 100644 --- a/src/collective/blog/locales/collective.blog.pot +++ b/src/collective/blog/locales/collective.blog.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-11-13 14:04+0000\n" +"POT-Creation-Date: 2023-12-01 11:10+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -25,11 +25,19 @@ msgstr "" msgid "A Blog Post" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/subscribers/blog.py:11 +msgid "Authors" +msgstr "" + +#: collective/blog/interfaces.py:14 +msgid "Authors container inside the Blog" +msgstr "" + +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "Blog" msgstr "" @@ -37,24 +45,28 @@ msgstr "" msgid "Blog Author" msgstr "" +#: collective/blog/behaviors/configure.zcml:13 +msgid "Blog Behavior" +msgstr "" + #: collective/blog/profiles/default/types/Post.xml msgid "Blog Post" msgstr "" -#: collective/blog/behaviors/configure.zcml:13 -msgid "Blog Behavior" +#: collective/blog/controlpanel/controlpanel.py:16 +msgid "Blog Settings" msgstr "" #: collective/blog/profiles.zcml:13 -msgid "Blog: Install" +msgid "Blog Support for Plone" msgstr "" #: collective/blog/profiles.zcml:21 -msgid "Blog: Uninstall" +msgid "Blog Support for Plone: Uninstall" msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "Edit" msgstr "" @@ -63,6 +75,10 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" +#: collective/blog/subscribers/blog.py:12 +msgid "Our Authors" +msgstr "" + #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -72,42 +88,51 @@ msgid "Uninstall Blog setup." msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "View" msgstr "" +#: collective/blog/subscribers/blog.py:10 +msgid "authors" +msgstr "" + #. Default: "Contributors" -#: collective/blog/content/post.py:41 +#: collective/blog/content/post.py:42 msgid "contributors" msgstr "" #. Default: "Persons responsible for creating the content of this post. Please enter a list of user names, one per line. The principal creator should come first." -#: collective/blog/content/post.py:25 +#: collective/blog/content/post.py:26 msgid "help_authors" msgstr "" #. Default: "The names of people that have contributed to this item. Each contributor should be on a separate line." -#: collective/blog/content/post.py:42 +#: collective/blog/content/post.py:43 msgid "help_contributors" msgstr "" #. Default: "Copyright statement or other rights information on this item." -#: collective/blog/content/post.py:58 +#: collective/blog/content/post.py:59 msgid "help_copyrights" msgstr "" +#. Default: "Should we create the Authors container inside the Blog?" +#: collective/blog/interfaces.py:15 +msgid "help_enable_authors_folder" +msgstr "" + #. Default: "Authors" -#: collective/blog/content/post.py:24 +#: collective/blog/content/post.py:25 msgid "label_authors" msgstr "" #. Default: "Rights" -#: collective/blog/content/post.py:57 +#: collective/blog/content/post.py:58 msgid "label_copyrights" msgstr "" #. Default: "Metadata" -#: collective/blog/content/post.py:19 +#: collective/blog/content/post.py:20 msgid "label_schema_metadata" msgstr "" diff --git a/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po index 1e2ed51..6c5743d 100644 --- a/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-11-13 14:04+0000\n" +"POT-Creation-Date: 2023-12-01 11:01+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,17 +16,25 @@ msgstr "" #: collective/blog/profiles/default/types/Author.xml msgid "A Blog Author" -msgstr "" +msgstr " " #: collective/blog/profiles/default/types/Post.xml msgid "A Blog Post" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/subscribers/blog.py:11 +msgid "Authors" +msgstr "Autoren" + +#: collective/blog/interfaces.py:14 +msgid "Authors container inside the Blog" +msgstr "" + +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "Blog" msgstr "" @@ -34,24 +42,28 @@ msgstr "" msgid "Blog Author" msgstr "" +#: collective/blog/behaviors/configure.zcml:13 +msgid "Blog Behavior" +msgstr "" + #: collective/blog/profiles/default/types/Post.xml msgid "Blog Post" msgstr "" -#: collective/blog/behaviors/configure.zcml:13 -msgid "Blog Behavior" +#: collective/blog/controlpanel/controlpanel.py:16 +msgid "Blog Settings" msgstr "" #: collective/blog/profiles.zcml:13 -msgid "Blog: Install" +msgid "Blog Support for Plone" msgstr "" #: collective/blog/profiles.zcml:21 -msgid "Blog: Uninstall" +msgid "Blog Support for Plone: Uninstall" msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "Edit" msgstr "" @@ -60,6 +72,10 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" +#: collective/blog/subscribers/blog.py:12 +msgid "Our Authors" +msgstr "Unsere Autoren" + #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -69,42 +85,51 @@ msgid "Uninstall Blog setup." msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "View" msgstr "" +#: collective/blog/subscribers/blog.py:10 +msgid "authors" +msgstr "autoren" + #. Default: "Contributors" -#: collective/blog/content/post.py:41 +#: collective/blog/content/post.py:42 msgid "contributors" msgstr "" #. Default: "Persons responsible for creating the content of this post. Please enter a list of user names, one per line. The principal creator should come first." -#: collective/blog/content/post.py:25 +#: collective/blog/content/post.py:26 msgid "help_authors" msgstr "" #. Default: "The names of people that have contributed to this item. Each contributor should be on a separate line." -#: collective/blog/content/post.py:42 +#: collective/blog/content/post.py:43 msgid "help_contributors" msgstr "" #. Default: "Copyright statement or other rights information on this item." -#: collective/blog/content/post.py:58 +#: collective/blog/content/post.py:59 msgid "help_copyrights" msgstr "" +#. Default: "Should we create the Authors container inside the Blog?" +#: collective/blog/interfaces.py:15 +msgid "help_enable_authors_folder" +msgstr "" + #. Default: "Authors" -#: collective/blog/content/post.py:24 +#: collective/blog/content/post.py:25 msgid "label_authors" msgstr "" #. Default: "Rights" -#: collective/blog/content/post.py:57 +#: collective/blog/content/post.py:58 msgid "label_copyrights" msgstr "" #. Default: "Metadata" -#: collective/blog/content/post.py:19 +#: collective/blog/content/post.py:20 msgid "label_schema_metadata" msgstr "" diff --git a/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po index 5e8e170..957b3c3 100644 --- a/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-11-13 14:04+0000\n" +"POT-Creation-Date: 2023-12-01 11:10+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -22,11 +22,19 @@ msgstr "" msgid "A Blog Post" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/subscribers/blog.py:11 +msgid "Authors" +msgstr "" + +#: collective/blog/interfaces.py:14 +msgid "Authors container inside the Blog" +msgstr "" + +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "Blog" msgstr "" @@ -34,24 +42,28 @@ msgstr "" msgid "Blog Author" msgstr "" +#: collective/blog/behaviors/configure.zcml:13 +msgid "Blog Behavior" +msgstr "" + #: collective/blog/profiles/default/types/Post.xml msgid "Blog Post" msgstr "" -#: collective/blog/behaviors/configure.zcml:13 -msgid "Blog Behavior" +#: collective/blog/controlpanel/controlpanel.py:16 +msgid "Blog Settings" msgstr "" #: collective/blog/profiles.zcml:13 -msgid "Blog: Install" +msgid "Blog Support for Plone" msgstr "" #: collective/blog/profiles.zcml:21 -msgid "Blog: Uninstall" +msgid "Blog Support for Plone: Uninstall" msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "Edit" msgstr "" @@ -60,6 +72,10 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" +#: collective/blog/subscribers/blog.py:12 +msgid "Our Authors" +msgstr "" + #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -69,42 +85,51 @@ msgid "Uninstall Blog setup." msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "View" msgstr "" +#: collective/blog/subscribers/blog.py:10 +msgid "authors" +msgstr "" + #. Default: "Contributors" -#: collective/blog/content/post.py:41 +#: collective/blog/content/post.py:42 msgid "contributors" msgstr "" #. Default: "Persons responsible for creating the content of this post. Please enter a list of user names, one per line. The principal creator should come first." -#: collective/blog/content/post.py:25 +#: collective/blog/content/post.py:26 msgid "help_authors" msgstr "" #. Default: "The names of people that have contributed to this item. Each contributor should be on a separate line." -#: collective/blog/content/post.py:42 +#: collective/blog/content/post.py:43 msgid "help_contributors" msgstr "" #. Default: "Copyright statement or other rights information on this item." -#: collective/blog/content/post.py:58 +#: collective/blog/content/post.py:59 msgid "help_copyrights" msgstr "" +#. Default: "Should we create the Authors container inside the Blog?" +#: collective/blog/interfaces.py:15 +msgid "help_enable_authors_folder" +msgstr "" + #. Default: "Authors" -#: collective/blog/content/post.py:24 +#: collective/blog/content/post.py:25 msgid "label_authors" msgstr "" #. Default: "Rights" -#: collective/blog/content/post.py:57 +#: collective/blog/content/post.py:58 msgid "label_copyrights" msgstr "" #. Default: "Metadata" -#: collective/blog/content/post.py:19 +#: collective/blog/content/post.py:20 msgid "label_schema_metadata" msgstr "" diff --git a/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po index 1e2ed51..edb7af4 100644 --- a/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-11-13 14:04+0000\n" +"POT-Creation-Date: 2023-12-01 11:10+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -22,11 +22,19 @@ msgstr "" msgid "A Blog Post" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/subscribers/blog.py:11 +msgid "Authors" +msgstr "" + +#: collective/blog/interfaces.py:14 +msgid "Authors container inside the Blog" +msgstr "" + +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "Blog" msgstr "" @@ -34,24 +42,28 @@ msgstr "" msgid "Blog Author" msgstr "" +#: collective/blog/behaviors/configure.zcml:13 +msgid "Blog Behavior" +msgstr "" + #: collective/blog/profiles/default/types/Post.xml msgid "Blog Post" msgstr "" -#: collective/blog/behaviors/configure.zcml:13 -msgid "Blog Behavior" +#: collective/blog/controlpanel/controlpanel.py:16 +msgid "Blog Settings" msgstr "" #: collective/blog/profiles.zcml:13 -msgid "Blog: Install" +msgid "Blog Support for Plone" msgstr "" #: collective/blog/profiles.zcml:21 -msgid "Blog: Uninstall" +msgid "Blog Support for Plone: Uninstall" msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "Edit" msgstr "" @@ -60,6 +72,10 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" +#: collective/blog/subscribers/blog.py:12 +msgid "Our Authors" +msgstr "" + #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -69,42 +85,51 @@ msgid "Uninstall Blog setup." msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "View" msgstr "" +#: collective/blog/subscribers/blog.py:10 +msgid "authors" +msgstr "" + #. Default: "Contributors" -#: collective/blog/content/post.py:41 +#: collective/blog/content/post.py:42 msgid "contributors" msgstr "" #. Default: "Persons responsible for creating the content of this post. Please enter a list of user names, one per line. The principal creator should come first." -#: collective/blog/content/post.py:25 +#: collective/blog/content/post.py:26 msgid "help_authors" msgstr "" #. Default: "The names of people that have contributed to this item. Each contributor should be on a separate line." -#: collective/blog/content/post.py:42 +#: collective/blog/content/post.py:43 msgid "help_contributors" msgstr "" #. Default: "Copyright statement or other rights information on this item." -#: collective/blog/content/post.py:58 +#: collective/blog/content/post.py:59 msgid "help_copyrights" msgstr "" +#. Default: "Should we create the Authors container inside the Blog?" +#: collective/blog/interfaces.py:15 +msgid "help_enable_authors_folder" +msgstr "" + #. Default: "Authors" -#: collective/blog/content/post.py:24 +#: collective/blog/content/post.py:25 msgid "label_authors" msgstr "" #. Default: "Rights" -#: collective/blog/content/post.py:57 +#: collective/blog/content/post.py:58 msgid "label_copyrights" msgstr "" #. Default: "Metadata" -#: collective/blog/content/post.py:19 +#: collective/blog/content/post.py:20 msgid "label_schema_metadata" msgstr "" diff --git a/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po index a802697..758b536 100644 --- a/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-11-13 14:04+0000\n" +"POT-Creation-Date: 2023-12-01 11:10+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -22,11 +22,19 @@ msgstr "" msgid "A Blog Post" msgstr "Uma postagem no blog" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "A folderish content item representing a Blog" msgstr "Um tipo de conteúdo que representa um Blog" -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/subscribers/blog.py:11 +msgid "Authors" +msgstr "" + +#: collective/blog/interfaces.py:14 +msgid "Authors container inside the Blog" +msgstr "" + +#: collective/blog/profiles/default/types/BlogFolder.xml msgid "Blog" msgstr "Blog" @@ -34,23 +42,28 @@ msgstr "Blog" msgid "Blog Author" msgstr "" +#: collective/blog/behaviors/configure.zcml:13 +msgid "Blog Behavior" +msgstr "" + #: collective/blog/profiles/default/types/Post.xml msgid "Blog Post" +msgstr "" -#: collective/blog/behaviors/configure.zcml:13 -msgid "Blog Behavior" +#: collective/blog/controlpanel/controlpanel.py:16 +msgid "Blog Settings" msgstr "" #: collective/blog/profiles.zcml:13 -msgid "Blog: Install" -msgstr "Blog: Instalação" +msgid "Blog Support for Plone" +msgstr "" #: collective/blog/profiles.zcml:21 -msgid "Blog: Uninstall" -msgstr "Blog: Remover" +msgid "Blog Support for Plone: Uninstall" +msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "Edit" msgstr "Editar" @@ -59,6 +72,10 @@ msgstr "Editar" msgid "Implements a blog behavior on a content type" msgstr "" +#: collective/blog/subscribers/blog.py:12 +msgid "Our Authors" +msgstr "" + #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "Pacote que configura tipos de conteúdo para blogs" @@ -68,42 +85,51 @@ msgid "Uninstall Blog setup." msgstr "" #: collective/blog/profiles/default/types/Author.xml -#: collective/blog/profiles/default/types/Blog.xml +#: collective/blog/profiles/default/types/BlogFolder.xml #: collective/blog/profiles/default/types/Post.xml msgid "View" msgstr "Visão" +#: collective/blog/subscribers/blog.py:10 +msgid "authors" +msgstr "" + #. Default: "Contributors" -#: collective/blog/content/post.py:41 +#: collective/blog/content/post.py:42 msgid "contributors" msgstr "Contribuidores" #. Default: "Persons responsible for creating the content of this post. Please enter a list of user names, one per line. The principal creator should come first." -#: collective/blog/content/post.py:25 +#: collective/blog/content/post.py:26 msgid "help_authors" msgstr "Pessoas responsáveis por esta postagem." #. Default: "The names of people that have contributed to this item. Each contributor should be on a separate line." -#: collective/blog/content/post.py:42 +#: collective/blog/content/post.py:43 msgid "help_contributors" msgstr "Pessoas que contribuiram para esta postagem." #. Default: "Copyright statement or other rights information on this item." -#: collective/blog/content/post.py:58 +#: collective/blog/content/post.py:59 msgid "help_copyrights" msgstr "Informações sobre direitos autorais desta postagem." +#. Default: "Should we create the Authors container inside the Blog?" +#: collective/blog/interfaces.py:15 +msgid "help_enable_authors_folder" +msgstr "" + #. Default: "Authors" -#: collective/blog/content/post.py:24 +#: collective/blog/content/post.py:25 msgid "label_authors" msgstr "Autores" #. Default: "Rights" -#: collective/blog/content/post.py:57 +#: collective/blog/content/post.py:58 msgid "label_copyrights" msgstr "Direitos Autorais" #. Default: "Metadata" -#: collective/blog/content/post.py:19 +#: collective/blog/content/post.py:20 msgid "label_schema_metadata" msgstr "Metadados" diff --git a/src/collective/blog/subscribers/blog.py b/src/collective/blog/subscribers/blog.py index 09ddea7..6e5806c 100644 --- a/src/collective/blog/subscribers/blog.py +++ b/src/collective/blog/subscribers/blog.py @@ -1,3 +1,4 @@ +from collective.blog import _ from collective.blog import logger from collective.blog.content.blog import Blog from plone import api @@ -5,6 +6,11 @@ import uuid +_AUTHORS_FOLDERISH = { + "id": _("authors"), + "title": _("Authors"), + "description": _("Our Authors"), +} PERMISSIONS_BLOG = ( ("collective.blog: Add Blog", []), ("collective.blog: Add Author", []), @@ -35,8 +41,9 @@ def auto_add_authors_container(blog: Blog, event): # Create Authors container authors = api.content.create( type="Document", - id="authors", - title="Authors", + id=_AUTHORS_FOLDERISH["id"], + title=_AUTHORS_FOLDERISH["title"], + description=_AUTHORS_FOLDERISH["description"], container=blog, ) # Add Blocks From d0fe0d9bacc0e3b6b328d051c38c65a3c58065fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Mon, 4 Dec 2023 11:09:58 -0300 Subject: [PATCH 2/3] Fix language detection support --- .../blog/locales/collective.blog.pot | 23 +++++---- .../locales/de/LC_MESSAGES/collective.blog.po | 23 +++++---- .../locales/en/LC_MESSAGES/collective.blog.po | 23 +++++---- .../locales/es/LC_MESSAGES/collective.blog.po | 23 +++++---- .../pt_BR/LC_MESSAGES/collective.blog.po | 47 ++++++++++--------- src/collective/blog/subscribers/blog.py | 33 ++++++++++--- tests/content/test_blog.py | 24 +++++++++- 7 files changed, 126 insertions(+), 70 deletions(-) diff --git a/src/collective/blog/locales/collective.blog.pot b/src/collective/blog/locales/collective.blog.pot index 971b8de..141f188 100644 --- a/src/collective/blog/locales/collective.blog.pot +++ b/src/collective/blog/locales/collective.blog.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-12-01 11:10+0000\n" +"POT-Creation-Date: 2023-12-04 13:40+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -29,10 +29,6 @@ msgstr "" msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/subscribers/blog.py:11 -msgid "Authors" -msgstr "" - #: collective/blog/interfaces.py:14 msgid "Authors container inside the Blog" msgstr "" @@ -75,10 +71,6 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" -#: collective/blog/subscribers/blog.py:12 -msgid "Our Authors" -msgstr "" - #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -93,8 +85,19 @@ msgstr "" msgid "View" msgstr "" +#. Default: "Our Authors" +#: collective/blog/subscribers/blog.py:12 +msgid "authors_folder_desc" +msgstr "" + +#. Default: "authors" #: collective/blog/subscribers/blog.py:10 -msgid "authors" +msgid "authors_folder_id" +msgstr "" + +#. Default: "Authors" +#: collective/blog/subscribers/blog.py:11 +msgid "authors_folder_title" msgstr "" #. Default: "Contributors" diff --git a/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po index 6c5743d..3864b2c 100644 --- a/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/de/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-12-01 11:01+0000\n" +"POT-Creation-Date: 2023-12-04 13:40+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -26,10 +26,6 @@ msgstr "" msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/subscribers/blog.py:11 -msgid "Authors" -msgstr "Autoren" - #: collective/blog/interfaces.py:14 msgid "Authors container inside the Blog" msgstr "" @@ -72,10 +68,6 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" -#: collective/blog/subscribers/blog.py:12 -msgid "Our Authors" -msgstr "Unsere Autoren" - #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -90,10 +82,21 @@ msgstr "" msgid "View" msgstr "" +#. Default: "Our Authors" +#: collective/blog/subscribers/blog.py:12 +msgid "authors_folder_desc" +msgstr "Unsere Autoren" + +#. Default: "authors" #: collective/blog/subscribers/blog.py:10 -msgid "authors" +msgid "authors_folder_id" msgstr "autoren" +#. Default: "Authors" +#: collective/blog/subscribers/blog.py:11 +msgid "authors_folder_title" +msgstr "Autoren" + #. Default: "Contributors" #: collective/blog/content/post.py:42 msgid "contributors" diff --git a/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po index 957b3c3..851fa2e 100644 --- a/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/en/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-12-01 11:10+0000\n" +"POT-Creation-Date: 2023-12-04 13:40+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -26,10 +26,6 @@ msgstr "" msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/subscribers/blog.py:11 -msgid "Authors" -msgstr "" - #: collective/blog/interfaces.py:14 msgid "Authors container inside the Blog" msgstr "" @@ -72,10 +68,6 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" -#: collective/blog/subscribers/blog.py:12 -msgid "Our Authors" -msgstr "" - #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -90,8 +82,19 @@ msgstr "" msgid "View" msgstr "" +#. Default: "Our Authors" +#: collective/blog/subscribers/blog.py:12 +msgid "authors_folder_desc" +msgstr "" + +#. Default: "authors" #: collective/blog/subscribers/blog.py:10 -msgid "authors" +msgid "authors_folder_id" +msgstr "" + +#. Default: "Authors" +#: collective/blog/subscribers/blog.py:11 +msgid "authors_folder_title" msgstr "" #. Default: "Contributors" diff --git a/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po index edb7af4..3f0e686 100644 --- a/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/es/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-12-01 11:10+0000\n" +"POT-Creation-Date: 2023-12-04 13:40+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -26,10 +26,6 @@ msgstr "" msgid "A folderish content item representing a Blog" msgstr "" -#: collective/blog/subscribers/blog.py:11 -msgid "Authors" -msgstr "" - #: collective/blog/interfaces.py:14 msgid "Authors container inside the Blog" msgstr "" @@ -72,10 +68,6 @@ msgstr "" msgid "Implements a blog behavior on a content type" msgstr "" -#: collective/blog/subscribers/blog.py:12 -msgid "Our Authors" -msgstr "" - #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" msgstr "" @@ -90,8 +82,19 @@ msgstr "" msgid "View" msgstr "" +#. Default: "Our Authors" +#: collective/blog/subscribers/blog.py:12 +msgid "authors_folder_desc" +msgstr "" + +#. Default: "authors" #: collective/blog/subscribers/blog.py:10 -msgid "authors" +msgid "authors_folder_id" +msgstr "" + +#. Default: "Authors" +#: collective/blog/subscribers/blog.py:11 +msgid "authors_folder_title" msgstr "" #. Default: "Contributors" diff --git a/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po b/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po index 758b536..2d0bf20 100644 --- a/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po +++ b/src/collective/blog/locales/pt_BR/LC_MESSAGES/collective.blog.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2023-12-01 11:10+0000\n" +"POT-Creation-Date: 2023-12-04 13:40+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,7 +16,7 @@ msgstr "" #: collective/blog/profiles/default/types/Author.xml msgid "A Blog Author" -msgstr "" +msgstr "Autor / Autora no Blog" #: collective/blog/profiles/default/types/Post.xml msgid "A Blog Post" @@ -26,13 +26,9 @@ msgstr "Uma postagem no blog" msgid "A folderish content item representing a Blog" msgstr "Um tipo de conteúdo que representa um Blog" -#: collective/blog/subscribers/blog.py:11 -msgid "Authors" -msgstr "" - #: collective/blog/interfaces.py:14 msgid "Authors container inside the Blog" -msgstr "" +msgstr "Pasta contendo autores dentro de um Blog" #: collective/blog/profiles/default/types/BlogFolder.xml msgid "Blog" @@ -40,27 +36,27 @@ msgstr "Blog" #: collective/blog/profiles/default/types/Author.xml msgid "Blog Author" -msgstr "" +msgstr "Autor" #: collective/blog/behaviors/configure.zcml:13 msgid "Blog Behavior" -msgstr "" +msgstr "Blog" #: collective/blog/profiles/default/types/Post.xml msgid "Blog Post" -msgstr "" +msgstr "Postagem" #: collective/blog/controlpanel/controlpanel.py:16 msgid "Blog Settings" -msgstr "" +msgstr "Configurações do Blog" #: collective/blog/profiles.zcml:13 msgid "Blog Support for Plone" -msgstr "" +msgstr "Blog suporte para Plone" #: collective/blog/profiles.zcml:21 msgid "Blog Support for Plone: Uninstall" -msgstr "" +msgstr "Blog: Remover suporte" #: collective/blog/profiles/default/types/Author.xml #: collective/blog/profiles/default/types/BlogFolder.xml @@ -70,11 +66,7 @@ msgstr "Editar" #: collective/blog/behaviors/configure.zcml:13 msgid "Implements a blog behavior on a content type" -msgstr "" - -#: collective/blog/subscribers/blog.py:12 -msgid "Our Authors" -msgstr "" +msgstr "Implementa o comportamento de blog para um tipo de conteúdo" #: collective/blog/profiles.zcml:13 msgid "Package to configure Blog content types" @@ -82,7 +74,7 @@ msgstr "Pacote que configura tipos de conteúdo para blogs" #: collective/blog/profiles.zcml:21 msgid "Uninstall Blog setup." -msgstr "" +msgstr "Remover suporte a Blogs" #: collective/blog/profiles/default/types/Author.xml #: collective/blog/profiles/default/types/BlogFolder.xml @@ -90,9 +82,20 @@ msgstr "" msgid "View" msgstr "Visão" +#. Default: "Our Authors" +#: collective/blog/subscribers/blog.py:12 +msgid "authors_folder_desc" +msgstr "Autores deste blog" + +#. Default: "authors" #: collective/blog/subscribers/blog.py:10 -msgid "authors" -msgstr "" +msgid "authors_folder_id" +msgstr "autores" + +#. Default: "Authors" +#: collective/blog/subscribers/blog.py:11 +msgid "authors_folder_title" +msgstr "Autores" #. Default: "Contributors" #: collective/blog/content/post.py:42 @@ -117,7 +120,7 @@ msgstr "Informações sobre direitos autorais desta postagem." #. Default: "Should we create the Authors container inside the Blog?" #: collective/blog/interfaces.py:15 msgid "help_enable_authors_folder" -msgstr "" +msgstr "Habilitamos a criação da pasta de autores dentro do Blog?" #. Default: "Authors" #: collective/blog/content/post.py:25 diff --git a/src/collective/blog/subscribers/blog.py b/src/collective/blog/subscribers/blog.py index 6e5806c..6d525cf 100644 --- a/src/collective/blog/subscribers/blog.py +++ b/src/collective/blog/subscribers/blog.py @@ -1,20 +1,24 @@ from collective.blog import _ from collective.blog import logger +from collective.blog import PACKAGE_NAME from collective.blog.content.blog import Blog from plone import api +from zope.i18nmessageid.message import Message import uuid _AUTHORS_FOLDERISH = { - "id": _("authors"), - "title": _("Authors"), - "description": _("Our Authors"), + "id": _("authors_folder_id", default="authors"), + "title": _("authors_folder_title", default="Authors"), + "description": _("authors_folder_desc", default="Our Authors"), } + PERMISSIONS_BLOG = ( ("collective.blog: Add Blog", []), ("collective.blog: Add Author", []), ) + PERMISSIONS_AUTHORS = ( ( "collective.blog: Add Author", @@ -23,6 +27,20 @@ ) +def _translate(msg: Message, lang: str) -> str: + """Translate the msg to the desired language. + + This is here due to a bug on api.portal.translate that expects the language code to be + on a specific format. + ref: https://github.com/plone/plone.api/issues/524 + """ + if "-" in lang: + lang_ = lang[:2] + cc = lang[-2:].upper() + lang = f"{lang_}_{cc}" + return api.portal.translate(msg, domain=PACKAGE_NAME, lang=lang) + + def _log_permission_change(path: str, permission_id: str, roles: list): roles = ", ".join(roles) logger.info(f"{path}: Set {permission_id} to roles {roles}") @@ -38,12 +56,13 @@ def auto_add_authors_container(blog: Blog, event): for permission_id, roles in PERMISSIONS_BLOG: blog.manage_permission(permission_id, roles=roles, acquire=False) _log_permission_change(blog_path, permission_id, roles) + lang = blog.language # Create Authors container authors = api.content.create( type="Document", - id=_AUTHORS_FOLDERISH["id"], - title=_AUTHORS_FOLDERISH["title"], - description=_AUTHORS_FOLDERISH["description"], + id=_translate(_AUTHORS_FOLDERISH["id"], lang=lang), + title=_translate(_AUTHORS_FOLDERISH["title"], lang=lang), + description=_translate(_AUTHORS_FOLDERISH["description"], lang=lang), container=blog, ) # Add Blocks @@ -52,7 +71,7 @@ def auto_add_authors_container(blog: Blog, event): authors.blocks_layout = {"items": [uuids[0], uuids[1]]} authors_path = "/".join(authors.getPhysicalPath()) - logger.info(f"Created authors folder inside {blog_path}") + logger.info(f"Created {authors.id} folder inside {blog_path}") for permission_id, roles in PERMISSIONS_AUTHORS: authors.manage_permission(permission_id, roles=roles, acquire=False) _log_permission_change(authors_path, permission_id, roles) diff --git a/tests/content/test_blog.py b/tests/content/test_blog.py index 96d1fbe..3843a5a 100644 --- a/tests/content/test_blog.py +++ b/tests/content/test_blog.py @@ -35,12 +35,14 @@ def disable_authors(portal): api.portal.set_registry_record(key, True) -class TestBlog: +class TestBaseBlog: @pytest.fixture(autouse=True) def _fti(self, get_fti, integration, portal): self.fti = get_fti(CONTENT_TYPE) self.portal = portal + +class TestBlog(TestBaseBlog): def test_fti(self): assert isinstance(self.fti, DexterityFTI) @@ -107,6 +109,8 @@ def test_blog_info_behavior_indexed(self, blogs): assert len(brains) == 2 + +class TestBlogAuthorsFolder(TestBaseBlog): def test_authors_folder_creation(self, blogs_payload): payload = blogs_payload[0] with api.env.adopt_roles(["Manager"]): @@ -143,3 +147,21 @@ def test_authors_folder_not_created(self, blogs_payload, disable_authors): with api.env.adopt_roles(["Manager"]): content = api.content.create(container=self.portal, **payload) assert "authors" not in content.objectIds() + + @pytest.mark.parametrize( + "lang,o_id,o_title", + [ + ("en", "authors", "Authors"), + ("de", "autoren", "Autoren"), + ("pt-br", "autores", "Autores"), + ], + ) + def test_authors_folder_translated( + self, blogs_payload, lang: str, o_id: str, o_title: str + ): + payload = deepcopy(blogs_payload[0]) + payload["language"] = lang + with api.env.adopt_roles(["Manager"]): + content = api.content.create(container=self.portal, **payload) + assert o_id in content.objectIds() + assert content[o_id].title == o_title From 967aca5577e8971a8df1e9e3c129bb337d9ba402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Mon, 4 Dec 2023 11:51:31 -0300 Subject: [PATCH 3/3] Tests: Always compile .mo files --- tests/conftest.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 7e8baa4..a4db66b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,11 +2,15 @@ from collective.blog.testing import FUNCTIONAL_TESTING from collective.blog.testing import INTEGRATION_TESTING from copy import deepcopy +from pathlib import Path from plone import api from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.restapi.testing import RelativeSession from pytest_plone import fixtures_factory +from pythongettext.msgfmt import Msgfmt +from pythongettext.msgfmt import PoSyntaxError +from typing import Generator import pytest @@ -25,6 +29,26 @@ ) +@pytest.fixture(scope="session", autouse=True) +def generate_mo(): + """Generate .mo files.""" + import collective.blog + + locales_path = Path(collective.blog.__file__).parent / "locales" + po_files: Generator = locales_path.glob("**/*.po") + for po_file in po_files: + parent: Path = po_file.parent + domain: str = po_file.name[: -len(po_file.suffix)] + mo_file: Path = parent / f"{domain}.mo" + try: + mo = Msgfmt(f"{po_file}", name=domain).getAsFile() + except PoSyntaxError: + continue + else: + with open(mo_file, "wb") as f_out: + f_out.write(mo.read()) + + @pytest.fixture def filter_items(): def func(content: list, portal_type: str, only_public: bool = False) -> list: