Feature #347 - Applying some coding rules for the internationalization library.

skala
Ivan Tcholakov 15 years ago
parent fc14b7574a
commit 364a373bdb
  1. 38
      main/inc/lib/internationalization.lib.php
  2. 2
      main/inc/lib/internationalization_database/conversion/character_map_selector.php
  3. 1
      main/inc/lib/internationalization_database/language_detection/update_language_profiles.php
  4. 3
      main/inc/lib/internationalization_database/name_order_conventions.php
  5. 4
      main/inc/lib/internationalization_database/non_utf8_encodings.php
  6. 34
      main/inc/lib/internationalization_internal.lib.php

@ -1,4 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File: internationalization.lib.php
* Internationalization library for Chamilo 1.8.7 LMS
@ -44,9 +46,7 @@ define ('LANGUAGE_DETECT_MAX_DELTA', 140000);
/**
* ----------------------------------------------------------------------------
* Initialization
* ----------------------------------------------------------------------------
*/
/**
@ -81,9 +81,7 @@ function api_set_internationalization_default_encoding($encoding) {
/**
* ----------------------------------------------------------------------------
* Language support
* ----------------------------------------------------------------------------
*/
/**
@ -358,14 +356,12 @@ function api_is_latin1_compatible($language) {
/**
* ----------------------------------------------------------------------------
* Language recognition
* Based on the publication:
* W. B. Cavnar and J. M. Trenkle. N-gram-based text categorization.
* Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis
* and Information Retrieval, 1994.
* @link http://citeseer.ist.psu.edu/cache/papers/cs/810/http:zSzzSzwww.info.unicaen.frzSz~giguetzSzclassifzSzcavnar_trenkle_ngram.pdf/n-gram-based-text.pdf
* ----------------------------------------------------------------------------
*/
function api_detect_language(&$string, $encoding = null) {
@ -385,9 +381,7 @@ function api_detect_language(&$string, $encoding = null) {
/**
* ----------------------------------------------------------------------------
* Date and time formats
* ----------------------------------------------------------------------------
*/
/**
@ -485,9 +479,7 @@ function api_get_months_long($language = null) {
/**
* ----------------------------------------------------------------------------
* Name order conventions
* ----------------------------------------------------------------------------
*/
/**
@ -594,9 +586,7 @@ function api_sort_by_first_name($language = null) {
/**
* ----------------------------------------------------------------------------
* A safe way to calculate binary lenght of a string (as number of bytes)
* ----------------------------------------------------------------------------
*/
/**
@ -620,9 +610,7 @@ function api_byte_count(& $string) {
/**
* ----------------------------------------------------------------------------
* Multibyte string conversion functions
* ----------------------------------------------------------------------------
*/
/**
@ -1089,9 +1077,7 @@ function api_utf8_decode_xml($string, $to_encoding = null) {
/**
* ----------------------------------------------------------------------------
* Common multibyte string functions
* ----------------------------------------------------------------------------
*/
/**
@ -2093,9 +2079,7 @@ function api_ucwords($string, $encoding = null) {
/**
* ----------------------------------------------------------------------------
* String operations using regular expressions
* ----------------------------------------------------------------------------
*/
/**
@ -2219,9 +2203,7 @@ function api_preg_split($pattern, $subject, $limit = -1, $flags = 0, $encoding =
/**
* ----------------------------------------------------------------------------
* Obsolete string operations using regular expressions, to be deprecated
* ----------------------------------------------------------------------------
*/
/**
@ -2428,9 +2410,7 @@ function api_split($pattern, $string, $limit = null) {
/**
* ----------------------------------------------------------------------------
* String comparison
* ----------------------------------------------------------------------------
*/
/**
@ -2507,9 +2487,7 @@ function api_strnatcmp($string1, $string2, $language = null, $encoding = null) {
/**
* ----------------------------------------------------------------------------
* Sorting arrays
* ----------------------------------------------------------------------------
*/
/**
@ -2910,9 +2888,7 @@ function api_rsort(&$array, $sort_flag = SORT_REGULAR, $language = null, $encodi
/**
* ----------------------------------------------------------------------------
* Common sting operations with arrays
* ----------------------------------------------------------------------------
*/
/**
@ -2951,9 +2927,7 @@ function api_in_array_nocase($needle, $haystack, $strict = false, $encoding = nu
/**
* ----------------------------------------------------------------------------
* Encoding management functions
* ----------------------------------------------------------------------------
*/
/**
@ -3220,9 +3194,7 @@ function api_detect_encoding_xml($string, $default_encoding = null) {
/**
* ----------------------------------------------------------------------------
* String validation functions concerning certain encodings
* ----------------------------------------------------------------------------
*/
/**
@ -3408,9 +3380,7 @@ function api_is_valid_ascii(&$string) {
/**
* ----------------------------------------------------------------------------
* Parsing CSV-data.
* ----------------------------------------------------------------------------
*/
/**
@ -3498,9 +3468,7 @@ function api_fgetcsv($handle, $length = null, $delimiter = ',', $enclosure = '"'
/**
* ----------------------------------------------------------------------------
* Miscellaneous routines
* ----------------------------------------------------------------------------
*/
/**
@ -3528,9 +3496,7 @@ function api_html_to_text($string) {
/**
* ----------------------------------------------------------------------------
* Functions for internal use behind this API
* ----------------------------------------------------------------------------
*/
require_once dirname(__FILE__).'/internationalization_internal.lib.php';

@ -1,4 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
// See http://demo.icu-project.org/icu-bin/convexp
return array(

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$_current_dir = str_replace('\\', '/', realpath(dirname(__FILE__))).'/';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
* The following table contains two types of conventions concerning person names:
@ -14,8 +15,6 @@
* "sort_by" - determines you preferable way of sorting person names. The possible values are:
* first_name - sorting names with priority for the first name;
* last_name - sorting names with priority for the last name.
*
* For licensing terms, see dokeos_license.txt.
*/
return array(
'afrikaans' => array( 'format' => 'title first_name last_name', 'sort_by' => 'first_name' ),

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Historical data about non UTF-8 encodings that might be used in Dokeos LMS.
* Historical data about non UTF-8 encodings that might be used in Chamilo LMS.
* The following list may have some inconsistencies.
* Put the probably most used for your language encoding at the first place.
* For licensing terms, see dokeos_license.txt.
*/
return array(
'afrikaans' => array('ISO-8859-15', 'WINDOWS-1252'),

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* ==============================================================================
* File: internationalization_internal.lib.php
* Main API extension library for Chamilo 1.8.7 LMS,
* contains functions for internal use only.
@ -8,7 +9,6 @@
* @author Ivan Tcholakov, <ivantcholakov@gmail.com>, 2009, 2010
* @author More authors, mentioned in the correpsonding fragments of this source.
* @package chamilo.library
* ==============================================================================
*
* Note: All functions and data structures here are not to be used directly.
* See the file internationalization.lib.php which contains the "public" API.
@ -16,9 +16,7 @@
/**
* ----------------------------------------------------------------------------
* Internal constants
* ----------------------------------------------------------------------------
*/
// A regular expression for accessing declared encoding within xml-formatted text.
@ -28,9 +26,7 @@ define('_PCRE_XML_ENCODING', '/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m');
/**
* ----------------------------------------------------------------------------
* Global variables used by some callback functions
* ----------------------------------------------------------------------------
*/
$_api_encoding = null;
@ -38,9 +34,7 @@ $_api_collator = null;
/**
* ----------------------------------------------------------------------------
* Appendix to "Language support"
* ----------------------------------------------------------------------------
*/
/**
@ -90,14 +84,12 @@ function _api_get_latin1_compatible_languages() {
/**
* ----------------------------------------------------------------------------
* Appendix to "Language recognition"
* Based on the publication:
* W. B. Cavnar and J. M. Trenkle. N-gram-based text categorization.
* Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis
* and Information Retrieval, 1994.
* @link http://citeseer.ist.psu.edu/cache/papers/cs/810/http:zSzzSzwww.info.unicaen.frzSz~giguetzSzclassifzSzcavnar_trenkle_ngram.pdf/n-gram-based-text.pdf
* ----------------------------------------------------------------------------
*/
/**
@ -222,9 +214,7 @@ function & _api_compare_n_grams(&$n_grams, $encoding, $max_delta = LANGUAGE_DETE
/**
* ----------------------------------------------------------------------------
* Appendix to "Date and time formats"
* ----------------------------------------------------------------------------
*/
/**
@ -254,9 +244,7 @@ function &_api_get_day_month_names($language = null) {
/**
* ----------------------------------------------------------------------------
* Appendix to "Name order conventions"
* ----------------------------------------------------------------------------
*/
/**
@ -318,9 +306,7 @@ function _api_clean_person_name($person_name) {
/**
* ----------------------------------------------------------------------------
* Appendix to "Multibyte string conversion functions"
* ----------------------------------------------------------------------------
*/
/**
@ -468,7 +454,7 @@ function &_api_parse_character_map($name) {
* @author Henri Sivonen, mailto:hsivonen@iki.fi
* @link http://hsivonen.iki.fi/php-utf8/
* @author Ivan Tcholakov, August 2009, adaptation for the Dokeos LMS.
*/
*/
function _api_utf8_to_unicode(&$string) {
$str = (string)$string;
$state = 0; // cached expected number of octets after the current octet
@ -580,7 +566,7 @@ function _api_utf8_to_unicode(&$string) {
* Takes an array of Unicode codepoints and returns a UTF-8 string.
* @param array $codepoints An array of Unicode codepoints representing a string.
* @return string Returns a UTF-8 string constructed using the given codepoints.
*/
*/
function _api_utf8_from_unicode($codepoints) {
return implode(array_map('_api_utf8_chr', $codepoints));
}
@ -682,9 +668,7 @@ function _api_convert_encoding_xml_callback($matches) {
/**
* ----------------------------------------------------------------------------
* Appendix to "Common multibyte string functions"
* ----------------------------------------------------------------------------
*/
/**
@ -770,9 +754,7 @@ function _api_utf8_ucwords_callback($matches) {
/**
* ----------------------------------------------------------------------------
* Appendix to "Common sting operations with arrays"
* ----------------------------------------------------------------------------
*/
/**
@ -793,9 +775,7 @@ function _api_array_utf8_decode($variable) {
/**
* ----------------------------------------------------------------------------
* Appendix to "String comparison"
* ----------------------------------------------------------------------------
*/
/**
@ -925,9 +905,7 @@ function _api_get_collator_sort_flag($sort_flag = SORT_REGULAR) {
/**
* ----------------------------------------------------------------------------
* ICU locales (accessible through intl extension).
* ----------------------------------------------------------------------------
*/
/**
@ -979,9 +957,7 @@ function api_get_default_locale() {
/**
* ----------------------------------------------------------------------------
* Appendix to "Encoding management functions"
* ----------------------------------------------------------------------------
*/
/**
@ -1229,9 +1205,7 @@ function _api_html_entity_supports($encoding) {
/**
* ----------------------------------------------------------------------------
* Upgrading the PHP5 mbstring extension
* ----------------------------------------------------------------------------
*/
// A multibyte replacement of strchr(). This function exists in PHP 5 >= 5.2.0

Loading…
Cancel
Save