Current location: Hot Scripts Forums » Programming Languages » PHP » Find strings which contain *


Find strings which contain *

Reply
  #1 (permalink)  
Old 09-23-09, 05:46 AM
noXy noXy is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Find strings which contain *

Hey again.

I'm trying to do translation for one web manageing system. I use Gtranslate to do so, all translations stored in files. And I never worked with files before. I'm trying to seperate all strings which contains

msgid "(original text in example)"

and there is over 4000 strings like this one, and loads of other text, could anyone give me an idea, how to get all these strings ? with no msgid " " just a texts between double quotes and nothing more.

I tryed to use strpos, but I'm able to get only one(first) line

Please help me.

Cheers

Last edited by noXy; 09-23-09 at 05:48 AM.
Reply With Quote
  #2 (permalink)  
Old 09-23-09, 06:18 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Please post your code.
Reply With Quote
  #3 (permalink)  
Old 09-23-09, 06:24 AM
noXy noXy is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
the part of file that I need to get organised is:

#: plugins/ktcore/admin/deletedDocuments.php:237
#, php-format
msgid "%d documents restored." //////////////////////////english
msgstr "%d документы восстановлены." //////////////////////////russian

#: plugins/ktstandard/KTSubscriptions.php:427
#, php-format
msgid "%d successful, %d failures"
msgstr "%d удачно, %d не удачно"

#: lib/metadata/metadatautil.inc.php:565
#, php-format
msgid "%d values for the Master Field are not assigned to behaviours."
msgstr "%d значений Основного Поля не ассоциировано."

#: plugins/ktcore/admin/workflows.php:1261
#, php-format
msgid "%s (%s)"
msgstr "%s (%s)"

#: lib/mime.inc.php:118
#: lib/widgets/fieldsetDisplay.inc.php:149
#, php-format
msgid "%s File"
msgstr "%s Файл"

from these lines I need to get only what is between msgid " and "

I never worked with files, so I don't even know am I suposed to use fopen() or file_get_contents()

At least is it possible to get copyed strings which contains msgid "" ? All of them..
Reply With Quote
  #4 (permalink)  
Old 09-23-09, 06:36 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Command line:

grep msgid file | cut -f2 -d'"'
Reply With Quote
  #5 (permalink)  
Old 09-23-09, 06:38 AM
noXy noXy is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
I tryed loads of times to get it sorted with simple functions, but as I think, I need to make a session or use while() but I don't know hot to, I'm kinda newbie at php
Reply With Quote
  #6 (permalink)  
Old 09-23-09, 06:40 AM
noXy noXy is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks for a reply, I'll try to use it, and will let you know if it worked.
Reply With Quote
  #7 (permalink)  
Old 09-23-09, 06:48 AM
noXy noXy is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
is it suposed to look something like

PHP Code:

$fopen fopen($failas'r');



$d preg_grep(msgid,$fopen cut -f2 -d'"');
echo 
"$d"
?

it gives me an error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/la2game/public_html/t.php on line 30


whole file code is
PHP Code:



header 
('Content-type: text/html; charset=utf-8');


$id $_POST['id'];
$failas $_POST['t'];
if(!isset(
$id))
{
echo 
"Failo pavadinimas:<br><form action='t.php' method='post'>
<input type='text' name='t'><input type='hidden' name='id' value='tesiam'><br>
<input type='submit' value='Testi'>"
;
}
if(
$id=='tesiam')
{
if(isset(
$failas))
{
echo 
"Ieskomas failas: $failas<br>";
if(
file_exists($failas))
{
echo 
"<br>Failas $failas rastas";
 
$turinys file_get_contents("$failas");
$fopen fopen($failas'r');


$d preg_grep(msgid,$fopen cut -f2 -d'"');
echo 
"$d";
}
}


if(!isset(
$failas))
{
echo 
"Neyvestas failo pavadinimas.";
}
if(!
file_exists($failas))
{
echo 
"Toks failas neegzistuoja";
}
}



   
 
 
 

 
 
?> 



whole file code is

Last edited by noXy; 09-23-09 at 06:55 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
find node in a heap UnrealEd Everything Java 0 11-20-07 03:48 AM
php extension problem UnrealEd Web Servers 6 09-18-06 05:31 AM
How to find the total number of subnodes in a tree structure? subhashparayil ASP 2 03-22-06 11:44 AM
how to solve this PHP error? j14nhAo PHP 1 02-16-06 07:48 AM
strings in a mysql row Aesis PHP 8 08-18-04 02:33 AM


All times are GMT -5. The time now is 08:00 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.