Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-28 Thread tedd

At 12:56 AM +0100 11/28/07, Jochem Maas wrote:

Colin Guthrie wrote:

 tedd wrote:


...

 
  Sorry Tedd, but I'm not sure where the browser sniffing stuff came in.

 IE and FF both offer a UI to input the user's preferred language, it's
 an HTTP standard thing and nothign to do with user agents string
 parsing. It uses the Accept-Language header sent with http requests to
 detect the language. It's quite standard but problems usually crop up in
 e.g. Australia and the UK where a lot of people leave the default en-US
 language when en-GB or en-AU would be better. Again it's not infallible
 but it's a fairly good starting point.


ditto.


So, sniffing the browser to determine language isn't the same as 
browser sniffing -- OK.


Sorry, my bad.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-28 Thread Jochem Maas
tedd wrote:
 At 12:56 AM +0100 11/28/07, Jochem Maas wrote:
 Colin Guthrie wrote:
  tedd wrote:

 ...

  
   Sorry Tedd, but I'm not sure where the browser sniffing stuff came in.
  IE and FF both offer a UI to input the user's preferred language, it's
  an HTTP standard thing and nothign to do with user agents string
  parsing. It uses the Accept-Language header sent with http requests to
  detect the language. It's quite standard but problems usually crop
 up in
  e.g. Australia and the UK where a lot of people leave the default en-US
  language when en-GB or en-AU would be better. Again it's not infallible
  but it's a fairly good starting point.

 ditto.
 
 So, sniffing the browser to determine language isn't the same as browser
 sniffing -- OK.

there is no sniffing of the browser - merely a case of parsing the contents of
the Accept-Language header if the browser sent it along with the request 
regardless
of what browser is being used.

there is no reason to assume that anyone would want to spoof the 
Accept-Language header
to contain something that doesn't correspond with what the user wants ... why 
set japanese
as a preferred language if you don't speak it? and if they do do that and end 
up getting a
site in japanese then really that is the users problem not the site developers.

it not the same as ouput different content/layout/etc based on the UserAgent 
string -
which is known to be spoofed in order to combat idiot developers attempts to 
force
people to use certain browser (for whatever reason)

I mean, we don't assume that the requested URL is not what the user really 
wanted?
e.g. user requests example.com/foo.php but we know that it's likely to be 
spoofed so
we'll help out and server them example.com/bar.php ???

besides which I did state that using Accept-Language header to determine a 
[probable]
suitable language should be done in addition to offering the user an explicit 
language
selection mechanism.

lastly I think using GEO-IP services to determine location and thereby an 
implied
language is worthless in general - I can be sitting anywhere on the planet and 
still want
to view content in Dutch, not to mention things like global corporate gateways, 
anonymous
proxies, etc, etc. The exception to this could be when the website in question 
is specifically
offering localised data (e.g. find me a restaurant/garage/whatever in Rotterdam)

 
 Sorry, my bad.

no need for the sarcasm Tedd, seems we have differing opinions on this - 
although my gut
feeling is that your hung up on something that's not strictly relevant in this 
situation.

:-)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-28 Thread Jochem Maas
Jeff Benetti wrote:

...

 Am I correct that if two people are logged on using two different languages
 that the session var will keep track of the different users (by IP I assume)
 and the server won’t mess up?

yes, the contents of $_SESSION are stored per user. this is tracked by way of a
session cookie (which is just another cookie really) that PHP (under normal 
circumstances)
automatically sends and parses (when you call session_start()).

 Anyway thanks everyone for all the great help, I’m on a nearly vertical
 learning curve here and it’s great to have this community to draw on.  I’m
 pretty much working in a vacuum otherwise.
 

any room for that wizard named Brad in your vacuum?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-28 Thread tedd

At 3:01 PM +0100 11/28/07, Jochem Maas wrote:

tedd wrote:
  So, sniffing the browser to determine language isn't the same as browser

 sniffing -- OK.


there is no sniffing of the browser - merely a case of parsing the contents of
the Accept-Language header if the browser sent it along with the 
request regardless

of what browser is being used.

there is no reason to assume that anyone would want to spoof the 
Accept-Language header
to contain something that doesn't correspond with what the user 
wants ... why set japanese
as a preferred language if you don't speak it? and if they do do 
that and end up getting a
site in japanese then really that is the users problem not the site 
developers.


it not the same as ouput different content/layout/etc based on the 
UserAgent string -
which is known to be spoofed in order to combat idiot developers 
attempts to force

people to use certain browser (for whatever reason)

I mean, we don't assume that the requested URL is not what the user 
really wanted?
e.g. user requests example.com/foo.php but we know that it's likely 
to be spoofed so

we'll help out and server them example.com/bar.php ???

besides which I did state that using Accept-Language header to 
determine a [probable]
suitable language should be done in addition to offering the user an 
explicit language

selection mechanism.

lastly I think using GEO-IP services to determine location and 
thereby an implied
language is worthless in general - I can be sitting anywhere on the 
planet and still want
to view content in Dutch, not to mention things like global 
corporate gateways, anonymous
proxies, etc, etc. The exception to this could be when the website 
in question is specifically
offering localised data (e.g. find me a restaurant/garage/whatever 
in Rotterdam)


Thanks for the explanation -- I didn't realize most of that.


  Sorry, my bad.

no need for the sarcasm Tedd, seems we have differing opinions on 
this - although my gut
feeling is that your hung up on something that's not strictly 
relevant in this situation.


:-)


Jochem:

This just hasn't been my week -- everyone (long story) thinks I'm 
being sarcastic when I'm not.


The Sorry, my bad means I apologize, my mistake. How can that be 
taken as sarcasm?


As for being hung-up -- again, I'm clueless. I mistakenly thought 
that anything obtained from the browser was subject to suspicion as 
is any outside data. But apparently you can trust (I realize within 
certain limits) some things provided by the browser -- that's news to 
me.


Boy, I got to work on my communication skills because everyone can't 
be wrong, right?


Again, thanks for your explanation -- and that's not being sarcastic. 
I'm just trying to communicate without offending/annoying anyone. 
Maybe I should end every line with a smiley?  :-)


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-28 Thread Jean-Michel Philippon-Nadeau

Dear Tedd, Dear List,

tedd wrote:
As for being hung-up -- again, I'm clueless. I mistakenly thought that 
anything obtained from the browser was subject to suspicion as is any 
outside data. But apparently you can trust (I realize within certain 
limits) some things provided by the browser -- that's news to me.


You are right. Being suspicious with data coming from the browser is a 
pretty good reflex. But, as long as you use the accept-language header 
only for detecting the user's native language, you do not risk a lot. In 
the worst case, your will set your site's language to something that is 
not the user's native language. In that case, you only need to allow him 
to change this setting manually.


You can base yourself on information provided by the browser, but as you 
say, I believe that we should not rely completely on it. This is why 
allowing the user to change his language, in your case, becomes important.


It's always a balance between risk and usability.

Hope this helps,


Jean-Michel

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-28 Thread Jochem Maas
tedd wrote:
 At 3:01 PM +0100 11/28/07, Jochem Maas wrote:

...

 Jochem:
 
 This just hasn't been my week -- everyone (long story) thinks I'm being
 sarcastic when I'm not.

ouch!

 
 The Sorry, my bad means I apologize, my mistake. How can that be
 taken as sarcasm?

guess it's down to my input filters ;-) not to worry, no feelings were hurt in
the process.

 
 As for being hung-up -- again, I'm clueless. I mistakenly thought that
 anything obtained from the browser was subject to suspicion as is any
 outside data. But apparently you can trust (I realize within certain
 limits) some things provided by the browser -- that's news to me.

your right about the trust issue but I don't think trust is the point in this 
case.
looking at what the browser offered as accepted languages is merely a way of 
trying to
be helpful - you still have to parse the relevant header in a safe way.

 
 Boy, I got to work on my communication skills because everyone can't be
 wrong, right?

let's be positive, next week it will be better!

 
 Again, thanks for your explanation -- and that's not being sarcastic.
 I'm just trying to communicate without offending/annoying anyone. Maybe
 I should end every line with a smiley?  :-)

dunno about that smiley, it might become annoying ;-)

 
 Cheers,
 
 tedd
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-28 Thread Jochem Maas
Jean-Michel Philippon-Nadeau wrote:
 Dear Tedd, Dear List,
 
 tedd wrote:
 As for being hung-up -- again, I'm clueless. I mistakenly thought
 that anything obtained from the browser was subject to suspicion as is
 any outside data. But apparently you can trust (I realize within
 certain limits) some things provided by the browser -- that's news to me.
 
 You are right. Being suspicious with data coming from the browser is a
 pretty good reflex. But, as long as you use the accept-language header
 only for detecting the user's native language, you do not risk a lot. In
 the worst case, your will set your site's language to something that is
 not the user's native language. In that case, you only need to allow him
 to change this setting manually.
 
 You can base yourself on information provided by the browser, but as you
 say, I believe that we should not rely completely on it. This is why
 allowing the user to change his language, in your case, becomes important.

yes! that's what I was trying to say :-)

 
 It's always a balance between risk and usability.
 
 Hope this helps,
 
 
 Jean-Michel
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-27 Thread Bastien Koert

My approach to multi lang abilities uses the following db structure
 
base_name is the input field name and the basic raw label for the field
lang_1
lang_2
...
lang_12
prompt_1
prompt_2
...
prompt_12
 
since i currently need to support 12 languages in the initial concept
 
when the user signs on, i equate the language to an offset on the table to be 
able to pull the correct language out of the tables. I have the prompts in 
there to provide prompts for input fields as required. These values are then 
input thru a translation interface. Using the interface, i build up 
translatable values for the controls as well, where items like radio buttons 
and selects are done in the following manner
 
base_name   
 lang_1  lang_2   ...  lang_n

 salutation 
  Salutation Salut   something
base_name.db_value_1 = first option  mr 
Mister  Monsiour   
base_name.db_value_2 = second option  mrs   
 Mrs Madam
...
base_name.db_value_n = n option
 
Then for each option value i have a function that pulls the the correct values 
and builds the options list for each control type
 
 
Our final step to improve perfomance (note that this is, sadly, ASP / vbscript 
) was to take the translation table into an XML application level object to 
cache the data since its relatively immutable. 
 
Now when I write this same app in php, I am more likely to skip the caching 
portion of this in favor of templating the forms for each language. I would use 
a folder for each language.
 
hth
 
bastien
 
 To: php-general@lists.php.net From: [EMAIL PROTECTED] Date: Tue, 27 Nov 
 2007 15:18:45 + Subject: [PHP] Re: Newbie asks about multi-lingual 
 website strategies  Jeff Benetti wrote:  I'm a noob so keep the comments 
 to a noob's level please.I am doing a website and my client wants the 
 bulk of the text to be  bilingual (French and English). The last site I did 
 used php and mysql so I  am getting comfortable with that technology. 
 Typically I am using a single  php file and my menu constantly points to 
 the same file with different id  options example index.php?id=30 and I 
 want to use the same idea to choose  a language example 
 index.php?lang=frid=30. Pretty straight forward for  many of you folks 
 but before I start reinventing the wheel I wondered if  anyone could offer 
 any suggestions. I have a couple of approaches in mind.1: Session 
 vars, I have never used this but it seems straight forward.  Drawbacks?  
 2: Cookies again not too big a deal, never used cookies either but it  
 doesn't seem to be mystifying however the fact that the user can turn  
 cookies off makes me not want to go this route.  3: Use the mysql database 
 and log each ip address and record the preference  and maybe the last time 
 on the site. I am leaning in this direction because  I think it is the most 
 robust but will it be slow? First I have to get the  ip then I have to 
 check to see if it is in my data base and then get the  language 
 preference. It would be great to have a standardized function that  I could 
 use on all of my sites. I live in a bilingual country (Canada) so  this 
 could be a real selling point for my services.Any any and all 
 comments are welcome, it will be a learning curve no matter  which route I 
 take so a little advice on the best direction pros cons would  be great.  
   And of course knowing that I will have many many thousands of people on 
 my  site (hee hee) which option will perform best once I start 
 accumulating  vistors. That's one problem I see with the mysql solution, I 
 think it may  start to be slow unless I start purging vistors who have not 
 shown up in a  while or limit the number of entries.   First of all you 
 can use the browser supplied language preferences (if available) to try and 
 guess the users preferred language. It should be obvious from phpinfo() and 
 a half decent browser what vars you need to inspect ($_SERVER['HTTP_LANG'] 
 or something like that - can't remember of hand!).  You could do soemthing 
 like: 1. Check session for lang preference and use it. 2. Regardless of the 
 result of 1, check GET for a preference and store in session if present and 
 use it. 3. If neither 1 nor 2 has any preference, use the browser supplied 
 preference. 4. If nothing else, use a hard coded default.OK, that 
 selection taken care of :)   For hard coded strings in your PHP code use 
 Gettext and bind to standard your catalog files and use the language choice 
 from the above algorithm. xgettext can extract strings from PHP files easily 
 enough. You just have to make sure you write 

Re: [PHP] Re: Newbie asks about multi-lingual website strategies

2007-11-27 Thread Jochem Maas
Colin Guthrie wrote:
 tedd wrote:

...

 
 Sorry Tedd, but I'm not sure where the browser sniffing stuff came in.
 IE and FF both offer a UI to input the user's preferred language, it's
 an HTTP standard thing and nothign to do with user agents string
 parsing. It uses the Accept-Language header sent with http requests to
 detect the language. It's quite standard but problems usually crop up in
 e.g. Australia and the UK where a lot of people leave the default en-US
 language when en-GB or en-AU would be better. Again it's not infallible
 but it's a fairly good starting point.

ditto.

with regard to 'en-GB' and the like - that's easy enough to match.
(the snippet I offered gave one one to do this)

secondly I don't consider it my problem if the user has there preferred
language set to swahili when they don't even speak that language
(besides which my site probably won't be offering swahili anyway).

 
 Another approach would be to use a geoip database and try and look up
 the users IP address but, if anything, I'd say that is even less
 accurate than the above.
 
 Col
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php