PHP Classes

lang_detect: Language setting detection

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 47%Total: 2,580 All time: 1,479 This week: 560Up
Version License Categories
lang_detect 1.0GNU General Publi...Localization
Description 

Author

Allows to find out the client's browser language settings and check for given locales in those settings

Picture of Carlos Falo Hervás
Name: Carlos Falo Hervás <contact>
Classes: 10 packages by
Country: Spain Spain
Age: 49
All time rank: 361 in Spain Spain
Week rank: 109 Down5 in Spain Spain Down
Innovation award
Innovation award
Nominee: 1x

Details

===== BASIC DOCUMENTATION FOR LANG DETECT CLASS ===== 0.- INTRODUCTION This Class is designed to check for the user's language preferences and to match for given locales. NOTES: All locales are composed by 3 elements: PREFIX-SUBCLASS ; QUALITY=value PREFIX: is the main language identifier (i.e. en-us, en-ca,... have prefix EN) SUBCLASS: is a subdivision for main language (prefix) (i.e. en-us runs for english - united states) IT CAN BE BLANK QUALITY: is the importance for given language... primary language setting defaults to 1 (100%), normally secondary and further selections have a lower Q value (value <1). 1.- INTERFACE The public interface for the class is formed by: PUBLIC VARIABLES: $langs: Counter for the number of accepted languages in the client's browser $lang_list: List of the accepted languages. PAIRS $locale => Q*100 PUBLIC FUNCTIONS: lang_detect() CONSTRUCTOR: Initialize the language list is_primarylang($locale) Returns 1 if the PREFIX for $locale matches the PREFIX for the primary language selected by the user $locale -> locale string get_primarylang() Returns the full locale string for the client's primary language selection get_primaryprefix() Returns the PREFIX string for the client's primary language selection find_lang($loc) Retunrs QUALITY for PREFIX in given $loc (QUALITY = q*100 -> percent) $loc -> locale string get_list($arr,&$sublist) Fills $sublist with an array of matching locales from $arr in the clients language selection ordered by QUALITY (DESC). $arr -> An array with the locales to match &$sublist -> destination array (it is converted to array internally) EXAMPLE: Imagine a language selection of en, es; q=0.5, fr; q=0.3 Calling get_list with $arr = Array("de","en","es) fills $sublist with: "en" => 100 , "es" => 50 print_list() Echo to screen a list for the users language selections (this is a debug function, basically useful for testing) 2.- Future releases and WIP This class will not have many revisions as it is fully functional for it's intended use. For furtehr developement any suggestions are wellcome 3.- Contact information Carlos Falo Hervás carles@bisinteractive.net http://www.bisinteractive.net C/Manila 54-56 Esc. A Ent. 4ª 08034 Barcelona Spain Phone: +34 9 3 2063652 Fax: +34 9 3 2063689

  Files folder image Files  
File Role Description
Plain text file language.class.php Class base class
Accessible without login Plain text file LICENSE Doc. GNU GPL License
Accessible without login Plain text file README_EN.txt Doc. Help file in english

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,580
This week:0
All time:1,479
This week:560Up
 User Ratings  
 
 All time
Utility:64%StarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:75%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:47%StarStarStar
Rank:2992