recipe for putting a po file in parts/instance/i18n?

3 Messages Forum Options Options
Permalink
Maurits van Rees-3
recipe for putting a po file in parts/instance/i18n?
Reply Threaded More
Print post
Permalink
Hi,

When overwriting existing translations for the plone domain (or any
other domain) the best solution is to place a po file in the i18n
directory of the zope instance, so parts/instance/i18n when using
buildout.

Is there a buildout recipe that can do this already?

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Plone-i18n mailing list
Plone-i18n@...
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Hanno Schlichting-2
Re: recipe for putting a po file in parts/instance/i18n?
Reply Threaded More
Print post
Permalink
Maurits van Rees wrote:
> When overwriting existing translations for the plone domain (or any
> other domain) the best solution is to place a po file in the i18n
> directory of the zope instance, so parts/instance/i18n when using
> buildout.
>
> Is there a buildout recipe that can do this already?

None, that I know of.

You might get around with one of the 'command' recipes putting a symlink
to a directory in the buildout root in there.

I recently needed to have the Extensions directory be handled in the
same way, but haven't had time to do this properly yet. The symlink
approach is quite nice when you have multiple Zope instances. For
Windows relying on the junction tool as done in the omlette recipe would
be an option...

Hanno


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Plone-i18n mailing list
Plone-i18n@...
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Maurits van Rees-3
Re: recipe for putting a po file in parts/instance/i18n?
Reply Threaded More
Print post
Permalink
Hanno Schlichting, on 2008-05-30:

> Maurits van Rees wrote:
>> When overwriting existing translations for the plone domain (or any
>> other domain) the best solution is to place a po file in the i18n
>> directory of the zope instance, so parts/instance/i18n when using
>> buildout.
>>
>> Is there a buildout recipe that can do this already?
>
> None, that I know of.
>
> You might get around with one of the 'command' recipes putting a symlink
> to a directory in the buildout root in there.

Ah, right.  I now do the following in buildout and that works:

[i18n-overwrites]
recipe = plone.recipe.command
command = python scripts/install-i18n-overwrites.py
update-command = python scripts/install-i18n-overwrites.py


For reference, I will paste the script below.  Too hardcoded and only
works for one instance currently, but that suffices for me for now.
It simply copies any '.po' files in the scripts directory of buildout
to parts/instance/i18n.


=======================================================================
#!/usr/bin/python2.4

import os
import sys
import shutil

buildout_dir = os.getcwd()
path = os.path.split(buildout_dir)
# Make sure this script can be called both from within the buildout
# directory and from the script directory.
if path[1] == 'scripts':
    buildout_dir = path[0]

instance_dir = os.path.join(buildout_dir, 'parts', 'instance')
if not os.path.exists(instance_dir):
    print "ERROR: %s does not exist.  Run bin/buildout again." % instance_dir
    sys.exit(1)
if not os.path.isdir(instance_dir):
    print "ERROR: %s is not a directory.  Run bin/buildout again." % instance_dir
    sys.exit(1)

i18n_dir = os.path.join(instance_dir, 'i18n')
if not os.path.exists(i18n_dir):
    print "Creating directory %s" % i18n_dir
    os.mkdir(i18n_dir)
if not os.path.isdir(i18n_dir):
    print "ERROR: %s is not a directory.  Run bin/buildout again." % i18n_dir
    sys.exit(1)


po_dir = os.path.join(buildout_dir, 'scripts')
print "Copying po (translation) files from %s to %s" % (po_dir, i18n_dir)
for po_name in os.listdir(po_dir):
    if po_name.endswith('.po'):
        po_file = os.path.join(po_dir, po_name)
        print "Copying %s" % po_file
        shutil.copy(po_file, i18n_dir)

print "Done"
=======================================================================



--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Plone-i18n mailing list
Plone-i18n@...
https://lists.sourceforge.net/lists/listinfo/plone-i18n