I need to use sed to:
Replace Strings Such as:
tr("Text");
TO
"text";
tr("Textfsafasfsfas
safasdfsafas");
TO
"Textfsafasfsfas
safasdfsafas";
foo(tr("text"));
TO
foo("text");
Do Not Replace these Strings:
tr("text").arg(text);
tr("I am some text")
.arg(i do stuff);
tr("I am some text")
.arg(i do stuff)
.arg(I also do stuff);
where it needs to be handled from 1 up to n lines of this.
My current code does not cover the multi-line .arg
edge case. Any bright ideas?
Current sed code:
sed -i '/\btr(/{ :a; s/\btr(\([^)]*\))\([^.]\)/\1\2/I; t; N; ba}' $file_t
Edit:
errors << tr("Error: Encountered an invalid token at line: %1, column: %2.")
.arg(m_reader.lineNumber())
.arg(m_reader.columnNumber());
is an edge-case that is still an issue at this time.
.arg()
usage. Can you do this in two passes?.arg
not on the first line thetr
with paren. will be deleted. It would be more trouble than it's worth trying to put that back in on the second pass