Forum Archive - Custom Image URLs for different languages

Custom Image URLs for different languages
Dec 9, 2011 5:51 pm by jb11
Hi Edvard I have been using GTranslate with huge success and all is working well. I am aware you are working an a feature whereby we can change the images/media on our website as well to show images based on the language being viewed by the visitor. At the moment, all my English static images/banners are showing-up for all the 23 languages I am using on my site via GTranslate. Until the feature will be available in future, I need to now attempt to do something myself to, via php and jumi for joomla, change the image urls based on the language code in the mod_rewrite URL as per the address bar. I want to use your Jumi (Joomla) product (I know how to use Jumi) to run a php script to: (1) use the "$_SERVER['REQUEST_URI'];" php command to get the mod_rewrite URL in the browser; I know how to do this. (2) and to use this string to search for the applicable language being seen by the website visitor. E.g.if "$_SERVER['REQUEST_URI'];" has the value "/es/blog" in it, I will be able to extract the "es" part with PHP; I know how to do this. (3) use this extracted language code order to show the images I created for the various languages which I also know how to do especially with Jumi for Joomla. PHP will change the img src urls based on this language code. I have my own banners/images which we designed for each language. I just want to ensure the banners show-up for the correct website language. My problem: $_SERVER['REQUEST_URI']; at the moment does not show me the /es/ (or /it/ or /de/ etc.) part but only the real path. I have created a php file ("lang.php) with the following code: <?php echo $_SERVER['REQUEST_URI']; ?> For example, If I visit "mysite.com/es/lang.php", $_SERVER['REQUEST_URI']; actually returns "/" and not "es/". Should I change something in my htaccess file for this command ($_SERVER['REQUEST_URI'];) to show the language sub-directory generated by mod_rewrite? I need to see the "es/" through the PHP command in order to manipulate my images. Will appreciate your input on why $_SERVER['REQUEST_URI']; is not showing the language sub-directories... I might be missing something. I am not familiar with .htaccess code although I can change it. Or is there a more easier way to determine the language code to use Jumi with a GTranslate wesbite? Thank you My htaccess file: ## Can be commented out if causes errors, see notes above. #Options +FollowSymLinks # # mod_rewrite in use RewriteEngine On # gtranslate config RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$1/$3 [R=301,L] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$1/ [R=301,L] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 [L,QSA] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1 [L,QSA] # RewriteRule ^(da|nl|de|sv|pl|ro|no|ru|hu|lt|sl|sk|lv|uk|es|pt|it|fi|fr|et|bg|cs|el)/(da|nl|de|sv|pl|ro|no|ru|hu|lt|sl|sk|lv|uk|es|pt|it|fi|fr|et|bg|cs|el)/(.*)$ /$1/$3 [R=301,L] # RewriteRule ^(da|nl|de|sv|pl|ro|no|ru|hu|lt|sl|sk|lv|uk|es|pt|it|fi|fr|et|bg|cs|el)/(da|nl|de|sv|pl|ro|no|ru|hu|lt|sl|sk|lv|uk|es|pt|it|fi|fr|et|bg|cs|el)$ /$1/ [R=301,L] # RewriteRule ^(da|nl|de|sv|pl|ro|no|ru|hu|lt|sl|sk|lv|uk|es|pt|it|fi|fr|et|bg|cs|el)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 [L,QSA] # RewriteRule ^(da|nl|de|sv|pl|ro|no|ru|hu|lt|sl|sk|lv|uk|es|pt|it|fi|fr|et|bg|cs|el)$ /gtranslate/translate.php?lang=$1 [L,QSA] ########## Begin - Rewrite rules to block out some common exploits ## If you experience problems on your site block out the operations listed below ## This attempts to block the most common type of exploit `attempts` to Joomla! # # Block out any script trying to set a mosConfig value through the URL RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] # Block out any script trying to base64_encode crap to send via URL RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] # Block out any script that includes a <script> tag in URL RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) # Send all blocked request to homepage with 403 Forbidden error! RewriteRule ^(.*)$ index.php [F,L] # ########## End - Rewrite rules to block out some common exploits # Uncomment following line if your webserver's URL # is not directly related to physical file paths. # Update Your Joomla! Directory (just / for root) RewriteBase / # ErrorDocument 404 /index.php ########## Begin - Joomla! core SEF Section # RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/index.php RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC] RewriteRule (.*) index.php RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] # ########## End - Joomla! core SEF Section
Re: Custom Image URLs for different languages
Dec 12, 2011 8:57 pm by Edvard
Hi, Please read this, it should be helpful: url-language-code-t320.html?hilit=glang

SIMILAR TOPICS

How do I add Indian languages in Drupal GTranslate?Sep 18, 2011 6:10 amReplies: 26Post by: rag_gupta
504 timeout calling a custom functionNov 28, 2018 10:34 amReplies: 1Post by: fabbrichetta
Custom menu with gtranslate functionDec 4, 2018 3:14 amReplies: 1Post by: luqman305
Export all custom translationsJul 5, 2018 11:50 amReplies: 1Post by: sadashiv
Enterprise URLs not workingMay 14, 2018 8:25 pmReplies: 1Post by: dpitfield

Try GTranslate with a free 15 day trial