• [MOD] Language select 4 0 5 1
Currently:  

Author Topic: [MOD] Language select  (Read 308021 times)

0 Members and 1 Guest are viewing this topic.

Offline Alessio

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Webax.it [Alessio's photogallery]
Re: [MOD] Language select
« Reply #150 on: October 12, 2008, 08:30:36 PM »
Is it possible to detect automatically the language (by IP or by OS language) if are not present cookie?

Any solution?
Alessio
my homepage: http://www.webax.it

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Language select
« Reply #151 on: October 13, 2008, 02:47:22 AM »
Is it possible to detect automatically the language (by IP or by OS language) if are not present cookie?

Assuming you are using this code:
http://www.4homepages.de/forum/index.php?topic=4743.msg31555#msg31555

Replace the code in global.php with this:
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  
$requested_l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if (
file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php')) {
    if (!isset(
$HTTP_COOKIE_VARS['4images_lang'])) $l $requested_l;
    
$config['language_dir'] = $requested_l;
    
setcookie('4images_lang'$requested_l, (time()+ 60 60 24 365), "/"""0);
  }
}
else
{
  if (isset(
$HTTP_COOKIE_VARS['4images_lang']) && file_exists(ROOT_PATH.'lang/'.$HTTP_COOKIE_VARS['4images_lang'].'/main.php'))
  {
    if (
$HTTP_COOKIE_VARS['4images_lang'] != $config['language_dir']) $l $HTTP_COOKIE_VARS['4images_lang'];
    
$config['language_dir'] = $HTTP_COOKIE_VARS['4images_lang'];
  }
  else
  {
    
//http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
    
$lang_codes = array(
      
"aa"=>"afar","ab"=>"abkhazian","ae"=>"avestan","af"=>"afrikaans","ak"=>"akan","am"=>"amharic","an"=>"aragonese","ar"=>"arabic","as"=>"assamese","av"=>"avaric","ay"=>"aymara","az"=>"azerbaijani",
      
"ba"=>"bashkir","be"=>"belarusian","bg"=>"bulgarian","bh"=>"bihari","bi"=>"bislama","bm"=>"bambara","bn"=>"bengali","bo"=>"tibetan","br"=>"breton","bs"=>"bosnian",
      
"ca"=>"catalan","ce"=>"chechen","ch"=>"chamorro","co"=>"corsican","cr"=>"cree","cs"=>"czech","cu"=>"church_slavic","cv"=>"chuvash","cy"=>"welsh",
      
"da"=>"danish","de"=>"deutsch","dv"=>"divehi","dz"=>"dzongkha",
      
"ee"=>"ewe","el"=>"greek","en"=>"english","eo"=>"esperanto","es"=>"spanish","et"=>"estonian","eu"=>"basque",
      
"fa"=>"persian","ff"=>"fulah","fi"=>"finnish","fj"=>"fijian","fo"=>"faroese","fr"=>"french","fy"=>"frisian",
      
"ga"=>"irish","gd"=>"gaelic","gl"=>"galician","gn"=>"guarani","gu"=>"gujarati","gv"=>"manx",
      
"ha"=>"hausa","he"=>"hebrew","hi"=>"hindi","ho"=>"hiri_motu","hr"=>"croatian","ht"=>"haitian","hu"=>"hungarian","hy"=>"armenian","hz"=>"herero",
      
"ia"=>"interlingua","id"=>"indonesian","ie"=>"interlingue","ig"=>"igbo","ii"=>"sichuan_yi","ik"=>"inupiaq","io"=>"ido","is"=>"icelandic","it"=>"italian","iu"=>"inuktitut",
      
"ja"=>"japanese","jv"=>"javanese",
      
"ka"=>"georgian","kg"=>"kongo","ki"=>"kikuyu","kj"=>"kuanyama","kk"=>"kazakh","kl"=>"kalaallisut","km"=>"khmer","kn"=>"kannada","ko"=>"korean","kr"=>"kanuri","ks"=>"kashmiri","ku"=>"kurdish","kv"=>"komi","kw"=>"cornish","ky"=>"kirghiz",
      
"la"=>"latin","lb"=>"luxembourgish","lg"=>"ganda","li"=>"limburgan","ln"=>"lingala","lo"=>"lao","lt"=>"lithuanian","lu"=>"luba-katanga","lv"=>"latvian",
      
"mg"=>"malagasy","mh"=>"marshallese","mi"=>"maori","mk"=>"macedonian","ml"=>"malayalam","mn"=>"mongolian","mo"=>"moldavian","mr"=>"marathi","ms"=>"malay","mt"=>"maltese","my"=>"burmese",
      
"na"=>"nauru","nb"=>"norwegian","nd"=>"ndebele","ne"=>"nepali","ng"=>"ndonga","nl"=>"dutch","nn"=>"norwegian","no"=>"norwegian","nr"=>"ndebele","nv"=>"navajo","ny"=>"chichewa",
      
"oc"=>"occitan","oj"=>"ojibwa","om"=>"oromo","or"=>"oriya","os"=>"ossetian",
      
"pa"=>"panjabi","pi"=>"pali","pl"=>"polish","ps"=>"pushto","pt"=>"portuguese",
      
"qu"=>"quechua",
      
"rm"=>"romansh","rn"=>"rundi","ro"=>"romanian","ru"=>"russian","rw"=>"kinyarwanda",
      
"sa"=>"sanskrit","sc"=>"sardinian","sd"=>"sindhi","se"=>"sami","sg"=>"sango","si"=>"sinhala","sk"=>"slovak","sl"=>"slovenian","sm"=>"samoan","sn"=>"shona","so"=>"somali","sq"=>"albanian","sr"=>"serbian","ss"=>"swati","st"=>"sotho","su"=>"sundanese","sv"=>"swedish","sw"=>"swahili",
      
"ta"=>"tamil","te"=>"telugu","tg"=>"tajik","th"=>"thai","ti"=>"tigrinya","tk"=>"turkmen","tl"=>"tagalog","tn"=>"tswana","to"=>"tonga","tr"=>"turkish","ts"=>"tsonga","tt"=>"tatar","tw"=>"twi","ty"=>"tahitian",
      
"ug"=>"uighur","uk"=>"ukrainian","ur"=>"urdu","uz"=>"uzbek",
      
"ve"=>"venda","vi"=>"vietnamese","vo"=>"volapük",
      
"wa"=>"walloon","wo"=>"wolof",
      
"xh"=>"xhosa",
      
"yi"=>"yiddish","yo"=>"yoruba",
      
"za"=>"zhuang","zh"=>"chinese","zu"=>"zulu",
    );
    
    
//http://www.thefutureoftheweb.com/blog/use-accept-language-header
    
$langs = array();
    
    if (isset(
$_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        
// break up string into pieces (languages and q factors)
        
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i'$_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
    
        if (
count($lang_parse[1])) {
            
// create a list like "en" => 0.8
            
$langs array_combine($lang_parse[1], $lang_parse[4]);
        
	

            
// set default to 1 for any without q factor
            
foreach ($langs as $key => $val) {
                if (
$val === ''$langs[$key] = 1;
            }
    
            
// sort list based on value
	

            
arsort($langsSORT_NUMERIC);
        }
    }
    foreach (
$langs as $key => $val)
    {
      
$key explode("-"$key);
      if (isset(
$lang_codes[$key[0]]) && file_exists(ROOT_PATH.'lang/'.$lang_codes[$key[0]].'/main.php'))
      {
        
$config['language_dir'] = $lang_codes[$key[0]];
        if (
$lang_codes[$key[0]] != $config['language_dir']) $l $lang_codes[$key[0]];
        
setcookie('4images_lang'$lang_codes[$key[0]], time()+ 60 60 24 365"/"""0);
        break;
      }
    }
    unset(
$langs);
    unset(
$lang_codes);
  }
}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Alessio

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Webax.it [Alessio's photogallery]
Re: [MOD] Language select
« Reply #152 on: October 13, 2008, 08:05:36 PM »
Thank you Vano!
One question. My website is available in two languages only, what happens with the others? Is the default language selected?
Alessio
my homepage: http://www.webax.it

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Language select
« Reply #153 on: October 13, 2008, 11:43:29 PM »
Yes, if visitor's language not detected or site doesn't have such language, then default language used (set in the settings)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline robertx

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Language select
« Reply #154 on: October 25, 2008, 08:27:01 PM »
on Lanuage select is it possible to for user to see another template??
let's say i have english and farsi
i want the user when he chooses the farsi to get a totally different template!

u'll need delete from global.php:
Code: [Select]
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']."/icons");
and this:
Code: [Select]
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
include(ROOT_PATH.'includes/template.php');
$site_template = new Template(TEMPLATE_PATH);

And then find:
4images older then v1.7.3:
Code: [Select]
include(ROOT_PATH.'lang/'.$config['language_dir'].'/main.php');4images v1.7.3 or newer:
Code: [Select]
include_once(ROOT_PATH.'lang/'.$config['language_dir'].'/main.php');
insert above:
Code: [Select]
if ($config['language_dir'] == $l) $config['template_dir'] .= "_".$l;
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']."/icons");
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
include(ROOT_PATH.'includes/template.php');
$site_template = new Template(TEMPLATE_PATH);

With this change you will need create template for each language with this name format: <template name>_<language>
for example your default language is english and have also deutsch and spanish languages.
the default template used has name blah
Then you must have three templates with names:
blah
blah_deutsch
blah_spanish


P.S. I've removed your page_header.php source, so it wont cloag up the search engine ;) next time if u want to show something like, attach the file as a .txt file ;) (or zip it)


I have try that it s working perfect but i have a BIG problem . I have installed Buddy Mod and that is working only for default template . I mean that the icon don t show in another template just in default template .
How could i resolve that ?

Thanks

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Language select
« Reply #155 on: October 25, 2008, 09:28:01 PM »
I'm sorry, what icon? I'm not familiar with "Buddy Mod", and don't know how it works...A screenshot of how it should look like and how it actually looks could possibly help.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.297
    • View Profile
    • Discover the New World of Kindersurprise
Re: [MOD] Language select
« Reply #156 on: October 25, 2008, 10:34:41 PM »
Klappt perfekt in Version 1.7.6  :thumbup:
man muss nur die images in den richtigen Ordner packen.

LG Harald
Danke Harald




Offline robertx

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Language select
« Reply #157 on: October 26, 2008, 02:15:34 PM »
I'm sorry, what icon? I'm not familiar with "Buddy Mod", and don't know how it works...A screenshot of how it should look like and how it actually looks could possibly help.

Hello V@no and thanks for your support .
The Buddy mod is here http://www.4homepages.de/forum/index.php?topic=19755.0.
Also please see atached 2 screenshots from english and romanian language

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Language select
« Reply #158 on: October 26, 2008, 05:36:39 PM »
I'm sorry, what icon? I'm not familiar with "Buddy Mod", and don't know how it works...A screenshot of how it should look like and how it actually looks could possibly help.

Hello V@no and thanks for your support .
The Buddy mod is here http://www.4homepages.de/forum/index.php?topic=19755.0.
Also please see atached 2 screenshots from english and romanian language

You have to upload your romanian button in to your_template/images_romanian folder if you don't have one you should create him.

Offline robertx

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Language select
« Reply #159 on: October 26, 2008, 06:36:53 PM »
I'm sorry, what icon? I'm not familiar with "Buddy Mod", and don't know how it works...A screenshot of how it should look like and how it actually looks could possibly help.

Hello V@no and thanks for your support .
The Buddy mod is here http://www.4homepages.de/forum/index.php?topic=19755.0.
Also please see atached 2 screenshots from english and romanian language

You have to upload your romanian button in to your_template/images_romanian folder if you don't have one you should create him.

Hello . Thanks . That was the problem . Thanks for help .

What you think will me the best sollution for set up the romanian language as default ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Language select
« Reply #160 on: October 26, 2008, 07:30:22 PM »
What you think will me the best sollution for set up the romanian language as default ?
It is really up to you. ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline robertx

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Language select
« Reply #161 on: October 26, 2008, 09:44:59 PM »
What you think will me the best sollution for set up the romanian language as default ?
It is really up to you. ;)

Hello V@no  . I have setup from admin romanian as default . the default template default and for english template default_ english . It 's working ok for romanian but when i try to select english the language is unchanged , in this mode will work just romanian . why ?

Offline robertx

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: [MOD] Language select
« Reply #162 on: October 29, 2008, 09:29:26 AM »
What you think will me the best sollution for set up the romanian language as default ?
It is really up to you. ;)

Hello V@no  . I have setup from admin romanian as default . the default template default and for english template default_ english . It 's working ok for romanian but when i try to select english the language is unchanged , in this mode will work just romanian . why ?

Could any1 help me whit that ?

Offline V@nо

  • Addicted member
  • ******
  • Posts: 1.223
    • View Profile
Re: [MOD] Language select
« Reply #163 on: October 29, 2008, 06:31:08 PM »
whitch code exactly do you use? did you try reinstal, maybe you made a misstake?
Your first three "must do" before you ask a question:
If I asked you to PM me, I meant PM to my primary account, this account doesn't accept PMs.

Offline Omsky

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: [MOD] Language select
« Reply #164 on: November 15, 2008, 12:23:24 AM »
possible make, individual photo language names and description on other languages pages, for all photos?

example
english link:
http://site.com/r-p-40-paris-hilton-41-paris-hilton---celebrity-star-photo-(010)-5359.htm
photo name: Paris Hilton - celebrity star photo
Description:     Paris Hilton - celebrity star photo
Keywords:    Paris, Hilton, star, photo, shoot

example
russian link:
http://site.com/r-p-40-paris-hilton-41-paris-hilton---celebrity-star-photo-(010)-5359.htm?l=russian
photo name: Пэрис Хилтон - фотография знаменитости
Описание: Пэрис Хилтон - фотка
Слова для поиска:    Пэрис, Перис, звезда, фото, снимок