Static content works fine, but when i use:
$r = mysqli_query($dbc,"select name from table");
while($row = mysqli_fetch_array($r)){
echo gettext($row['name']);
}
Poedit doesnt recognizes the dynamic content which i fully understand.
But is there a workaround for this?
The workflow of gettext is based on the fact that you markup your source code with defined function calls, e.g. gettext('string to localise')
. This source code can be parsed automatically and all the localisable strings can be extracted into a POT file. Obviously, as you say, this doesn't work if the strings you want to localise aren't actually in your source code. In this case, you need to bridge that extraction step manually.
All you really need to do is to produce a file in POT format which contains all your strings. This should be relatively easy with a short PHP script which reads your database contents and outputs the relevant entries into a POT file. Since POT is such a widely supported format, there are a number of PHP libraries which can easily produce this output for you; you mostly just need to write a database query and loop around it. Search your favourite open source repository and you'll find something that fits your needs.
From there you can either concatenate that POT file into your other POT file, or you can keep it as a separate translation file. You should certainly take care to use the proper gettext workflow to make sure you're never overwriting anything with your changes:
msgmerge