[graphics/krita] /: Add more resource types to be translated
Alvin Wong
null at kde.org
Tue Jul 13 13:11:16 BST 2021
Git commit 151aadd4ebd5301a5fec6edf0d28d7c1779ea20e by Alvin Wong, on behalf of Agata Cacko.
Committed on 13/07/2021 at 12:09.
Pushed by alvinwong into branch 'master'.
Add more resource types to be translated
Before this commit, only gradients, palettes and potentially
brush tips could be translated.
This commit adds some other files types like .kpp presets,
.kwl window layouts, .kws workspaces, .kgm gamutmasks,
.png patterns, .myb presets and .svg symbol libraries
and brush tips.
CCMAIL:kde-i18n-doc at kde.org
CCMAIL:kimageshop at kde.org
M +65 -1 extracti18n.pl
https://invent.kde.org/graphics/krita/commit/151aadd4ebd5301a5fec6edf0d28d7c1779ea20e
diff --git a/extracti18n.pl b/extracti18n.pl
old mode 100755
new mode 100644
index 6a6bf8d4ae..dee34d47ac
--- a/extracti18n.pl
+++ b/extracti18n.pl
@@ -21,11 +21,41 @@ sub printi18n($$$$) {
}
}
+sub parseFromFilenameAuto($) {
+ my $name = $_[0];
+ my @extensions = split(/\./, $name);
+ my $extension = $extensions[$#extensions];
+ return parseFromFilename($name, $extension);
+}
+
+sub parseFromFilename($$) {
+ my $name = $_[0];
+ my $extension = $_[1];
+ chomp($name);
+ my @path = split(/\//, $name);
+ $name = $path[$#path];
+ $name =~ s/_/ /g;
+ if( $extension ne "" ) {
+ $name =~ s/\.${extension}$//g;
+ }
+ return $name;
+}
+
my @filenames = glob("./krita/data/gradients/*.ggr");
push( @filenames, glob("./krita/data/palettes/*.gpl"));
push( @filenames, glob("./krita/data/brushes/*.gih"));
push( @filenames, glob("./krita/data/brushes/*.gbr"));
+push( @filenames, glob("./krita/data/brushes/*.svg"));
push( @filenames, glob("./krita/data/patterns/*.pat"));
+push( @filenames, glob("./krita/data/patterns/*.png"));
+push( @filenames, glob("./krita/data/paintoppresets/*.kpp"));
+push( @filenames, glob("./krita/data/workspaces/*.kws"));
+push( @filenames, glob("./krita/data/windowlayouts/*.kwl"));
+push( @filenames, glob("./krita/data/gamutmasks/*.kgm"));
+push( @filenames, glob("./plugins/paintops/mypaint/brushes/*.myb"));
+push( @filenames, glob("./krita/data/symbols/*.svg"));
+
+
foreach my $filename (@filenames)
{
unless ( open(FILE, '<'.$filename) )
@@ -50,6 +80,36 @@ foreach my $filename (@filenames)
printi18n($name, $filename, $filename, 1);
}
}
+ elsif( $filename =~ /svg$/ )
+ {
+ my @lines = <FILE>;
+ my $svg = join('', @lines);
+ my $name = "";
+ if( $svg =~ m:(<title.*?</title>):s )
+ {
+ my $titlesvg = $1;
+ if( $titlesvg =~ m:>(.*?)</title>:s ) #not perfect, but should usually do a good job, at least for existing libraries
+ {
+ $name = $1;
+ chomp($name);
+ $name =~ s/&/&/; # 'Pepper & Carrot Speech Bubbles' needs it
+ }
+ }
+ if ($name eq "")
+ {
+ $name = parseFromFilenameAuto($filename);
+ }
+ printi18n($name, $filename, $filename, -1);
+ }
+ elsif( $filename =~ /kpp$/ || $filename =~ /kws$/ || $filename =~ /kwl$/ || $filename =~ /kgm$/ || $filename =~ /jpg$/ || $filename =~ /myb$/ || $filename =~ /png$/)
+ {
+ # all of Krita's default brush presets and other resources with abovementioned extensions
+ # are named the same way the file is called
+ # so there is no need to parse the file itself to find the name inside of it
+ my $extension = split(/\./, $filename);
+ my $name = parseFromFilenameAuto($filename);
+ printi18n($name, $filename, $filename, -1); # sadly, I'm not sure what the last number means exactly
+ }
else
{
if( $filename =~ /gbr/ )
@@ -71,12 +131,16 @@ foreach my $filename (@filenames)
printi18n($name, $filename, $filename, -1);
}
}
- else
+ elsif( $filename =~ /pat$/ )
{
read(FILE, my $bytes, 4);
my $size = unpack("N", $bytes);
read(FILE, $bytes, 20);
read(FILE, my $name, $size - 25);
+ if( $name eq "" )
+ {
+ $name = parseFromFilenameAuto($filename);
+ }
printi18n($name, $filename, $filename, -1);
}
}
More information about the kde-i18n-doc
mailing list