Server side PHP or similar website translator script - translates website page content into other languages automatically and saves a copy to cache folders. Visitor arrives at a site page, clicks a translate flag and a new html page is served in that language and a static copy saved in the sites cache folder.
**How it works.**
When a visitor requests a translated page, the script checks if a cached version exists, if not it sends the page to the translator script. The translator does its work and then keeping the page structure intact, it generates and saves a .html cached copy of that page which it presents to the visitor.
Should work with any site - html, php, htm etc and retain the originating pages design and formating perfectly.
Existing hyperlinks in the originating page (../[url removed, login to view] or ../../../anyfolder/[url removed, login to view]) must still work in the cached page, even though the new cache version is located in different folder names and locations. It is acceptable to automatically change and overwrite hyperlinks in cached pages (htref="[url removed, login to view]" instead of htref="../[url removed, login to view]") if required. The same would apply to image src urls etc. That would gaurantee clean SEO urls and no link breakage.
In addition to converting all viewable content, it will automatically translate text inside certain html tags like page title, meta title, meta description, meta keywords, image 'alt text' and href 'title description' to the chosen language. It will not translate or change any other html code or scripts.
Though it would translate any sript served content like Google Ads ect.
If references need to be added to cached pages by the scripts for any reason, it can use commands between comment tags <!-- -->.
It will keep the url perfect for being indexed by search engines.
If using php or .htaccess 'RewriteEngine' to build dynamic pages, it must not generate dynamic url's, search engines don't like it. Url should be SEO friendly NOT like "[url removed, login to view]://[url removed, login to view]
But like "[url removed, login to view]"
Please note, this script does not just simply save a Yahoo or Google wrapper page which is bloated with additional html and scripts. It saves the
page as served to the visitor.
Ie; go to [url removed, login to view] and click the first translate flag (fr), then view that pages source.
The translation process requires time and bandwidth and translator services like Google and Yahoo etc (which the script would use for initial
translation), only allow a limited number of translations per site IP within a set time and will block further translations for twelve hours. Devising a way
to alter the sites sending IP could be done but I dont know how.
To avoid this and make the translated page appear faster, the cache system should save the page translated in a cache folder. This way when a
visitor will visit a page which has been translated before, it will show the page from the cache instead of translating it again. The 'cache' folder can
have any name, permissions or location. Cached pages are saved as .html using seo friendly names in their individual language sub-folders which
are automatically created as required.
IE Instead of '[url removed, login to view]' Would be like:- '[url removed, login to view]' - Where
'anydomain' is derived from the sites domain name (without the .com): 'translate' is the scripts user defined default folder name: 'french' is the auto created language sub-folder and 'file' is the originating pages html name and '000481' is a sequential number appended to ensure uniqueness.
Like. [url removed, login to view]
To ensure an up to date version of the cache, when a translation is requested and that page already exists in the cache, the script will check that the creation date of the cache page is greater than the original site page. If not, it will translate and overwrite the cached copy.
Translator engines are notoriously busy and sometimes will be unavailable, in this event and no page in cache, it would be nice for a 'fade in fade out' popup on the page being viewed saying something like "Sorry service not available at present due to high demand. Please try later"
1. An optional 'auto' script to the translator that when started will automatically translate every page on the site that does not already exist in the cache folders, adding that page to the cache. It would also check dates against any pre-existing cache translated pages with the original and
overwrite with updated version if neccessary. It would do this by dividing 24 hours with the max translations set by user - say 24, therefore doing a translation every hour. As one of our sites has 300+ pages, this could take quite a while with say 20 languages. (300x20) divided by a maximum of say only 24 translations per twelve hours (250 days). Though this would provide a steady organic growth of pages on the site and be totally automatic. At the finish of this time, the site would have 20 language folders, each containing 300+ translated pages. In the event the requested
translation is not available due to service unavailable, the script will log these and try them later. The script can be stoped and started through main admin panel.
The auto translate function would need an 'Includes' drop down file selection option so that it would only work on selected files and folders on the site. IE; ignore any unchecked boxes.
2. When the translator creates the cache page, It auto inserts a user specified comment in each page (Eg; <!--flights-->) immediately after <body> or immediately before </body>. If no comment is set, it will insert a default comment like <!-- input --> We can use this for future global operations.
There are several moderately priced and shareware scripts around that do similar to this, but we prefer a solution to fit more to our needs as the 5 php scripts (cache, counter, flags, function and [url removed, login to view]) we presently use need upgrading, if its of use for ideas or reference you may have copies of them. They are simple but got the job done and some snippits of the php may be re-usable, saving some programing time.
You can see a working example of our existing translation at [url removed, login to view], though these are only cache versions as the script no longer translates on the fly.
Will work on php enabled servers, with or without root access.
Not need functions like 'curl' or 'cron' .
We already have language flag images.
We are able to set permissions (Ie; 777 / 775), for cache folders and scripts etc.
We already use the root .htaccess for other functions, so cannot use this for any translator functions. However .htaccess can exist in the translate folders if required.