I just set up Simplified Chinese and Traditional Chinese in the background. The users are all Chinese browsers (zh-cn), but when they visit the website, the default is English. You must register to log in to display Chinese.
I am adding after this code. echo $LANGUAGE;Used to detect the result. Found to be the output of "english".
I personally think that the following code logic has a problem. Please help me , thank you.
includes/session.php
if((empty($LANGUAGE)||$ENABLE_MULTI_LANGUAGE)&&empty($_SESSION['CLANGUAGE'])&&empty($SEARCH_SPIDER)){if(isset($HTTP_ACCEPT_LANGUAGE)){$browserLangPrefs=$HTTP_ACCEPT_LANGUAGE;}elseif(!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])){$browserLangPrefs=$_SERVER['HTTP_ACCEPT_LANGUAGE'];}else{$browserLangPrefs='en';}// Seach list of supported languages for this Browser's preferred page languages$browserLangList=preg_split('/(,\s*)|(;\s*)/',$browserLangPrefs);if(empty($LANGUAGE))$LANGUAGE='english';// Use English if we can't match any of the browser's preferred languagesforeach($browserLangListas$browserLang){$browserLang=';'.strtolower(trim($browserLang));foreach($pgv_lang_useas$language=>$active){if($CONFIGURED&&!$active)continue;// Don't consider any language marked as "inactive"if(strpos(';'.$lang_langcode[$language],$browserLang)===false)continue;$LANGUAGE=$language;// We have a matchbreak2;}}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The language detection code is working as intended. You must configure your browser's language preference so that Chinese is at the top of the list.
If you wish to support both versions of Chinese in the same PhpGedView installation, you'll have to edit the settings of each of the Chinese languages so that the language detection codes are unique. This means that for Simplified Chinese, the detection code list should contain only "zh-cn;" and for Traditional Chinese the list should not contain "zh-cn;"
The logic is this:
Build a list of language codes for all languages that are currently active, in the order in which they occur in the file /index/lang_settings.php .
Try to find the browser's language preferences in the language code list built in (1) above. Try each of the browser's language codes in the order in which the browser provides them. The browser's list is in Preference order.
If (2) doesn't produce a match, use English. That will happen whenever the browser's language list doesn't match any of the languages currently marked as "active" in PhpGedView.
If you are supporting both Simplified and Traditional Chinese and you haven't adjusted the list of language detection codes, PhpGedView will default to Traditional Chinese for the "zh-cn" code. That's because Traditional Chinese occurs before Simplified Chinese in the lang_settings.php file.
Last edit: Gerry Kroll 2018-10-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tracked the results by adding echo to different locations in the code above.
The program detected that the browser language is "zh-cn" ,The value of $browserLangPrefs is also correct.
But in the foreach structure, the final output is still english.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Try accessing my site : https://keldine.ca/phpGedView . It works OK for me when I have my copy of Firefox set to Chinese or Chinese-CN as the topmost entry in the preferred languages list.
Chinese activates Chinese with the Taiwan flag , Chinese-CN activates Chinese with the China flag.
I have not yet tried this with any browsers other than Firefox.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just tried Internet Explorer, Chrome, Opera, and Safari.
Internet Explorer, Chrome, and Opera work just fine. I could not find a language setting in Safari. It appears as though Safari takes its cue from the Windows language settings.
Internet Explorer has zh-HANS and zh-HANT as choices for Simplified and Traditional Chinese. These codes aren't in PhpGedView's language list, so PhpGedView will default to English when these codes are used.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just set up Simplified Chinese and Traditional Chinese in the background. The users are all Chinese browsers (zh-cn), but when they visit the website, the default is English. You must register to log in to display Chinese.
I am adding after this code.
echo $LANGUAGE;Used to detect the result. Found to be the output of "english".I personally think that the following code logic has a problem. Please help me , thank you.
includes/session.php
The language detection code is working as intended. You must configure your browser's language preference so that Chinese is at the top of the list.
If you wish to support both versions of Chinese in the same PhpGedView installation, you'll have to edit the settings of each of the Chinese languages so that the language detection codes are unique. This means that for Simplified Chinese, the detection code list should contain only "zh-cn;" and for Traditional Chinese the list should not contain "zh-cn;"
The logic is this:
If you are supporting both Simplified and Traditional Chinese and you haven't adjusted the list of language detection codes, PhpGedView will default to Traditional Chinese for the "zh-cn" code. That's because Traditional Chinese occurs before Simplified Chinese in the lang_settings.php file.
Last edit: Gerry Kroll 2018-10-13
I tracked the results by adding echo to different locations in the code above.
The program detected that the browser language is "zh-cn" ,The value of $browserLangPrefs is also correct.
But in the foreach structure, the final output is still english.
Try accessing my site : https://keldine.ca/phpGedView . It works OK for me when I have my copy of Firefox set to Chinese or Chinese-CN as the topmost entry in the preferred languages list.
Chinese activates Chinese with the Taiwan flag , Chinese-CN activates Chinese with the China flag.
I have not yet tried this with any browsers other than Firefox.
I just tried Internet Explorer, Chrome, Opera, and Safari.
Internet Explorer, Chrome, and Opera work just fine. I could not find a language setting in Safari. It appears as though Safari takes its cue from the Windows language settings.
Internet Explorer has zh-HANS and zh-HANT as choices for Simplified and Traditional Chinese. These codes aren't in PhpGedView's language list, so PhpGedView will default to English when these codes are used.
I have added the zh-hans code to the configuration.thank you very much!I will continue to test