phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Procedural File: _locale.funcs.php

Source Location: /qp_inc/locales/_locale.funcs.php

Page Details

This file implements functions for handling locales and i18n.

This file is part of Quam Plures - http://quamplures.net/ See also https://launchpad.net/quam-plures.

Author:  blueyed: Daniel HAHLER.
Author:  fplanque: Francois PLANQUE.
Copyright:  

(c)2003-2009 by Francois PLANQUE - http://fplanque.net/ Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - http://thequod.de/contact.

Copyright:  (c) 2009 - 2011 by the Quam Plures developers - http://quamplures.net/
Todo:  Make it a class / global object!
  • Provide (static) functions to extract .po files / generate _global.php files (single quoted strings!)
Filesource:  Source Code for this file
Functions
can_convert_charsets  [line 867]

boolean can_convert_charsets( string $dest_charset, string $src_charset  )

Can we convert from charset A to charset B?

Parameters:
string   $dest_charset:  Target charset (TO)
string   $src_charset:  Source charset (FROM)


[ Top ]
convert_charset  [line 836]

string convert_charset( string $string, string $dest_charset, [string $src_charset = NULL]  )

Convert a string from one charset to another.

Parameters:
string   $string:  String to convert
string   $dest_charset:  Target charset (TO)
string   $src_charset:  Source charset (FROM) - leave empty to detect it automatically (UTF8, latin1 or latin15)

API Tags:
Return:  Encoded string (if it cannot be converted it's the original one)
See:  can_convert_charsets()

Information Tags:
Todo:  Implement iconv and PHP mapping tables

[ Top ]
init_charsets  [line 902]

boolean init_charsets( string $req_io_charset  )

Init charset handling between Input/Output ($io_charset) and the internal handling ($evo_charset).

Check and possibly adjust $evo_charset.

Parameters:
string   $req_io_charset:  I/O (input/output) charset to use

API Tags:
Return:  true, if encoding has been changed
Staticvar:  boolean $_trans: Used to only start mb_output_handler once


[ Top ]
locales_load_available_defs  [line 989]

void locales_load_available_defs( )

Load available locale definitions



[ Top ]
locale_activate  [line 308]

void locale_activate( string $locale, boolean 1  )

Activate a locale.

Parameters:
boolean   1:  True on success/change, false on failure (if already set or not existant)
string   $locale:  locale to activate

Information Tags:
Todo:  dh> this should make sure, that e.g. "charset" is set for the locale in $locales. See http://forums.b2evolution.net/viewtopic.php?p=43980#43980

[ Top ]
locale_by_lang  [line 332]

void locale_by_lang( $lang, [ $fallback_to_default = true]  )

locale_by_lang(-)

Find first locale matching lang

Parameters:
   $lang: 
   $fallback_to_default: 


[ Top ]
locale_charset  [line 374]

void locale_charset( [ $disp = true]  )

Returns the charset of the current locale

Parameters:
   $disp: 


[ Top ]
locale_country  [line 452]

string locale_country( [string $locale = '']  )

Get the country locale

Parameters:
string   $locale:  locale to use, '' for current

API Tags:
Return:  country locale


[ Top ]
locale_datefmt  [line 390]

string locale_datefmt( [string $locale = NULL]  )

Returns the current locale's default date format

Parameters:
string   $locale:  Locale, must be set in $locales

API Tags:
Return:  Date format of the locale, e.g. 'd.m.Y'


[ Top ]
locale_datetimefmt  [line 425]

void locale_datetimefmt( [ $separator = ' ']  )
Parameters:
   $separator: 


[ Top ]
locale_dialing_code  [line 465]

void locale_dialing_code( [ $locale = '']  )

Get the locale country dialing code

Parameters:
   $locale: 


[ Top ]
locale_flag  [line 490]

void locale_flag( [string $locale = ''], [string $collection = 'w16px'], [string $class = 'flag'], [string $align = ''], [boolean $disp = true], [mixed $absoluteurl = true]  )

T-Tag: Displays or returns an author's locale flag

Parameters:
string   $locale:  locale to use, '' for current
string   $collection:  collection name (subdir of img/flags)
string   $class:  name of class for IMG tag
string   $align:  deprecated HTML align attribute
boolean   $disp:  to echo or not
mixed   $absoluteurl:  use absolute url (===true) or path to flags directory


[ Top ]
locale_from_httpaccept  [line 597]

locale locale_from_httpaccept( )

Detect language from HTTP_ACCEPT_LANGUAGE

First matched full locale code in HTTP_ACCEPT_LANGUAGE will win Otherwise, first locale in table matching a lang code will win


API Tags:
Return:  made out of HTTP_ACCEPT_LANGUAGE or $default_locale, if no match


[ Top ]
locale_lang  [line 360]

string locale_lang( [boolean $disp = true]  )

Displays/Returns the current locale. (for backward compatibility)

This is for HTML lang attributes

Parameters:
boolean   $disp:  true (default) if we want it to be outputted

API Tags:
Return:  current locale, if $disp = false


[ Top ]
locale_options  [line 537]

string|array locale_options( [string $default = ''], [boolean $disp = true], [boolean $array_if_onelocale = false]  )

[callback function] Outputs an <option> set with default locale selected.

Optionally returns an array with a locale key and name if there's only one enabled locale.

Parameters:
string   $default:  default value
boolean   $disp:  echo output?
boolean   $array_if_onelocale:  Return array (locale key + name) if there's only one enabled locale?

API Tags:
Return:  The options string or an array (locale key + name) if there's only one enabled locale and $array_if_onelocale == true.


[ Top ]
locale_options_return  [line 582]

void locale_options_return( [string $default = '']  )

[callback function] Returns an <option> set with default locale selected

Parameters:
string   $default:  default value


[ Top ]
locale_overwritefromDB  [line 659]

mixed locale_overwritefromDB( )

load locales from DB into $locales array. Also sets $default_locale.


API Tags:
Return:  new default locale on succes, false on failure


[ Top ]
locale_priosort  [line 648]

void locale_priosort( $a, $b  )

user sort function to sort locales by priority

  1. is highest priority.

Parameters:
   $a: 
   $b: 


[ Top ]
locale_restore_previous  [line 287]

boolean locale_restore_previous( )

T-Tag: Restore the locale in use before the switch


API Tags:
Return:  true on success, false on failure (no locale stored before)
See:  locale_temp_switch()


[ Top ]
locale_shorttimefmt  [line 417]

void locale_shorttimefmt( )

Returns the current locale's default short time format



[ Top ]
locale_startofweek  [line 437]

integer locale_startofweek( )

Returns the current locale's start of week


API Tags:
Return:  0 for Sunday, 1 for Monday


[ Top ]
locale_temp_switch  [line 258]

boolean locale_temp_switch( string $locale  )

T-tag: Temporarily switch to another locale

Calls can be nested

Parameters:
string   $locale:  locale to activate

API Tags:
Return:  true on success, false on failure
See:  locale_restore_previous()


[ Top ]
locale_timefmt  [line 407]

void locale_timefmt( )

Returns the current locale's default time format



[ Top ]
locale_updateDB  [line 759]

void locale_updateDB( )

Write $locales array to DB table



[ Top ]
TS_  [line 243]

string TS_( string $string, [string $req_locale = ''], [array $params = array()]  )

Translate and escape single quotes.

This is to be used mainly for Javascript strings.

Parameters:
string   $string:  String to translate
string   $req_locale:  Locale to use
array   $params:  See T_()

API Tags:
Return:  The translated and escaped string.
Uses:  T_()


[ Top ]
T_  [line 63]

string T_( string $string, [string $req_locale = ''], [array $params = array()]  )

TRANSLATE!

Translate a text to the desired locale or to the current locale.

Parameters:
string   $string:  String to translate, '' to get language file info (as in gettext spec)
string   $req_locale:  locale to translate to, '' to use current locale
array   $params:  Array containing the following keys (all optional):
  • 'ext_transarray': A reference to an alternate array to use for the caching of the translated strings or NULL to use the internal array.
  • 'alt_basedir': Alternate base directory to search for translations, e. g. a plugin or template directory.
  • 'for_helper': (boolean) Is the translation for the b2evoHelper object?

API Tags:
Return:  The translated string or the original string on error.
Usedby:  TS_()


[ Top ]