Best way to use two language in a website - php

What is the best way to use 2 language in a website while data are taken from Database
What I searched for
I have found a Google Translate Plugin but actually I don't like google translate translation plus I have to add google banner.
Problem
I can make the website with two languages but the problem is that it is a dynamic website that users will enter data in English in database and I want to output it in two languages.

if you are doing your project with spring mvc then you can easily do localization.

Related

Auto Language Translation Drupal 7

I am working on Drupal 7 and I am stuck with language translation.
I have a Social Networking Site on which I allow user to post data. I allow user to post their data in three languages. User has the option of choosing any one of the three languages and post data.
Now my requirement is that if an English User posts data/message in English, then another Chinese User must be able to see that message in Chinese. So the requirement is that no matter whichever language a data is posted in, it must be visible to all the users in their own language.
Can Drupal provide this automated feature? If yes , then how. I have been trying multiple things but have'nt succeeded to get what I need.
Thanks.
Please see this post and Molot's answer about this topic: https://drupal.stackexchange.com/questions/135227/auto-translate-content-of-nodes
It will never be good. Human languages are not something perfectly unambiguous and logical, so no computer software will ever be able to translate them perfectly. You need a human to properly translate human languages.

Wordpress: search error message in several languages

I am building a multilanguage Wordpress website, is it possible to display a different error message for each language when a search returns no results and how?
Thank you :)
It depends a lot on the plugins and the template you are using. I can sugest the following link:
http://codex.wordpress.org/Translating_WordPress
Many modern templates come with .po files that allow easy internationalization of most text elements such as search and results that you are looking for. Same happens with plugins, if they follow good practices you should be able to translate/internationalize everything you need.

Redirect languages for search engines by cookies

I Wan't optimize my web-site to search engines with multi languages...
i have that structure with languages:
English - example.com/en/
Russian - example.com/ru/
Georgian - example.com/ge/
on first join to my website he automated set you language by your country.
(for Google and other bot's default language are english) and all robots searched on my site only English texts.
Anyone know how can I optimize website in search engines with languages?
E.G: Google search example result
Probably your language versions should provide links to the same content in the other languages, then google has a chance of finding out that the other versions exist. I personally also would consider it good form to provide a way for the use to chose languages by hand. You can't always trust the language preferences coming in from the browser.
Another solution could be to offer a site map that links to each and every article in every language; that way, Google can also at least find out that more stuff exists.

Multilingual website issues

I have to maintain a website in three languages: Arabic, English, and Pashto.
When the users select a language, for example arabic, when he applies any search in my website, how that search will be applied in my database?
When I'm updating the website (of course in english), how those updates will be reflected for arabic and pashto languages in the database?
First you have to decide what would be you database approach. Multilingual Site in Zend Framework
Secondly you have to decide what would be the approach to translated from one language to another. There are some options regrading this.
Add translated text for each language manually.
Use some translating service like google translate. But i dont think that you can rely on that. You have to add some approval system for translated text.
You can store multiple languages in an XML file (you can use http://php.net/manual/en/simplexmlelement.xpath.php to find what language you want based on the user`s selection), maybe even caching it...my opinion
Pro: further development (more languages)

PHP - how to translate a website into multiple languages?

I have a website that's currently in English; I want to be able to switch to a different language when a user clicks on a different language (there are little country flag icons on the site). The way I'm currently trying is with arrays, e.g.:
$english = array('index',
array('h1' => 'this is some h1 text',
'h2' => 'this is some h2 text'));
$japanese = array('index',
array('h1' => '世界交換への歓迎',
'h2' => 世界交換への'));
print $english[index][h1];
print $japanese[index][h2];
As you can see, if I did this for every single page in a separate language, it would be an insane amount of code. What other method can I try?
Given that you are looking for full i18n support which will eventually lead to l10n support, I would suggest writing your page in a PHP framework that supports these things out of the box.
Personally I've only done translations with the Symfony framework. They use a combination of i18n table extension in the DB for content, and XLIFF files for translations of the interface. It was fairly transparent once it was setup, and using a framework avoids having to write all this support by hand.
I also know that i18n is supported in Zend, CakePHP, and Code Igniter.
Content database (or file I guess)
Entry per page for each language
Language referenced by ID
ID set in $_SESSION variable
Optionally remembered in cookie for subsequent visits
I've used this system with a custom CMS # www.grandhall.eu. It gets especially fun when you need to take things like brochures & other downloads into account.
I'd suggest hooking your site into the Windows Live or Google Translate API's. I don't know about the Google one, but the Windows Live API seems really easy to use.
http://msdn.microsoft.com/en-us/magazine/dd569750.aspx
That, or you can write out all the content on the page in two languages, store them both in different tables in a "content" database, then change which table is loaded when the user clicks the change language button. Now, the majority of your drudgery would be in rewriting the content in both languages.
You could just use the Google translate api:
http://code.google.com/apis/ajaxlanguage/
It has tons of documentation and there are examples of how to use it on the google code playground:
http://code.google.com/apis/ajax/playground/
Just browse to ajax > translation

Categories