In a project of my company there is a website available in 6 languages. The site sends some emails to customers/members. Every phrase/word is stored in database and all work well in the website. Our main problem appears in emails.
In each email there are daily reports. We use set_locale() to define each language and "show" the day names (months also) to the proper selected language. This works ok.
In some cases there are more than one emails to be send (in 2 different languages) - here we have problem.
Every info in email appears correct - texts/translations from database.
Day names (and month also) appear only in the first language in both emails.
So, if the first email was in german and the second in french, the french email will have everything in french excpet the day names that will be in german (even though that we execute set_locale again before sending the second email)
Why is that? Is this some set_locale bad behavior? How can we prevent/fix this? Thank you for any insight/tips
EDIT:
the code we use is: setlocale(LC_ALL, $setLocale);
where setLocale would look like "fr_FR.UTF8"
you should use this module (from Zend Framework): http://framework.zend.com/manual/en/zend.locale.html
it is really useful to identify the browser context language.
For translations you can use Zend Translate:
http://framework.zend.com/manual/en/zend.translate.html
It is really useful!
Related
I have a list of Czech names associated with days of the year - all Czech people have their birthday as well as a "name day". I'd like to display the appropriate name(s) associated with each day (there is a long list) according to the user's computer date. Before investigating coding this myself I wanted to ask if you may know a Javascript script for this type of application already, or know how I should go about it. This site is PHP.
You can see the list of Czech name days here: http://en.wikipedia.org/wiki/Name_days_in_the_Czech_Republic
Yes, there is one. The page is in german unfortunatly: http://www.web-toolbox.net/webtoolbox/datum/datum-tagestipp365.htm
You may use google translate to translate the description.
I have got idea of how to build a website in 2 languages, i have a switch and each language text in file and user it. But my website is a website where all freelancers register and post their projects and so. How do i control in what language users enter data. If user entered data in English, how do i show data in other language ?
Example: take 2 language English and Arabic
Case 1 :
1. User enters data only in english.
2. How do i show this data in Arabic??
Case 2:
1. How to make user enter data only in either Arabic or English??
Depending on how much content there is you may need to employ a dedicated translator.
I wouldn't suggest automatic translation or at least be very, very careful with it, as users don't like that at all (e.g. I definitely prefer reading text in English than an automated translation in my native language that some website oh so helpfully decided to show me based on my IP).
It depends on the site settings, you will have to use a language translator and set it up on your website accordingly.
Not sure if stackoverflow is the most appropriate place for this question.
I am currently building a web application that will manage content, ecommerce and allow users to participate.
I am using php's intl extension to deal with different number formats and so on. gettext will be used to provide translations of the actual text in the application.
This question isn't really a technical one, but more as to how the user sets the language/version of the web app.
I have came up with a possible scenarios:
(Country regions) User selects his country and this determines his language. If the language for his country is not avaliable, default to default language.
(Language) User selects his own language, and he selects his own country/time zone settings. That means we can have users in say the United states reading content in Japanese.
With the first option, obviously it is quite fool-proof. The user claims he is from canada, so we display the content in english (en_ca) or french (fr_ca if avaliable).
However, not every web site built on top of the application will be big enough to warrant translations based on locale (i.e. canadian french (fr_ca) vs french french (fr_fr).
Some site would be quite small, so it doesn't matter where the user comes from, he should be able to select either French or English when browsing the site. However, this leads to another issue. If the user selects the content to be shown in french, how do we format things like numbers and currencies? We cannot directly infer his locale from the language he has chosen.
I have looked around the web at some "big" websites to look at how they do things.
Amazon - (Country Regions) Different sites for different countries, i.e. Amazon japan is only avaliable in japanese.
Microsoft - (Country Regions) Some countries have multiple languages. (fr_ca) vs (en_ca).
Engadget.com - (Language) English, Japanese, Chinese (both simplified and traditional).
FaceBook - (Language), but offers different versions of languages (fr_ca and fr_fr)
So I guess the question is, should I force all users of the web application to build their content around the countries/regions or languages? Or should I allow both scenarios?
Cheers :)
As a professional localizer, I reccomend "language" if there is no difference in content.
The reason why Amazon or MS ask for country is that the content is different for each territory. For stuff that is not available, say in Japan, why would they want to translate it to Japanese? Plus it's misleading to the Japanese reader, even if they are on the US site.
On the flip-side, if you offer Country as the selection, then users may expect to see different content based on the coutry they choose, and that might be misleading.
These days a lot of people are mutli-lingual so if the content is the same, defaulting by location then offering the language selection on top is more user-friendly.
I hope my thoughts might help. This is a tough question and depends on many factors - there is no 'right' answer. :)
We did something similar to this in our web app. We essentially just used the currency format of the "home" country for the language. So, if they choose French, they get France's formatting. German, Germany's formatting, etc. It won't always be the correct one but for our app we haven't had any complaints yet, so I assume that works the best if your users aren't too picky. We have a decently small userbase, however (<= 1000 visitors per instance of our app), so you may want to take this advice with a grain of salt ;)
So I need to make a site available in different languages. Using PHP 5.x and MySQL 5.x. I believe I will be using gettext which seems fine for static text throughout the site but what about dynamic data that is stored in the db? Im referring to things like stories, events business listings etc. How do I get those to display in a different language? My initial thought was in the backend have them be able to enter multiple versions of a story, event or listing, one for each language they want to use on the site. But there could be thousands of entries times how many languages they want to show. Is there a better solution/idea that someone can point me to?
Also another issue I was thinking is currently the site allows you to search events/stories/listings, how would that work in different languages? Im assuming if someone selected the site to show in spanish they are going to use spanish words to search the site, but if the information in the db is in english I dont know that would work. Any suggestions on that?
If you want the stories to be correct in all languages, then you need them stored in all languages and provide the backend to do the translations or enter the stories on different languages as you initially thought.
If you don't like that, you might add the google translate element in your pages, to provide automatic (not correct) translation.
For the search question, I would only search for the keywords in the fields of the database in the same language as the user. If Joe is visiting your page in English, only look for the search terms in title_en, content_en, description_en fields of your database (or the ones with language='en' if you have one row per article and translation in the database, instead of one row per article (with all translations inside)). Obviously, this does only work if you put all the translations on the database.
The best solution I have seen described is this.
As i18n CMS sites as you describe are in a constant state of flux, with new articles being added, some of which have had translations, in some languages.
If an article in a chosen language has not yet been translated then show a default language (English?).
Then pick any ideas which appeal to your case:
a) If showing a default article in English also throw onto the page an input box and invite your audience to translate it for you.
b) If showing a default article in English also put on the page an offer to send the content to google translate as well as doing a) above
c) put a bounty on the translation and optionaly do a) and/or b) above.
I have developed a website www.tenxian.com.
It has three language versions, English, Japanese and Chinese. How can I write an effective PHP program which can automatically choose a language version based on the IP address of the visitor?
If I use "if-else", the code would be much complicated; If I use switch-case, how to write it since the data which should be dealt with are IP ranges, not particular numbers. Besides, I don't know these IP ranges
What is the easiest way to do it?
Please, PLEASE, do not make the mistake of thinking that IP == language. Look at the browsers accept-language header first, then the browser identification string which might contain the OS language, and only then take the IP into account. In almost 100% of all cases the browser accept-language header will be present and sufficient.
And always give the user the choice to switch to another language.
Just apart from the simple case of a foreigner abroad, how do you determine the language for Belgium, where they speak French, Dutch and German? (Maybe that doesn't apply to your case, but just philosophically. :)).
Check out GeoPlugin:
http://www.geoplugin.com/webservices/php
Yes please don't do it... Google does this and dreaking annoying.. I always get the thai version instead the english one from my browser.
Use the http headers from the browser.
<?php
$ln = split(",",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
print_r($ln[0]);
?>
Perhaps this will help: www.countryipblocks.net
You'd probably want to use some form of IP geocoding database (example).
Assuming you can convert IP ranges to one of your language choices, you could do this (all replies above): have all your messages in the applications stored in an associative array of this form.
$MESSAGES[$USER_LANGUAGE][$msgId]
where $USER_LANGUAGE can be chinese, japanese, or english (or any other equivalent enum). $msgId can be things like "login.successful", "login.fail" etc. Where ever you display messages to the user do not display hardcoded strings, make a reference to the variable using the $msgId.
You can access it as a global variable OR you can create a function that takes in the $msgId as a parameter and returns the message, $USER_LANGUAGE can be a global variable as well (which is set the first time the user comes in).
take a look at the maxmind geoip module for PHP (http://www.maxmind.com/app/php), as for your data structure perhaps key it to the ISO-3166-1 country code which apache_note("GEOIP_COUNTRY_CODE"); returns.