Re: Mailman core: basic internationalization howto?
Hi.
This is far short of a howto: I have done something similar for one of my lists, although for Swedish. I just added custom templates for all things necessary and set the default language for the list to "sv" for Swedish.
It worked without setting the language on the list but then any non-ASCII characters in the template caused mailman to crash and lose the mail without any warning if you send a HTML-formatted message. But it works just fine for pure text messages, I guess as the character set in my test mail was something compatible. I think I filed an error for this.
The language for the list can be set via the "mailman withlist" command (or in the database directly, but I have not tried that).
I run a relatively new version of mailman, after 3.1. Without Hyperkitty.
// David
On Wed, Oct 4, 2017 at 10:55 AM, Thor Atle Rustad <thor.rustad@gmail.com> wrote:
I would like to use Norwegian in the welcome/subscribe/unsubscribe/confirm etc messages from mailman3. For my current project I want all future mailing lists to have Norwegian as default. I find some sporadic info on the subject, but it's fair to say that I would like some simple instructions (e.g. what to copy from where to where, and which configs to change).
Mailman-users mailing list mailman-users@mailman3.org https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
I made it work, sort of, after creating the directory structure templates/site/no and put the templates inside the 'no' folder. However, I can't make it work without setting the language manually for each list first. New lists are created with English as their language, breaking the creation of welcome mail. Also, I can not add members to the lists from Postorius. I want all new lists to use utf-8 without having to use mailman shell. How can it be done?
On 10/06/2017 07:34 AM, thor.rustad@gmail.com wrote:
I made it work, sort of, after creating the directory structure templates/site/no and put the templates inside the 'no' folder. However, I can't make it work without setting the language manually for each list first. New lists are created with English as their language, breaking the creation of welcome mail. Also, I can not add members to the lists from Postorius. I want all new lists to use utf-8 without having to use mailman shell. How can it be done?
Put
[mailman] default_language: no
in your mailman config.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 10/06/2017 07:34 AM, thor.rustad@gmail.com wrote:
I made it work, sort of, after creating the directory structure templates/site/no and put the templates inside the 'no' folder. However, I can't make it work without setting the language manually for each list first. New lists are created with English as their language, breaking the creation of welcome mail. Also, I can not add members to the lists from Postorius. I want all new lists to use utf-8 without having to use mailman shell. How can it be done?
Put
[mailman] default_language: no
in your mailman config.
Mark,
I already have that in my mailman-extra.cfg. See https://gitlab.com/mailman/mailman/issues/413#note_42453740, there's my config.
When I make a new list, the list's language is English/us-ascii. However, it will choose the templates from the site/no directory. So it chooses the correct template for my site preferences, but the list has the wrong language. Mailman reports Norwegian as default language. Is all language related setup in files? Should I check postgresql for language settings?
Thor
On Oct 6, 2017, at 16:19, Thor Atle Rustad <thor.rustad@gmail.com> wrote:
When I make a new list, the list's language is English/us-ascii. However, it will choose the templates from the site/no directory. So it chooses the correct template for my site preferences, but the list has the wrong language. Mailman reports Norwegian as default language. Is all language related setup in files? Should I check postgresql for language settings?
The mailing list’s language is initially assigned from the style that is applied, specifically the preferred_language
attribute. By default, we ship a ‘legacy-default’ style which as you’ve guessed, assigns ‘en’ to the language.
So the way this will work is that you want to create a new style which will be the same as ‘legacy-default’ but sets the language to ‘no’. Something like the following (untested):
from mailman.interfaces.styles import IStyle
from mailman.styles.base import (
BasicOperation, Bounces, Discussion, Identity, Moderation, Public)
from public import public
from zope.interface import implementer
@public
@implementer(IStyle)
class NOStyle(Identity, BasicOperation, Bounces, Public, Discussion, Moderation):
name = ’no-default'
def apply(self, mailing_list):
"""See `IStyle`."""
Identity.apply(self, mailing_list)
BasicOperation.apply(self, mailing_list)
Bounces.apply(self, mailing_list)
Public.apply(self, mailing_list)
Discussion.apply(self, mailing_list)
Moderation.apply(self, mailing_list)
mailing_list.preferred_language = ‘no’
Then in your mailman.cfg:
[styles]
default: no-default
The last thing is that you have to arrange for your NOStyle module to get imported at the right time. See http://mailman.readthedocs.io/en/latest/src/mailman/plugins/docs/intro.html for details, but understand that that only works for git master (i.e. what will be Mailman 3.2).
Let us know how it goes. Using plugins for extending the set of default styles isn’t well tested, but if it doesn’t work, I’d consider that a bug.
Cheers, -Barry
So the way this will work is that you want to create a new style which will be the same as ‘legacy-default’ but sets the language to ‘no’. Something like the following (untested):
from mailman.interfaces.styles import IStyle from mailman.styles.base import ( BasicOperation, Bounces, Discussion, Identity, Moderation, Public) from public import public from zope.interface import implementer @public @implementer(IStyle) class NOStyle(Identity, BasicOperation, Bounces, Public, Discussion, Moderation): name = ’no-default' def apply(self, mailing_list): """See `IStyle`.""" Identity.apply(self, mailing_list) BasicOperation.apply(self, mailing_list) Bounces.apply(self, mailing_list) Public.apply(self, mailing_list) Discussion.apply(self, mailing_list) Moderation.apply(self, mailing_list) mailing_list.preferred_language = ‘no’
Barry,
Thanks, I'll try that tomorrow. Now, I'm a 98% Python illiterate.. so it's not obvious to me where I should put this. However, styles/default.py looks like a candiate. Is that correct? Then, should I just add NOstyle as a class and leave LegacyDefaultStyle just the way it is?
Thor
participants (5)
-
Barry Warsaw
-
David Krantz
-
Mark Sapiro
-
Thor Atle Rustad
-
thor.rustad@gmail.com