Need help writing regex to clear all translated strings in files

Having a question about translating phpBB 3.3? Want to discuss and collaborate with people currently translating phpBB 3.3? Here would be the correct place to do so.
User avatar
scootergrisen
Translator
Posts: 257
Joined: Thu Aug 25, 2011 2:25 pm

Need help writing regex to clear all translated strings in files

Post by scootergrisen »

Can someone help me write a regex that I can use (In Notepad++) to search/replace all strings in the translations files so they are removed.

So that I end up with files that just have the PHP code but the values (translation strings) are empty.

From:

Code: Select all

	'A'		=> 'One line of text'
	'B'		=> 'Some
    text
    with newlines'
	'C'		=> 'Some text with \' that also needs to work'
	'D'		=> 'More text'
To:

Code: Select all

	'A'		=> ''
	'B'		=> ''
	'C'		=> ''
	'D'		=> ''
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3886
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Need help writing regex to clear all translated strings in files

Post by Kailey »

Under the Replace tab:

Find what:

Code: Select all

=> '(?:[^\\']|\\\\|\\')*'
Replace with:

Code: Select all

=> ''
notepadplusplus.png

Make sure you check the radio button for Regular expression.
You do not have the required permissions to view the files attached to this post.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
User avatar
scootergrisen
Translator
Posts: 257
Joined: Thu Aug 25, 2011 2:25 pm

Re: Need help writing regex to clear all translated strings in files

Post by scootergrisen »

Thanks that helped a lot.
How are you able to figure out how to write that?
User avatar
scootergrisen
Translator
Posts: 257
Joined: Thu Aug 25, 2011 2:25 pm

Re: Need help writing regex to clear all translated strings in files

Post by scootergrisen »

The regex is fine.
But in case you want to improve it there is a few strings that it don't work for.

Where there is an inline comment with a '.

And there is one with $lang['CLI_DESCRIPTION_CRON_RUN'].

Code: Select all

		0	=> '', // zero means no limit, so we don't view a message here.

	'CLI_HELP_CRON_RUN'			=> $lang['CLI_DESCRIPTION_CRON_RUN'] . ' Optionally you can specify a cron task name to run only the specified cron task.',
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3886
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Need help writing regex to clear all translated strings in files

Post by Kailey »

scootergrisen wrote: Tue Sep 10, 2024 11:12 am But in case you want to improve it there is a few strings that it don't work for.

Where there is an inline comment with a '.
It should be fine. The regex is based off on this line that you provided in your original post:

Code: Select all

'C'		=> 'Some text with \' that also needs to work'
Edit: Try this one:

Code: Select all

=> ((?:[^\'\\\\]|\\\\\')*)\'/m
scootergrisen wrote: Tue Sep 10, 2024 11:12 am And there is one with $lang['CLI_DESCRIPTION_CRON_RUN'].

Code: Select all

		0	=> '', // zero means no limit, so we don't view a message here.

	'CLI_HELP_CRON_RUN'			=> $lang['CLI_DESCRIPTION_CRON_RUN'] . ' Optionally you can specify a cron task name to run only the specified cron task.',
I don't think there's anything I can do about that one.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders

Return to “[3.3.x] Translations”