Multilingual website issues - php

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)

Related

Best way to use two language in a website

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.

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.

Localize existing PHP application

I have an existing, database driven PHP application with around 40 pages printing an unknown (but rather large) number of English strings. The strings are currently all hard coded. There is also a set of static documentation pages. I now need to add language support to this application.
As far as I can tell gettext seems to be the standard solution to this problem, but gettext feels very much like a "hack" to me. I am also not certain about the additional overhead (both in development and run-time) it will cause. Are there any other solutions or frameworks that could be better suited to my requirements? Any best practices or pitfalls I should be aware of when starting this project?
gettext is the "standard" for multi-lingual text storage, but in the end, it is just a storage engine. It does nothing to put the proper text into your page. You need to abstract the text from your View so the proper text can be inserted.
In the end, you need a way to place the language text in your document. This means "tagging" the text in a certain way so that it can be searched and replaced by with desired language text. For the e-commerce site I manage (3 languages) I used a technique derived from Facebook FBML tagging system.
You can wrap your text in "tags" <trans id="slt">something like this</trans>. Then use the DOM tools in PHP to extract the ID, look up the translated text based on the id, replace the content between the tags with the proper language text. You can still use gettext for your storage mechanism, or your database. Your browser will ignore the tags, so your page will still look fine during development.
This is just one tagging example. You can use any tagging mechanism and use grep instead to extract, search and replace.
For static pages, you can pre-generate the translated versions and load the appropriate language version. This way there is no extra overhead for different languages.

Multi languages site

I have a site with texts in 2 languages. How should I go between the pages so that from the point that he clicked to change the language he will see it and the moment he clicks the other language, it will change back?
An option is that when the user clicks the link to change the language I will store it into the session and use it. But I've heard it won't work well with the search engines.
A second option is to pass the language variable through the URL to every page.
Third option is to smartly use the zend extension ability.
(Using PHP + Zend Framework).
SEO is very important to me.
EDIT:
The texts that are in the site(and that are in several languages), are entered by an admin. It works now with languages objects that I've created with the option for the admin to add texts in each of them. So when I'll enter the first page(of which the text can be changed) I'll see it in English and when I click the Russian flag it will display that page(and the others later) in Russian.
Using Zend_Locale or translate won't work for me(I think), and passing through the URL is an option. The question is if it is the best one?
It is best to pass it along as a parameter in the URL, google uses locale=en for this. It would also be ok to store it in the session only if the user is logged into your website and selected a preferred locale or something. That way search engines can index the different locales with different urls, but your users would see pages in whatever locale they have chosen.
Zend Framework provides a pretty solid set of tools for this.
Start with Zend_Locale and Zend_Translate
It ought to be possible to tweak ZF's routing to contain a segment that indicates the locale. So you'd end up something like /:locale/:controller/:action (or similar). Your URLs would then look like http://example.com/en/some-controller/some-action.
Note that there's more than just translation of language. You can also localize the display of numbers, currency, dates, etc.
Come back with more specific questions once you've played with those.

PHP translation frontend similar to Rosetta?

I'm currently migrating a web application from a database-based internationalization approach (each word having an entry in the translation table, and the actual translation) to one based on Zend_Translate and CSV files.
I need to provide a end-user friendly way to update those translations quickly and easily. Ideally, to minimize the risk of breaking stuff, users would not edit the CSV files directly, but be shown a nice form with fields.
Do you know a standalone, PHP-based, end-user compatible translation frontend that supports one of the adapters Zend_Translate has to offer - ideally gettext or csv?
Something like Python's/Django's Rosetta but in PHP? Rosetta does exactly what I need:
but I would very much like to stay with PHP here for server setup reasons.
SimplePO looks like it goes in the right direction, but is too simple - it doesn't seem to be able to handle multiple languages and catalogs, and plurals.
I have not seen another one and probably for the following reason. In spite of what it says on the SimplePO web site translators do not like and often will not work on side by side translation systems as shown above.
That is how programmers imagine translators will work and it is flawed. Translators work with a toolkit called TMX, Translation Memory Exchange (generic name see Okapi an open source implementation to get a feel for it), and in this they build up translation dictionaries for words, phrases and sentences. They the take a file of varying formats and feed it into the TMX software, this gives them a first pass that is 60%, 70% etc translated but like Google language API horribly mangled in terms of making sense in the target language.
Then what they do is translate the words not dealt with by TMX, adding to the dictionaries where logical, and they colloquialise it, i.e. make it work in the target language and make sense of it. For this reason the translator should always be translating into their native language.
They do it this way for a number of reasons, a) it makes sense and works and reduces their work load and b) because they get paid by the word and to do side by side translation does not allow them to use their tools and maximise their income.
What translators want is a file in a format that you can export, they can import and translate, export and send back to you to import.
The files formats can be csv, rtf, tmx, xliff, gettext and if you read the Symfony framework docs you can see how they do it and handle it (they do a pretty good job in my opinion).
Having said all that i was in a similar position about 8 years ago when having to write a site in English, French, German, Hungarian and Slovakian and i did the same as SimplPO and simply wrote my own side by side application to allow this to be done. However the company we were writing the application for did all their own translation in house so we didn't hit the problem with translators. When we did we wrote an export to RTF and import from RTF (that in itself is mind boggling) so the translators could function as above.
However SimplePO is the only other implementation of the idea i have seen. The frameworks such as Zend seem to think you just create lookup tags to replace words and phrases and build no control into the application to manage the process. Consequently it soon gets out of hand and the maintenance of it becomes both difficult and expensive.
Most people who write multilingual web sites actually don't. They write a master site and then make a copy, translate it and maintain the translated version. It seems clunky to us logical types but is actually very effective.
One of the reasons it is effective is the i18n and l10n are about many other things than language.
Look and feel. Anglo saxons like cool colours and san serif typefaces, Hispanic peoples like Serif type faces and brighter colours. And as you cross other cultures the expectations vary wildly in layout, types, colours etc.
French and to some degree German is 30% longer, more verbose, than the equivalent English so you layout goes to hell in a hand basket real quick.
Semitic language run right to left
Japanese and other language that are not alphabet based can run ltr rtl top to bottom and some do not even have white space
dates? US, Japanese, UK, Hungarian as all different
currency and number formats, don't even start me off
Well sorry to go on and to summarise:- For simple side to side just write it yourself, took me about two weeks without any frameworks and working it out as i went along just use tag replacement. But any more and consider what you are doing. Carefully.
If you can use gettext files (Zend_Translate supports them) you can give POEdit a try. It is quite simple to use and supports plural forms since version 1.3.
However, users will have to download the files and reupload them in the end, because POEdit is not an online tool. I don't know any other web based tool.
You can try Transtable, a simple web intefece for editing translations in php arrays.

Categories