provide .pot templates for new locales

RESOLVED FIXED in Q1 2011

Status

addons.mozilla.org Graveyard
Localization
P5
normal
RESOLVED FIXED
7 years ago
2 years ago

People

(Reporter: gandalf, Assigned: clouserw)

Tracking

unspecified
Q1 2011
x86
Mac OS X

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

7 years ago
Gettext pattern is to place .pot files in a directory /templates/LC_MESSAGES which is then used for new locale initialization and entity merging.

Currently, entity merging is done by AMO devs manually, so not sure if they want to switch to this model, but such positioning would help us bootstrap new locales basing on the template.

So, the proposed directory structure looks like this:

/ru
/sk
/de
/templates/LC_MESSAGES/messages.pot
/templates/LC_MESSAGES/javascript.pot

Out of this we will be able to initialize new locales automagically. (not sure if adding them to SVN will happen without human touch but we'll be step closer to one-click locale bootstrapping anyway)
This could be helpful: https://github.com/clouserw/tower/blob/master/tower/management/commands/verbatimize.py

Although I'm not sure whether we still need the --rename option.  Are our POT files still prefixed with "z-"?
(Assignee)

Updated

7 years ago
Assignee: nobody → clouserw
Target Milestone: --- → Q1 2011
(Assignee)

Updated

7 years ago
Priority: -- → P5
(Assignee)

Comment 2

7 years ago
Created attachment 510107 [details] [diff] [review]
fix

This gets rid of all the z-* stuff and makes locale/templates/LC_MESSAGES the default output dir.

I don't use verbatimize, but it looks like we could remove that command after this lands.
Attachment #510107 - Flags: review?(stas)
(Assignee)

Comment 3

7 years ago
James might use verbatimize, so CCing for fyi.
Here's my workflow for updating strings, per our README[1] for it:

./manage.py extract
./manage.py verbatimize --rename
./manage.py merge  # Also used for populating new locales?

extract still outputs locale/z-keys.pot and locale/z-javascript.pot. If we can make it output locale/templates/LC_MESSAGES/messages.pot and locale/templates/LC_MESSAGES/javascript.pot, and drop the 'verbatimize --rename' step, I call it a win.

I have one question about the patch, though: do we need to either drop our 'STANDALONE_DOMAINS' setting or update it to ['messages', 'javascript']? [2]

[1] http://viewvc.svn.mozilla.org/vc/projects/sumo/locales/README.txt?view=markup
[2] https://bugzilla.mozilla.org/attachment.cgi?id=510107&action=diff#a/tower/management/commands/extract.py_sec2
(Assignee)

Comment 5

7 years ago
(In reply to comment #4)
> Here's my workflow for updating strings, per our README[1] for it:
> 
> ./manage.py extract
> ./manage.py verbatimize --rename
> ./manage.py merge  # Also used for populating new locales?
> 
> extract still outputs locale/z-keys.pot and locale/z-javascript.pot. If we can
> make it output locale/templates/LC_MESSAGES/messages.pot and
> locale/templates/LC_MESSAGES/javascript.pot, and drop the 'verbatimize
> --rename' step, I call it a win.

This would remove the verbatimize step.  I haven't used merge, but it looks like it would work.

> I have one question about the patch, though: do we need to either drop our
> 'STANDALONE_DOMAINS' setting or update it to ['messages', 'javascript']?

What is it set to now?  If you want a messages.po and a javascript.po, I'd just drop it from your settings files.
(In reply to comment #5)
> This would remove the verbatimize step.  I haven't used merge, but it looks
> like it would work.

Awesome. The patch doesn't touch merge so I assume it would be unaffected.

> What is it set to now?  If you want a messages.po and a javascript.po, I'd just
> drop it from your settings files.

It's currently STANDALONE_DOMAINS = ['javascript'] but we'll just drop it when we upgrade tower.
Comment on attachment 510107 [details] [diff] [review]
fix

I love this patch.  It's a great thing that we can remove verbatimize at last.

r=me with a question and a nit.

>@@ -1,6 +1,7 @@
>+# By default, all the domains you speficy will be merged into one big
>+# messages.po file.  If you want to separate a domain from the main .po file,
>+# specify it in this list.  Make sure to include 'messages' here, or you won't
>+# get a messages.po after the script has run.
> try:
>     standalone_domains = settings.STANDALONE_DOMAINS
> except AttributeError:
>-    standalone_domains = ['javascript']
>+    standalone_domains = ['messages', 'javascript']

Should we use setting.TEXT_DOMAIN instead of 'messages'?  We do that in merge.py.


>@@ -124,11 +129,22 @@ class Command(BaseCommand):
>+        make_option('--output-dir', '-o',
>+                    default="locale/templates/LC_MESSAGES",
>+                    dest='outputdir',
>+                    help='The directory where extracted files will be placed. '
>+                         '(Default: %s)' % './locale/templates/LC_MESSAGES'),

I think that the default should be:
  os.path.join(settings.ROOT, 'locale', 'templates', 'LC_MESSAGES')


BTW Can we now remove the amalgamate command as well?
Attachment #510107 - Flags: review?(stas) → review+
Hmm, actually, I think we'll need to change merge command as well. See https://github.com/clouserw/tower/blob/master/tower/management/commands/merge.py and the following part:

try:
    domains = [settings.TEXT_DOMAIN] + settings.STANDALONE_DOMAINS
except AttributeError:
    domains = [settings.TEXT_DOMAIN, 'javascript']

that should now read:

try:
    domains = settings.STANDALONE_DOMAINS
except AttributeError:
    domains = [settings.TEXT_DOMAIN, 'javascript']
(Assignee)

Comment 9

7 years ago
Created attachment 510454 [details] [diff] [review]
better fix
Attachment #510107 - Attachment is obsolete: true
Attachment #510454 - Flags: review?(stas)
Comment on attachment 510454 [details] [diff] [review]
better fix

Just some random comments.


> try:
>     standalone_domains = settings.STANDALONE_DOMAINS
> except AttributeError:
>-    standalone_domains = ['javascript']
>+    standalone_domains = [TEXT_DOMAIN, 'javascript']

As discussed in irc, the fallback here could just be standalone_domains = [TEXT_DOMAIN].

> 
> TOWER_KEYWORDS = dict(DEFAULT_KEYWORDS)
> 
>@@ -124,11 +131,23 @@ class Command(BaseCommand):
>         make_option('--domain', '-d', default=DEFAULT_DOMAIN, dest='domain',
>                     help='The domain of the message files.  If "all" '
>                          'everything will be extracted and combined into '
>-                         'z-keys.pot. (default: %s).' % DEFAULT_DOMAIN),
>+                         '<TEXT_DOMAIN>.pot. (default: %default).'),

Again from irc, <TEXT_DOMAIN> could be a placable.

>         if len(domains) > 1:
>             print "Concatenating all domains except the standalone ones..."

How about this:
    print "Concatenating the non-standalone domains into %s.pot" % TEXT_DOMAIN


>diff --git a/tower/management/commands/merge.py b/tower/management/commands/merge.py
>index b354ba4..564a03a 100644
>--- a/tower/management/commands/merge.py
>+++ b/tower/management/commands/merge.py
>@@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand
> from manage import settings
> 
> try:
>-    domains = [settings.TEXT_DOMAIN] + settings.STANDALONE_DOMAINS
>+    domains = settings.STANDALONE_DOMAINS
> except AttributeError:
>     domains = [settings.TEXT_DOMAIN, 'javascript']

Same comment from irc about the default fallback applies here.
Attachment #510454 - Flags: review?(stas) → review+
(Assignee)

Comment 11

7 years ago
thanks

https://github.com/clouserw/tower/commit/99275f64345bf7e972943d9e9d36823c05149d24
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.