Internationalize additions to asset expoter.

This commit is contained in:
Drake 2006-10-13 21:22:28 +00:00
parent 1674bcfe10
commit e03d761eca
2 changed files with 93 additions and 20 deletions

View file

@ -171,39 +171,37 @@ sub _exportAsHtml {
s#^/*## for ($extrasUrl, $uploadsUrl); s#^/*## for ($extrasUrl, $uploadsUrl);
my ($extrasDst, $uploadsDst) = ($exportPath.'/'.$extrasUrl, $exportPath.'/'.$uploadsUrl); my ($extrasDst, $uploadsDst) = ($exportPath.'/'.$extrasUrl, $exportPath.'/'.$uploadsUrl);
# TODO: internationalize $self->session->output->print($i18n->get('extrasUploads symlinking')."\n") unless $quiet;
$self->session->output->print("Symlinking extras and uploads dirs.\n") unless $quiet;
foreach my $rec ([$extrasPath, $extrasDst], foreach my $rec ([$extrasPath, $extrasDst],
[$uploadsPath, $uploadsDst]) { [$uploadsPath, $uploadsDst]) {
my ($path, $dst) = @$rec; my ($path, $dst) = @$rec;
if (-l $dst) { if (-l $dst) {
next if (readlink $dst eq $path); next if (readlink $dst eq $path);
unlink $dst or return (0, sprintf("Could not unlink %s: %s", $dst, $!)); unlink $dst or return (0, sprintf($i18n->get('could not unlink'), $dst, $!));
} }
eval { mkpath($dst) }; eval { mkpath($dst) };
$@ and return (0, sprintf("Could not create path %s: %s", $dst, $@)); $@ and return (0, sprintf($i18n->get('could not create'), $dst, $@));
rmdir $dst or return (0, sprintf("Could not remove directory at path %s: %s", $dst, $!)); rmdir $dst or return (0, sprintf($i18n->get('could not rmdir'), $dst, $!));
symlink $path, $dst or return (0, sprintf("Could not symlink %s to %s: %s", $path, $dst, $!)); symlink $path, $dst or return (0, sprintf($i18n->get('could not symlink'), $path, $dst, $!));
} }
} elsif ($extrasUploadsAction eq 'none') { } elsif ($extrasUploadsAction eq 'none') {
# Nothing. This is the default. # Nothing. This is the default.
} }
if ($rootUrlAction eq 'symlinkDefault') { if ($rootUrlAction eq 'symlinkDefault') {
# TODO: internationalize
if (defined $defaultAssetPath) { if (defined $defaultAssetPath) {
{ {
my ($src, $dst) = ($defaultAssetPath, $exportPath.'/'.$index); my ($src, $dst) = ($defaultAssetPath, $exportPath.'/'.$index);
$self->session->output->print("Symlinking default asset.\n") unless $quiet; $self->session->output->print($i18n->get('rootUrl symlinking default')."\n") unless $quiet;
if (-l $dst) { if (-l $dst) {
last if (readlink $dst eq $src); last if (readlink $dst eq $src);
unlink $dst or return (0, sprintf("Could not unlink %s: %s", $dst, $!)); unlink $dst or return (0, sprintf($i18n->get('could not unlink'), $dst, $!));
} }
symlink $src, $dst or return (0, sprintf("Could not symlink %s to %s: %s", $src, $dst, $!)); symlink $src, $dst or return (0, sprintf($i18n->get('could not symlink'), $src, $dst, $!));
} }
} else { } else {
$self->session->output->print("Not symlinking default asset; not included in exported subtree.\n") unless $quiet; $self->session->output->print($i18n->get('rootUrl default not present')."\n") unless $quiet;
} }
} elsif ($rootUrlAction eq 'none') { } elsif ($rootUrlAction eq 'none') {
# Nothing. This is the default. # Nothing. This is the default.
@ -262,22 +260,22 @@ sub www_export {
-name=>"index", -name=>"index",
-value=>"index.html" -value=>"index.html"
); );
# TODO: internationalize
# TODO: maybe add copy options to these boxes alongside symlink # TODO: maybe add copy options to these boxes alongside symlink
$f->selectBox( $f->selectBox(
-label => "Extras and uploads directories", -label => $i18n->get('extrasUploads form label'),
-hoverHelp => "What action to take regarding the extras and uploads directories, which are often referenced by parts of the site. Symlink means to use a symbolic link (not available on all systems) to the original directory. None means to do nothing, and ignore the extras and uploads directories; this will probably cause references to them to break in the exported site unless you've prepared the directories already.", -hoverHelp => $i18n->get('extrasUploads form hoverHelp'),
-name => "extrasUploadsAction", -name => "extrasUploadsAction",
-options => { 'symlink' => 'Symlink', -options => { 'symlink' => $i18n->get('extrasUploads form option symlink'),
'none' => 'None' }, 'none' => $i18n->get('extrasUploads form option none') },
-value => ['none'], -value => ['none'],
); );
$f->selectBox( $f->selectBox(
-label => "Root URL", -label => $i18n->get('rootUrl form label'),
-hoverHelp => "What action to take regarding queries to the root URL. Symlink Default means to create a symbolic link from the root-URL index file to the index file of the default asset (not available on all systems). None means to do nothing, which usually causes queries to the root URL to be rejected in the exported site.", -hoverHelp => $i18n->get('rootUrl form hoverHelp'),
-name => "rootUrlAction", -name => "rootUrlAction",
-options => { 'symlinkDefault' => 'Symlink Default', -options => { 'symlinkDefault' => $i18n->get('rootUrl form option symlinkDefault'),
'none' => 'None' }, 'none' => $i18n->get('rootUrl form option none') },
-value => ['none'], -value => ['none'],
); );
$f->submit; $f->submit;

View file

@ -967,6 +967,81 @@ to edit or modify that asset.</p>|,
lastUpdated => 1128920336, lastUpdated => 1128920336,
}, },
'extrasUploads symlinking' => {
message => q|Symlinking extras and uploads dirs.|,
lastUpdated => 1160773957,
},
'rootUrl symlinking default' => {
message => q|Symlinking extras and uploads dirs.|,
lastUpdated => 1160773957,
},
'rootUrl default not present' => {
message => q|Not symlinking default asset; not included in exported subtree.|,
lastUpdated => 1160773957,
},
'could not create' => {
message => q|Could not create %s: %s|,
lastUpdated => 1160773957,
},
'could not unlink' => {
message => q|Could not unlink %s: %s|,
lastUpdated => 1160773957,
},
'could not rmdir' => {
message => q|Could not remove directory at %s: %s|,
lastUpdated => 1160773957,
},
'could not symlink' => {
message => q|Could not symlink %s to %s: %s|,
lastUpdated => 1160773957,
},
'extrasUploads form label' => {
message => q|Extras and uploads directories|,
lastUpdated => 1160773957,
},
'extrasUploads form hoverHelp' => {
message => q|What action to take regarding the extras and uploads directories, which are often referenced by parts of the site. Symlink means to use a symbolic link (not available on all systems) to the original directory. None means to do nothing, and ignore the extras and uploads directories; this will probably cause references to them to break in the exported site unless you've prepared the directories already.|,
lastUpdated => 1160773957,
},
'extrasUploads form option symlink' => {
message => q|Symlink|,
lastUpdated => 1160773957,
},
'extrasUploads form option none' => {
message => q|None|,
lastUpdated => 1160773957,
},
'rootUrl form label' => {
message => q|Root URL|,
lastUpdated => 1160773957,
},
'rootUrl form hoverHelp' => {
message => q|What action to take regarding queries to the root URL. Symlink Default means to create a symbolic link from the root-URL index file to the index file of the default asset (not available on all systems). None means to do nothing, which usually causes queries to the root URL to be rejected in the exported site.|,
lastUpdated => 1160773957,
},
'rootUrl form option symlinkDefault' => {
message => q|Symlink Default|,
lastUpdated => 1160773957,
},
'rootUrl form option none' => {
message => q|None|,
lastUpdated => 1160773957,
},
}; };
1; 1;