Re: [PHP] software localization with PHP

2001-08-02 Thread Colin Viebrock

I was just looking through the mailing list archives for some help
with my gettext problem (basically, I can't get it to work).

Anyway, I came across your post:

 Thanks for the reply.  This will not solve my problem.  The problem is,
for some
 languages the sentence structure may be different.  For example, the
sentence
 may need to be,
 $greeting = $first_name, welcome!
 as opposed to,
$greeting = Welcome, $first_name!

This can be handled by gettext.  Change your english code to something like:

$greeting = sprintf( gettext(Welcome, %s!), $first_name );

Once you run xgettext to extract all the strings, you'll end up with

msgid Welcome, %s!
msgstr 

So just convert it into whatever language, and move the %s as needed, eg:

msgstr %s, bonjour!

This even works with multiple %s's, in later versions of PHP where you can
rearrange the arguments in the format string, but not the way they are
passed
to sprintf():

msgid %s is %d years old
msgstr $2%d Jahrs habe $1%s

Check www.php.net/sprintf for details.

Hope that helps.

- Colin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] software localization with PHP

2001-03-14 Thread Tao

Kevin,

Thanks for the reply.  This will not solve my problem.  The problem is, for some
languages the sentence structure may be different.  For example, the sentence
may need to be,
$greeting = "$first_name, welcome!"
as opposed to,
$greeting = "Welcome, $first_name!"

Or, it can come in a different form, like,
$greeting = "Good morning, $first_name."

These specificity need to be in the language file, not the scripts.

Tao


Leavell Digital Design wrote:

 You can use constants:

 in your language file
 define("HELLO", OLA);

 in your script  which includes the language file you can write
 $greeting = HELLO . " $first_name";

 print $greeting;

 Kevin Leavell
 [EMAIL PROTECTED]
 P 406.829.8989
 C 406.240.4595

 --- -Original Message-
 --- From: Tao [mailto:[EMAIL PROTECTED]]
 --- Sent: Tuesday, March 13, 2001 9:50 PM
 --- To: [EMAIL PROTECTED]
 --- Subject: [PHP] software localization with PHP
 ---
 ---
 --- Hi all,
 ---
 --- I have a question about localizing PHP scripts.  I understand
 --- that for basic
 --- localization one can have a "strings" file for each language,
 --- which contains
 --- string variables and values such as:
 --- ?php
 --- $title = "Welcome!";
 --- $error = "An error occurred.";
 --- ?
 ---
 --- Then, in the scripts just "include" the language file at the
 --- beginning and
 --- simply call the strings by their variable names.  The issue I
 --- have is when
 --- embedding variables within these strings.  Suppose I need to
 --- call the user
 --- by his/her first name, in the strings file I would have a variable like
 --- this:
 --- $greeting = "Welcome! $first_name";
 ---
 --- The problem is, the strings file is loaded at the beginning of
 --- the script
 --- before $first_name was set, so the $greeting string will come out as
 --- "Welcome! ", with $first_name being an empty string.  Even if
 --- I loaded the
 --- strings file after the $first_name variable is set, the problem still
 --- remains - when $first_name variable is changed, the strings
 --- file has to be
 --- reloaded.
 ---
 --- What is the best way of dealing with this problem?  Is there a
 --- place to find
 --- "best practices" on localizing PHP software?
 ---
 --- Tao
 ---
 ---
 ---
 --- --
 --- PHP General Mailing List (http://www.php.net/)
 --- To unsubscribe, e-mail: [EMAIL PROTECTED]
 --- For additional commands, e-mail: [EMAIL PROTECTED]
 --- To contact the list administrators, e-mail:
 --- [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] software localization with PHP

2001-03-14 Thread Tao

Kevin,

Thanks for the reply.  This will not solve my problem.  The problem is, for some
languages the sentence structure may be different.  For example, the sentence
may need to be,
$greeting = "$first_name, welcome!"
as opposed to,
$greeting = "Welcome, $first_name!"

Or, it can come in a different form, like,
$greeting = "Good morning, $first_name."

These specificity need to be in the language file, not the scripts.

Tao


Leavell Digital Design wrote:

 You can use constants:

 in your language file
 define("HELLO", OLA);

 in your script  which includes the language file you can write
 $greeting = HELLO . " $first_name";

 print $greeting;

 Kevin Leavell
 [EMAIL PROTECTED]
 P 406.829.8989
 C 406.240.4595

 --- -Original Message-
 --- From: Tao [mailto:[EMAIL PROTECTED]]
 --- Sent: Tuesday, March 13, 2001 9:50 PM
 --- To: [EMAIL PROTECTED]
 --- Subject: [PHP] software localization with PHP
 ---
 ---
 --- Hi all,
 ---
 --- I have a question about localizing PHP scripts.  I understand
 --- that for basic
 --- localization one can have a "strings" file for each language,
 --- which contains
 --- string variables and values such as:
 --- ?php
 --- $title = "Welcome!";
 --- $error = "An error occurred.";
 --- ?
 ---
 --- Then, in the scripts just "include" the language file at the
 --- beginning and
 --- simply call the strings by their variable names.  The issue I
 --- have is when
 --- embedding variables within these strings.  Suppose I need to
 --- call the user
 --- by his/her first name, in the strings file I would have a variable like
 --- this:
 --- $greeting = "Welcome! $first_name";
 ---
 --- The problem is, the strings file is loaded at the beginning of
 --- the script
 --- before $first_name was set, so the $greeting string will come out as
 --- "Welcome! ", with $first_name being an empty string.  Even if
 --- I loaded the
 --- strings file after the $first_name variable is set, the problem still
 --- remains - when $first_name variable is changed, the strings
 --- file has to be
 --- reloaded.
 ---
 --- What is the best way of dealing with this problem?  Is there a
 --- place to find
 --- "best practices" on localizing PHP software?
 ---
 --- Tao
 ---
 ---
 ---
 --- --
 --- PHP General Mailing List (http://www.php.net/)
 --- To unsubscribe, e-mail: [EMAIL PROTECTED]
 --- For additional commands, e-mail: [EMAIL PROTECTED]
 --- To contact the list administrators, e-mail:
 --- [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] software localization with PHP

2001-03-14 Thread Maciek Uhlig

Check http://stphp.sourceforge.net

Maciek

 -Original Message-
 From: Tao [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, March 14, 2001 8:14 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP] software localization with PHP


 Kevin,

 Thanks for the reply.  This will not solve my problem.  The
 problem is, for some
 languages the sentence structure may be different.  For example,
 the sentence
 may need to be,
 $greeting = "$first_name, welcome!"
 as opposed to,
 $greeting = "Welcome, $first_name!"

 Or, it can come in a different form, like,
 $greeting = "Good morning, $first_name."

 These specificity need to be in the language file, not the scripts.

 Tao


 Leavell Digital Design wrote:

  You can use constants:
 
  in your language file
  define("HELLO", OLA);
 
  in your script  which includes the language file you can write
  $greeting = HELLO . " $first_name";
 
  print $greeting;
 
  Kevin Leavell
  [EMAIL PROTECTED]
  P 406.829.8989
  C 406.240.4595
 
  --- -Original Message-
  --- From: Tao [mailto:[EMAIL PROTECTED]]
  --- Sent: Tuesday, March 13, 2001 9:50 PM
  --- To: [EMAIL PROTECTED]
  --- Subject: [PHP] software localization with PHP
  ---
  ---
  --- Hi all,
  ---
  --- I have a question about localizing PHP scripts.  I understand
  --- that for basic
  --- localization one can have a "strings" file for each language,
  --- which contains
  --- string variables and values such as:
  --- ?php
  --- $title = "Welcome!";
  --- $error = "An error occurred.";
  --- ?
  ---
  --- Then, in the scripts just "include" the language file at the
  --- beginning and
  --- simply call the strings by their variable names.  The issue I
  --- have is when
  --- embedding variables within these strings.  Suppose I need to
  --- call the user
  --- by his/her first name, in the strings file I would have a
 variable like
  --- this:
  --- $greeting = "Welcome! $first_name";
  ---
  --- The problem is, the strings file is loaded at the beginning of
  --- the script
  --- before $first_name was set, so the $greeting string will
 come out as
  --- "Welcome! ", with $first_name being an empty string.  Even if
  --- I loaded the
  --- strings file after the $first_name variable is set, the
 problem still
  --- remains - when $first_name variable is changed, the strings
  --- file has to be
  --- reloaded.
  ---
  --- What is the best way of dealing with this problem?  Is there a
  --- place to find
  --- "best practices" on localizing PHP software?
  ---
  --- Tao
  ---
  ---
  ---
  --- --
  --- PHP General Mailing List (http://www.php.net/)
  --- To unsubscribe, e-mail: [EMAIL PROTECTED]
  --- For additional commands, e-mail: [EMAIL PROTECTED]
  --- To contact the list administrators, e-mail:
  --- [EMAIL PROTECTED]
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] software localization with PHP

2001-03-14 Thread Don Read


On 14-Mar-01 Tao wrote:
 Kevin,
 
 Thanks for the reply.  This will not solve my problem.  The problem is, for
 some
 languages the sentence structure may be different.  For example, the
 sentence
 may need to be,
 $greeting = "$first_name, welcome!"
 as opposed to,
 $greeting = "Welcome, $first_name!"
 
 Or, it can come in a different form, like,
 $greeting = "Good morning, $first_name."
 
 These specificity need to be in the language file, not the scripts.
 
 Tao
 

I use a MySQL table to localis(z)e both words  printf formats:

+---+--++---+
| catid | lang | strid  | strval|
+---+--++---+
|   | de   | Statistics for | Stand vom %s  |
|   | de   | Statistics | Statistik |
|   | sv   | Statistics | Statistik |
|   | en   | Statistics for | Statistics for %s |
|   | en   | Statistics | Statistics|
|   | sv   | Statistics for | Statistik för %s  |
+---+--++---+

+---+--+---++
| catid | lang | strid | strval /
+---+--+---++
|   | en   | Topsignupurls | Top %d signup URL's for %s |
|   | de   | Topsignupurls | Ãbersteigen Sie %d signup URL's für %s |
|   | sv   | Topsignupurls | Topp %d försäljnings URLs  för %s  |
+---+--+---++

If the phrase structure is likely to be different, you store the printf
specification as well. example:

body_beg(SITENAME.' '.nls('Statistics')); // title  open body
...
$ds=formatdate($dte); // localized date string
...
printf('H5' .nls('Statistics for') ."/H5\n", $ds);
...
printf('H5'.nls('Topsignupurls').' /H5', 30, $ds);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- If you are going to sin, sin against God, not the bureaucracy. 
  God will forgive you but the bureaucrats won't. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] software localization with PHP

2001-03-13 Thread Tao

Hi all,

I have a question about localizing PHP scripts.  I understand that for basic
localization one can have a "strings" file for each language, which contains
string variables and values such as:
?php
$title = "Welcome!";
$error = "An error occurred.";
?

Then, in the scripts just "include" the language file at the beginning and
simply call the strings by their variable names.  The issue I have is when
embedding variables within these strings.  Suppose I need to call the user
by his/her first name, in the strings file I would have a variable like
this:
$greeting = "Welcome! $first_name";

The problem is, the strings file is loaded at the beginning of the script
before $first_name was set, so the $greeting string will come out as
"Welcome! ", with $first_name being an empty string.  Even if I loaded the
strings file after the $first_name variable is set, the problem still
remains - when $first_name variable is changed, the strings file has to be
reloaded.

What is the best way of dealing with this problem?  Is there a place to find
"best practices" on localizing PHP software?

Tao



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] software localization with PHP

2001-03-13 Thread Leavell Digital Design

You can use constants:

in your language file
define("HELLO", OLA);

in your script  which includes the language file you can write
$greeting = HELLO . " $first_name";

print $greeting;


Kevin Leavell
[EMAIL PROTECTED]
P 406.829.8989
C 406.240.4595

--- -Original Message-
--- From: Tao [mailto:[EMAIL PROTECTED]]
--- Sent: Tuesday, March 13, 2001 9:50 PM
--- To: [EMAIL PROTECTED]
--- Subject: [PHP] software localization with PHP
---
---
--- Hi all,
---
--- I have a question about localizing PHP scripts.  I understand
--- that for basic
--- localization one can have a "strings" file for each language,
--- which contains
--- string variables and values such as:
--- ?php
--- $title = "Welcome!";
--- $error = "An error occurred.";
--- ?
---
--- Then, in the scripts just "include" the language file at the
--- beginning and
--- simply call the strings by their variable names.  The issue I
--- have is when
--- embedding variables within these strings.  Suppose I need to
--- call the user
--- by his/her first name, in the strings file I would have a variable like
--- this:
--- $greeting = "Welcome! $first_name";
---
--- The problem is, the strings file is loaded at the beginning of
--- the script
--- before $first_name was set, so the $greeting string will come out as
--- "Welcome! ", with $first_name being an empty string.  Even if
--- I loaded the
--- strings file after the $first_name variable is set, the problem still
--- remains - when $first_name variable is changed, the strings
--- file has to be
--- reloaded.
---
--- What is the best way of dealing with this problem?  Is there a
--- place to find
--- "best practices" on localizing PHP software?
---
--- Tao
---
---
---
--- --
--- PHP General Mailing List (http://www.php.net/)
--- To unsubscribe, e-mail: [EMAIL PROTECTED]
--- For additional commands, e-mail: [EMAIL PROTECTED]
--- To contact the list administrators, e-mail:
--- [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]