This is a discussion on need help with gettext i18n within the PHP General forums, part of the PHP Programming Forums category; Hi there, I am trying to get I18n support working on my site. To do this I have isntalled gettext. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi there,
I am trying to get I18n support working on my site. To do this I have isntalled gettext. Somehow the translation does not work. I did everything the examples explained, but I do stillg get en text. Here is what I did. 1. I creaed a test file: <?php // I18N support information here $language = 'de'; putenv("LANG=$language"); setlocale(LC_ALL, $language); // Set the text domain as 'messages' $domain = 'messages'; bindtextdomain($domain, "/home/www/mydocs/x_dev/sprachen/gettext/locale"); textdomain($domain); echo gettext("A string to be translated would go here"); ?> 2. I extracted the text via command line: xgettext -a test.php 3. I translated it and created a mo file with poedit (editor) 4. I moved the files into a de directory /locale /de /LC_MESSAGES messages.po When I load the php file in the browser it still gives me the entlish language. Has anybody an idea on what I am doing wrong? Thank you for any help on that, Merlin |
|
|||
|
Hi,
Tuesday, November 25, 2003, 2:25:33 AM, you wrote: M> Hi there, M> I am trying to get I18n support working on my site. To do this I have M> isntalled gettext. M> Somehow the translation does not work. I did everything the examples M> explained, but I do stillg get en text. M> Here is what I did. M> 1. I creaed a test file: M> <?php M> // I18N support information here M> $language = 'de'; M> putenv("LANG=$language"); M> setlocale(LC_ALL, $language); M> // Set the text domain as 'messages' M> $domain = 'messages'; M> bindtextdomain($domain, "/home/www/mydocs/x_dev/sprachen/gettext/locale"); M> textdomain($domain); M> echo gettext("A string to be translated would go here"); ?>> M> 2. I extracted the text via command line: M> xgettext -a test.php M> 3. I translated it and created a mo file with poedit (editor) M> 4. I moved the files into a de directory M> /locale M> /de M> /LC_MESSAGES M> messages.po M> When I load the php file in the browser it still gives me the entlish M> language. M> Has anybody an idea on what I am doing wrong? M> Thank you for any help on that, M> Merlin If on linux you may need to generate the right files with something like: localedef -ci de_DE -f ISO_8859-1:1987 de_DE Then restart apache as it caches locale info I think -- regards, Tom |
|
|||
|
On Mon, Nov 24, 2003 at 09:42:30PM -0800, Joffrey Leevy wrote:
: : Would appreciate in anyone can help me. Some more code would be helpful. : Let's say I do a query in php, eg. $query = "select : shed from structure"; With the mysql_fetch_array : function and a loop I could see all the values stored : in the column, shed, using the command: echo $shed; $query = "select shed from structure"; $result = mysql_query($query); while (($row = mysql_fetch_array($result)) !== false) { echo $row['shed']; } : Let's say now that I am carrying over a variable from : a form called $form where $form = shed. I can still : say $query = "select $form from structure"; because : $form = shed. Try using more variables to make life a little easier to parse: $colname = $_FORM['form'] $query = "select {$colname} from structure"; $result = mysql_query($query); while (($row = mysql_fetch_array($result)) !== false) { echo $row[$colname]; } : The problem I have now is with the strings and how do : I see my column values. Use better variable names. And avoid register_globals. |
|
|||
|
Eugene Lee wrote:
> Try using more variables to make life a little easier to parse: > > $colname = $_FORM['form'] > $query = "select {$colname} from structure"; > $result = mysql_query($query); > while (($row = mysql_fetch_array($result)) !== false) > { > echo $row[$colname]; > } > Very dangerous. $colname can be anything, e.g. "mysql.user.password colname FROM mysql.user #" |
|
|||
|
On Tue, Nov 25, 2003 at 11:38:27AM +0100, Marek Kilimajer wrote:
: Eugene Lee wrote: : > : >Try using more variables to make life a little easier to parse: : > : > $colname = $_FORM['form'] : > $query = "select {$colname} from structure"; : > $result = mysql_query($query); : > while (($row = mysql_fetch_array($result)) !== false) : > { : > echo $row[$colname]; : > } : > : : Very dangerous. $colname can be anything, e.g. "mysql.user.password : colname FROM mysql.user #" I wrote it out this way because: the other user provided no source code, I wanted to show working code, it was late and I didn't feel like adding anything to secure against intrusions like SQL injection attacks. For the sake of completeness, redo the first line above as: $colname = mysql_escape_string($_FORM['form']); |
|
|||
|
Hey thanks guys. Problem solved.
--- Eugene Lee <list-php-1@fsck.net> wrote: > On Tue, Nov 25, 2003 at 11:38:27AM +0100, Marek > Kilimajer wrote: > : Eugene Lee wrote: > : > > : >Try using more variables to make life a little > easier to parse: > : > > : > $colname = $_FORM['form'] > : > $query = "select {$colname} from structure"; > : > $result = mysql_query($query); > : > while (($row = mysql_fetch_array($result)) !== > false) > : > { > : > echo $row[$colname]; > : > } > : > > : > : Very dangerous. $colname can be anything, e.g. > "mysql.user.password > : colname FROM mysql.user #" > > I wrote it out this way because: the other user > provided no source code, > I wanted to show working code, it was late and I > didn't feel like adding > anything to secure against intrusions like SQL > injection attacks. For > the sake of completeness, redo the first line above > as: > > $colname = mysql_escape_string($_FORM['form']); > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ |
|
|||
|
Eugene Lee wrote:
> On Tue, Nov 25, 2003 at 11:38:27AM +0100, Marek Kilimajer wrote: > : Eugene Lee wrote: > : > > : >Try using more variables to make life a little easier to parse: > : > > : > $colname = $_FORM['form'] > : > $query = "select {$colname} from structure"; > : > $result = mysql_query($query); > : > while (($row = mysql_fetch_array($result)) !== false) > : > { > : > echo $row[$colname]; > : > } > : > > : > : Very dangerous. $colname can be anything, e.g. "mysql.user.password > : colname FROM mysql.user #" > > I wrote it out this way because: the other user provided no source code, > I wanted to show working code, it was late and I didn't feel like adding > anything to secure against intrusions like SQL injection attacks. For > the sake of completeness, redo the first line above as: > > $colname = mysql_escape_string($_FORM['form']); > That does not help at all, there is no character to be escaped in "mysql.user.password colname FROM mysql.user #". The strig would have to be in quotes, and column name cannot be in qoutes. |