Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SDK
KDE Development Scripts
Commits
a34fb5fe
Commit
a34fb5fe
authored
May 24, 2013
by
David Faure
Browse files
Add option to keep i18n().
parent
86abc3b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
kf5/convert-kcmdlineargs.pl
View file @
a34fb5fe
...
...
@@ -7,6 +7,11 @@ use strict;
use
File::
Basename
;
use
lib
dirname
(
$
0
);
use
functionUtilkde
;
my
$use_tr
;
# Set $use_tr to generate code that uses QCoreApplication::translate
# If it's not set, i18n will be used.
#$use_tr = 1;
foreach
my
$file
(
@ARGV
)
{
my
$context
=
"
\"
main
\"
";
...
...
@@ -20,18 +25,20 @@ foreach my $file (@ARGV) {
$opt
=
$
1
;
s/KCmdLineOptions /QCommandLineParser \*/
;
s/$opt/parser = new QCommandLineParser/
;
$_
.=
"
parser->addVersionOption(INSERT_VERSION_NUMBER_HERE);
\n
";
$_
.=
"
app.setApplicationVersion(INSERT_VERSION_HERE);
\n
";
$_
.=
"
parser->addVersionOption();
\n
";
$_
.=
"
parser->addHelpOption(INSERT_DESCRIPTION_HERE);
\n
";
}
elsif
(
defined
$opt
&&
/KCmdLineArgs::addCmdLineOptions\s*\(\s*$opt\s*\)/
||
/KCmdLineArgs::init/
)
{
$_
=
"";
}
elsif
(
defined
$opt
&&
/(.*)$opt.add\s*\(\s*"([^\"]*)"\s*\)/
)
{
# short option
$_
=
"";
$short
=
"
\"
$2
\"
<<
";
}
elsif
(
defined
$opt
&&
/(.*)$opt.add\s*\(\s*"([^\"]*)"\s*,\s*ki18n\((.*)\)\s*(?:,\s*([^\)]*))?\)/
)
{
}
elsif
(
defined
$opt
&&
/(.*)$opt.add\s*\(\s*"([^\"]*)"\s*,\s*k
(
i18n
c?)
\((.*)\)\s*(?:,\s*([^\)]*))?\)/
)
{
my
$prefix
=
$
1
;
# e.g. indent
my
$name
=
$
2
;
my
$description
=
$
3
;
my
$defaultValue
=
$
4
;
my
$i18n
=
$
3
;
my
$description
=
$
4
;
my
$defaultValue
=
$
5
;
my
$trail
=
"";
if
(
$name
=~
/(\w*) <(.*)>/
)
{
# "stylesheet <xsl>"
$name
=
$
1
;
...
...
@@ -42,7 +49,8 @@ foreach my $file (@ARGV) {
}
elsif
(
$name
=~
/^no/
)
{
# negative option, e.g. --nosignal
$negatedOptions
{
$name
}
=
1
;
}
$_
=
"
${prefix}
parser->addOption(QCommandLineOption(QStringList() <<
$short
\"
$name
\"
, QCoreApplication::translate(
$context
,
$description
)
$trail
));
\n
";
my
$translate
=
defined
$use_tr
?
"
QCoreApplication::translate(
$context
,
$description
)
"
:
"
$i18n
(
$description
)
";
$_
=
"
${prefix}
parser->addOption(QCommandLineOption(QStringList() <<
$short
\"
$name
\"
,
$translate$trail
));
\n
";
$short
=
"";
}
elsif
(
/KCmdLineArgs\s*\*(\w*)\s*=\s*KCmdLineArgs::parsedArgs\(\s*\)/
)
{
$args
=
$
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment