hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : PHP gettext - issue w/ accent marks
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

PHP gettext - issue w/ accent marks

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 06-26-2008, 12:05 PM
nkad nkad is offline
WHT Addict
 
Join Date: Mar 2003
Posts: 110

PHP gettext - issue w/ accent marks


I'm trying to translate a site to Spanish, but accent marks are not displaying correctly. For example,

echo _("Password"); should output the translation Contraseņa, but instead it appears as Contrase~na.

I'm using poedit, with charset iso-8859-1. I tried setting it to UTF-8 but it didn't make a difference.

Reply With Quote


Sponsored Links
  #2  
Old 06-26-2008, 02:26 PM
nkad nkad is offline
WHT Addict
 
Join Date: Mar 2003
Posts: 110
I just tested this with Python and it works fine. I'm using PHP 5.2.5.

Reply With Quote
  #3  
Old 06-26-2008, 03:05 PM
nkad nkad is offline
WHT Addict
 
Join Date: Mar 2003
Posts: 110
I've spend countless hours wrestling with this problem before coming here and posting about it. Turns out I got it working after adding this PHP code:

bind_textdomain_codeset("messages", "ISO-8859-1");

Reply With Quote
Sponsored Links
  #4  
Old 06-26-2008, 04:33 PM
Saeven Saeven is offline
Web Hosting Master
 
Join Date: Aug 2002
Location: Canada
Posts: 644
nkad,

UTF-8 can successfully display Spanish characters, however, if your characters are stored in a different encoding, then you'll get cross-encoding disparities (look like trash characters).

It's important to display characters in their original encodings, or otherwise convert the data to the target display encoding. mbstring has a conversion function that fixes these issues.

So consider:
poedit in utf-8, you must have the charset on the output set to utf-8.

Sticking to gettext, I think that without using bind_textdomain_codeset, PHP's behavior is to fallback on locale-data. This writ, I would strongly recommend sticking to locale and resource bundles instead of using gettext. PHP6 has a fantastic alternative that they've called 'i18n', http://ca3.php.net/manual/en/intro.i18n.php

Glad you solved your problem in one way or the other though

__________________
Senior Architect, saeven.net consulting inc.
Zend Certified Engineer
Saeven|CRM (helpdesk/email/livechat) : http://crm.saeven.net
Whois.Cart() : http://whoiscart.net

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Savvis Opens Fifth Data Center in London Market Web Hosting News 2013-03-05 09:55:18
PayPal UK IPN Issues Impact Web Hosts, Users Web Hosting News 2013-02-01 09:34:43
Q&A: Christian Dawson on the Founding of the Internet Infrastructure Coalition Web Hosting News 2012-09-25 17:28:41
Akamai Report Names Taiwan Number-One Source of Attack Traffic Web Hosting News 2011-10-28 18:33:23
DNS Solutions Provider Nominum Names Industry Veteran New CEO Web Hosting News 2011-08-24 15:46:23


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?