Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature 1616: add a tool to replace language keys from a mapping file…
… + replace values from a template file git-svn-id: http://piwigo.org/svn/trunk@7026 68402e56-0260-453c-a942-63ccdbb3a9ee
- Loading branch information
Showing
3 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
$lang['%d category including'] = '%d album including'; | ||
$lang['%d categories including'] = '%d albums including'; | ||
$lang['%d category moved'] = '%d album moved'; | ||
$lang['%d categories moved'] = '%d albums moved'; | ||
$lang['Apply to subcategories'] = 'Apply to sub-albums'; | ||
$lang['Categories authorized thanks to group associations'] = 'Albums authorized thanks to group associations'; | ||
$lang['Categories manual order was saved'] = 'Album manual order was saved'; | ||
$lang['Category elements associated to the following categories: %s'] = 'Album elements associated to the following albums: %s'; | ||
$lang['Link all category elements to a new category'] = 'Link all album elements to a new album'; | ||
$lang['Link all category elements to some existing categories'] = 'Link all album elements to some existing albums'; | ||
$lang['Linked categories'] = 'Linked albums'; | ||
$lang['Manage permissions for a category'] = 'Edit album permissions'; | ||
$lang['Move categories'] = 'Move albums'; | ||
$lang['New parent category'] = 'New parent album'; | ||
$lang['Only private categories are listed'] = 'Only private albums are listed'; | ||
$lang['Other private categories'] = 'Other private albums'; | ||
$lang['Parent category'] = 'Parent album'; | ||
$lang['Permalink %s has been previously used by category %s. Delete from the permalink history first'] = 'Permalink %s has been previously used by album %s. Delete from the permalink history first'; | ||
$lang['Permalink %s is already used by category %s'] = 'Permalink %s is already used by album %s'; | ||
$lang['Representation of categories'] = 'Representation of albums'; | ||
$lang['Select at least one category'] = 'Select at least one album'; | ||
$lang['Storage category'] = 'Storage album'; | ||
$lang['Virtual categories to move'] = 'Virtual albums to move'; | ||
$lang['Virtual category name'] = 'Virtual album name'; | ||
$lang['You cannot move a category in its own sub category'] = 'You cannot move an album in its own sub album'; | ||
$lang['associate to category'] = 'Associate to album'; | ||
$lang['Add a virtual category'] = 'Add a virtual album'; | ||
$lang['Authorize users to add comments on selected categories'] = 'Authorize users to add comments on selected albums'; | ||
$lang['The name of a category should not be empty'] = 'The name of an album must not be empty'; | ||
$lang['Lock categories'] = 'Lock albums'; | ||
$lang['Private category'] = 'Private'; | ||
$lang['Public category'] = 'Public'; | ||
$lang['Manage authorizations for selected categories'] = 'Manage authorizations for selected albums'; | ||
$lang['Select uploadable categories'] = 'Select uploadable albums'; | ||
$lang['Virtual category added'] = 'Virtual album added'; | ||
$lang['Virtual category deleted'] = 'Virtual album deleted'; | ||
$lang['delete category'] = 'delete album'; | ||
$lang['dissociate from category'] = 'Dissociate from album'; | ||
$lang['edit category permissions'] = 'edit album permissions'; | ||
$lang['Category informations updated successfully.'] = 'Album updated successfully'; | ||
$lang['jump to category'] = 'jump to album'; | ||
$lang['manage category elements'] = 'manage album elements'; | ||
$lang['manage sub-categories'] = 'manage sub-albums'; | ||
$lang['Categories management'] = 'Album list management'; | ||
$lang['Edit a category'] = 'Edit album'; | ||
$lang['Update categories informations'] = 'Update albums informations'; | ||
$lang['reduce to single existing categories'] = 'reduce to single existing albums'; | ||
$lang['display maximum informations (added categories and elements, deleted categories and elements)'] = 'display maximum informations (added albums and elements, deleted albums and elements)'; | ||
$lang['categories deleted in the database'] = 'albums deleted in the database'; | ||
$lang['categories added in the database'] = 'albums added in the database'; | ||
$lang['Files with same name in more than one physical category'] = 'Files with same name in more than one physical album'; | ||
$lang['edit category informations'] = 'edit album'; | ||
$lang['No element in this category'] = 'No element in this album'; | ||
$lang['Drop into category'] = 'Drop into album'; | ||
$lang['existing category'] = 'existing album'; | ||
$lang['create a new category'] = 'create a new album'; | ||
$lang['Category name'] = 'Album name'; | ||
$lang['Category "%s" has been added'] = 'Album "%s" has been added'; | ||
$lang['Category "%s" now contains %d photos'] = 'Album "%s" now contains %d photos'; | ||
$lang['Category \'%s\' has been added'] = 'Album "%s" has been added'; | ||
$lang['Category \'%s\' now contains %d photos'] = 'Album "%s" now contains %d photos'; | ||
$lang['Categories automatically sorted'] = 'Albums automatically sorted'; | ||
$lang['%d category updated'] = '%d album updated'; | ||
$lang['%d categories updated'] = '%d albums updated'; | ||
$lang['Categories'] = 'Albums'; | ||
$lang['Category'] = 'Album'; | ||
$lang['The RSS notification feed provides notification on news from this website : new pictures, updated categories, new comments. Use a RSS feed reader.'] = 'The RSS notification feed provides notification on news from this website : new pictures, updated albums, new comments. Use a RSS feed reader.'; | ||
$lang['Expand all categories'] = 'Expand all albums'; | ||
$lang['shows images at the root of this category'] = 'shows images at the root of this album'; | ||
$lang['in this category'] = 'in this album'; | ||
$lang['in %d sub-category'] = 'in %d sub-album'; | ||
$lang['in %d sub-categories'] = 'in %d sub-albums'; | ||
$lang['display all elements in all sub-categories'] = 'display all elements in all sub-albums'; | ||
$lang['Recent categories'] = 'Recent albums'; | ||
$lang['display recently updated categories'] = 'display recently updated albums'; | ||
$lang['Search in Categories'] = 'Search in albums'; | ||
$lang['Search in subcategories'] = 'Search in sub-albums'; | ||
$lang['set as category representative'] = 'set as album representative'; | ||
$lang['Category: %s'] = 'Album: %s'; | ||
$lang['Category results for'] = 'Album results for'; | ||
$lang['All sub-categories of private categories become private'] = 'All sub-albums of private albums become private'; | ||
$lang['sub-categories'] = 'sub-albums'; | ||
$lang['a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory "thumbnail" of the category directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :'] = 'a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory "thumbnail" of the album directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :'; | ||
$lang['a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory \'thumbnail\' of the category directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :'] = 'a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory "thumbnail" of the album directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :'; | ||
$lang['Virtual category'] = 'Virtual album'; | ||
$lang['[%s] Come to visit the category %s'] = '[%s] Visit album %s'; | ||
$lang['Come to discover the category:'] = 'Discover album:'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
my $replacement_file = $ARGV[0]; | ||
my $language_dir = $ARGV[1]; | ||
|
||
# load the replacements | ||
my %replace_by = (); | ||
open(my $ifh_rep, '<'.$replacement_file); | ||
while (<$ifh_rep>) { | ||
if (m/^\$lang\['(.*)'\] \s* = \s* (['"])(.*)\2;/x) { | ||
if ($1 ne $3 and length($1) > 0) { | ||
$replace_by{$1} = $3; | ||
} | ||
} | ||
} | ||
# use Data::Dumper; print Dumper(\%replace_by); exit(); | ||
|
||
my $append_to_common = ''; | ||
|
||
foreach my $file_code (qw/upgrade install admin common plugin/) { | ||
my $filename = $language_dir.'/'.$file_code.'.lang.php'; | ||
# print $filename; | ||
if (not -f $filename) { | ||
# print ' is missing', "\n"; | ||
next; | ||
} | ||
print $filename.' is under process', "\n"; | ||
|
||
my $file_content = ''; | ||
|
||
open(my $ifh, '<'.$filename); | ||
while (my $line = <$ifh>) { | ||
if ($line =~ m/^\$lang\['(.*)'\] \s* =/x) { | ||
if (defined $replace_by{$1}) { | ||
my $search = quotemeta($1); | ||
my $replace = $replace_by{$1}; | ||
|
||
$line =~ s{$search}{$replace}; | ||
$file_content.= $line; | ||
} | ||
else { | ||
$file_content.= $line; | ||
} | ||
} | ||
elsif ($line =~ m/^?>/) { | ||
$file_content.= $line; | ||
} | ||
else { | ||
$file_content.= $line; | ||
} | ||
} | ||
close($ifh); | ||
|
||
open(my $ofh, '>'.$filename); | ||
print {$ofh} $file_content; | ||
close($ofh); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
my $replacement_file = $ARGV[0]; | ||
my $language_dir = $ARGV[1]; | ||
|
||
# load the new values for given keys | ||
my %new_value_of = (); | ||
open(my $ifh_rep, '<'.$replacement_file); | ||
while (<$ifh_rep>) { | ||
if (m/^\$lang\['(.*)'\] \s* = \s* (.*);/x) { | ||
$new_value_of{$1} = $2; | ||
} | ||
} | ||
# use Data::Dumper; print Dumper(\%new_value_of); exit(); | ||
|
||
my %replacement_performed_for = (); | ||
|
||
foreach my $file_code (qw/upgrade install admin common plugin/) { | ||
my $filename = $language_dir.'/'.$file_code.'.lang.php'; | ||
# print $filename; | ||
if (not -f $filename) { | ||
# print ' is missing', "\n"; | ||
next; | ||
} | ||
print $filename.' is under process', "\n"; | ||
|
||
my $file_content = ''; | ||
|
||
open(my $ifh, '<'.$filename); | ||
while (my $line = <$ifh>) { | ||
if ($line =~ m/^\$lang\['(.*)'\] \s* =/x) { | ||
if (defined $new_value_of{$1}) { | ||
$file_content.= '$lang[\''.$1.'\'] = '.$new_value_of{$1}.';'."\n"; | ||
$replacement_performed_for{$1}++; | ||
} | ||
else { | ||
$file_content.= $line; | ||
} | ||
} | ||
elsif ($line =~ m/^?>/) { | ||
$file_content.= $line; | ||
} | ||
else { | ||
$file_content.= $line; | ||
} | ||
} | ||
close($ifh); | ||
|
||
open(my $ofh, '>'.$filename); | ||
print {$ofh} $file_content; | ||
close($ofh); | ||
} | ||
|
||
foreach my $new_value (keys %new_value_of) { | ||
if (not defined $replacement_performed_for{$new_value}) { | ||
print 'no replacement performed on: ', $new_value, "\n"; | ||
} | ||
} |