24 static $CURRENT_LANGUAGE;
27 if (!is_array(
$args)) {
29 'As of Elgg 1.8, the 2nd arg to elgg_echo() is an array of string replacements and the 3rd arg is the language.',
37 if (!$CURRENT_LANGUAGE) {
45 if (!isset($CONFIG->translations[
$language])) {
53 if (isset($CONFIG->translations[
$language][$message_key])) {
55 }
else if (isset($CONFIG->translations[
"en"][$message_key])) {
56 $string = $CONFIG->translations[
"en"][$message_key];
57 elgg_log(sprintf(
'Missing %s translation for "%s" language key',
$language, $message_key),
'NOTICE');
60 elgg_log(sprintf(
'Missing English translation for "%s" language key', $message_key),
'NOTICE');
87 if (!isset($CONFIG->translations)) {
88 $CONFIG->translations = array();
91 $country_code = strtolower($country_code);
92 $country_code = trim($country_code);
93 if (is_array($language_array) &&
sizeof($language_array) > 0 && $country_code !=
"") {
94 if (!isset($CONFIG->translations[$country_code])) {
95 $CONFIG->translations[$country_code] = $language_array;
97 $CONFIG->translations[$country_code] = $language_array + $CONFIG->translations[$country_code];
134 if ((!
$language) && (isset($CONFIG->language)) && ($CONFIG->language)) {
151 if ($CONFIG->system_cache_enabled) {
164 $CONFIG->i18n_loaded_from_cache =
true;
166 $CONFIG->language_paths[dirname(dirname(dirname(__FILE__))) .
"/languages/"] =
true;
193 if (!empty($CONFIG->system_cache_enabled)) {
217 $languages_path =
"{$plugin->getPath()}languages/";
219 if (!is_dir($languages_path)) {
224 $language_file =
"{$languages_path}{$language}.php";
226 if (!file_exists($language_file)) {
229 $name = $plugin->getFriendlyName();
230 elgg_log(
"Plugin $name is missing translations for $language language",
'NOTICE');
237 $msg =
elgg_echo(
'ElggPlugin:Exception:CannotRegisterLanguages',
238 array($plugin->getID(), $plugin->guid, $languages_path));
261 if (!isset($CONFIG->language_paths)) {
262 $CONFIG->language_paths = array();
264 $CONFIG->language_paths[
$path] =
true;
269 elgg_log(
"Translations loaded from: $path",
"INFO");
272 $load_language_files = array(
274 "$current_language.php" 277 $load_language_files = array_unique($load_language_files);
279 $handle = opendir(
$path);
281 elgg_log(
"Could not open language path: $path",
'ERROR');
286 while (
false !== (
$language = readdir($handle))) {
292 if (in_array(
$language, $load_language_files) || $load_all) {
329 if (!isset($CONFIG->language_paths)) {
330 $CONFIG->language_paths = array();
332 $CONFIG->language_paths[
$path] =
true;
334 $language_file =
"{$path}{$language}.php";
336 if (!file_exists($language_file)) {
337 elgg_log(
"Could not find language file: $language_file",
'NOTICE');
342 $result = include_once($language_file);
344 elgg_log(
"Translations loaded from: $language_file",
"INFO");
368 static $LANG_RELOAD_ALL_RUN;
369 if ($LANG_RELOAD_ALL_RUN) {
373 if ($CONFIG->i18n_loaded_from_cache) {
375 $cache_dir = $cache->getVariable(
"cache_path");
381 if (preg_match(
'/(([a-z]{2,3})(_[a-z]{2})?)\.lang$/', $filename, $matches)) {
390 foreach ($CONFIG->language_paths as
$path => $dummy) {
395 $LANG_RELOAD_ALL_RUN =
true;
410 $installed = array();
412 foreach ($CONFIG->translations as $k => $v) {
413 $installed[$k] =
elgg_echo($k, array(), $k);
416 if (($completeness < 100) && ($k !=
'en')) {
417 $installed[$k] .=
" (" . $completeness .
"% " .
elgg_echo(
'complete') .
")";
440 $en = count($CONFIG->translations[
'en']);
444 $missing = count($missing);
450 $lang = $en - $missing;
452 return round((
$lang / $en) * 100, 2);
471 foreach ($CONFIG->translations[
'en'] as $k => $v) {
472 if ((!isset($CONFIG->translations[
$language][$k]))
473 || ($CONFIG->translations[
$language][$k] == $CONFIG->translations[
'en'][$k])) {
478 if (count($missing)) {
get_current_language()
Detect the current language being used by the current site or logged in user.
_elgg_load_translations_for_language($language)
Load both core and plugin translations for a specific language.
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
if($guid==elgg_get_logged_in_user_guid()) $name
get_language_completeness($language)
Return the level of completeness for a given language code (compared to english)
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
elgg_get_system_cache()
Returns an ElggCache object suitable for caching system information.
reload_all_translations()
Reload all translations from all registered paths.
$args
Some servers don't allow PHP to check the rewrite, so try via AJAX.
_elgg_load_translations()
private
get_missing_language_keys($language)
Return the translation keys missing from a given language, or those that are identical to the english...
elgg_get_file_list($directory, $exceptions=array(), $list=array(), $extensions=null)
Returns a list of files in $directory.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
get_language()
Gets the current language in use by the system or user.
sanitise_string($string)
Wrapper function for alternate English spelling (.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
add_translation($country_code, $language_array)
Add a translation.
elgg_log($message, $level= 'NOTICE')
Display or log a message.
_elgg_register_translations_for_language($path, $language)
When given a full path, finds translation files for a language and loads them.
elgg_get_plugins($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
elgg_load_system_cache($type)
Retrieve the contents of a system cache.
register_translations($path, $load_all=false)
When given a full path, finds translation files and loads them.
get_installed_translations()
Return an array of installed translations as an associative array "two letter code" => "native langua...
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
$language
$vars['language'] $vars['lc'] if present, client will be sent long expires headers ...