Elgg  Version 3.0
languages.js.php
Go to the documentation of this file.
1 <?php
9 $language = elgg_extract('language', $vars, 'en');
10 
11 // requested language
13 
14 // add site language
16 if (!empty($site_language)) {
18 }
19 
20 // add English fallback
21 $combine_languages['en'] = true;
22 
23 // fetch all translations
24 $all_translations = _elgg_services()->translator->getLoadedTranslations();
25 
26 // make sure all requested languages are loaded
27 foreach (array_keys($combine_languages) as $language) {
28  if (!isset($all_translations[$language])) {
29  _elgg_services()->translator->reloadAllTranslations();
30 
31  $all_translations = _elgg_services()->translator->getLoadedTranslations();
32  break;
33  }
34 }
35 
36 // combine all languages in one result
38 foreach (array_keys($combine_languages) as $language) {
39  if (!isset($all_translations[$language])) {
40  continue;
41  }
42  $translations = array_merge($all_translations[$language], $translations);
43 }
44 
45 ?>
46 define(<?php echo json_encode($translations, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ?>);
foreach(array_keys($combine_languages) as $language) $translations
$language
Build a JSON array of the combined language keys to be used in javascript elgg.echo() ...
Definition: languages.js.php:9
$combine_languages[$language]
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$site_language
$all_translations
define(function(require){var $=require('jquery');var elgg=require('elgg');var spinner=require('elgg/spinner');var Ajax=require('elgg/Ajax');var ajax=new Ajax();function init(){initPluginReordering();$(document).on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);$(document).on('click', '.elgg-plugins-toggle', toggleAllPlugins);$(document).on('click', '.elgg-plugin-state-change', toggleSinglePlugin);$(document).on('mouseenter', '.elgg-plugin-details-screenshots.elgg-plugin-screenshot', showPluginScreenshot);};function freezePlugins(){$('#elgg-plugin-list-cover').css('display', 'block');};function unfreezePlugins(){$('#elgg-plugin-list-cover').css('display', 'none');};function initPluginReordering(){$('#elgg-plugin-list > ul').sortable({items: 'li:has(>.elgg-state-draggable)', handle: '.elgg-body', forcePlaceholderSize:true, placeholder: 'elgg-plugin-placeholder', opacity:0.8, revert:500, stop:movePlugin});};function toggleSinglePlugin(e){freezePlugins();e.preventDefault();ajax.action(this.href).done(function(output, statusText, jqXHR){if(jqXHR.AjaxData.status==-1){location.reload();return;}ajax.path('admin_plugins_refresh').done(function(output){$('#elgg-plugin-list').html(output.list);$('.elgg-sidebar').html(output.sidebar);$(".elgg-admin-plugins-categories > li.elgg-state-selected > a").trigger('click');initPluginReordering();unfreezePlugins();});});};function toggleAllPlugins(e){e.preventDefault();if(!confirm(elgg.echo('question:areyousure'))){return;}freezePlugins();var guids=[], state=$(this).data('desiredState'), find_state=state== 'active'? 'inactive': 'active';$('.elgg-plugin.elgg-state-'+find_state+ ':visible').each(function(){var guid=$(this).data('guid');if(guid){guids.push(guid);}});if(!guids.length){elgg.register_error(elgg.echo('admin:plugins:already:'+state));unfreezePlugins();return;}spinner.start();var $form=$('< form method="post"/>');$form.prop('action', elgg.security.addToken(this.href));$form.append('< input type="hidden"name="guids"value="' + guids.join(',') + '"/>');$form.appendTo("body").submit();};function movePlugin(e, ui){freezePlugins();var pluginGuid=ui.item.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.action('admin/plugins/set_priority',{data:{plugin_guid:pluginGuid, priority:ui.item.index()+1}, success:function(){var priorityDep=new RegExp(elgg.echo('ElggPlugin:Dependencies:Priority'));ui.item.siblings().andSelf().each(function(){if(priorityDep.test($(this).find('.elgg-dependency-requires').text())){updatePluginView($(this));}});unfreezePlugins();}});};function updatePluginView(pluginView){var pluginGuid=pluginView.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.get({url:elgg.config.wwwroot+"ajax/view/object/plugin/full", dataType:"html", cache:false, data:{guid:pluginGuid, display_reordering:true}, success:function(htmlData){if(htmlData.length > 0){pluginView.html(htmlData);}}});};function filterPluginCategory(e){e.preventDefault();$(".elgg-admin-plugins-categories > li").removeClass("elgg-state-selected");$(".elgg-plugin").hide();$(".elgg-plugin-category-"+$(this).attr("rel")).show();$(this).closest('li').addClass("elgg-state-selected");};function showPluginScreenshot(){$(this).parent().find(".elgg-plugin-screenshot").removeClass("elgg-state-selected");$(this).addClass("elgg-state-selected");$(".elgg-plugin-details-screenshots > div > img").hide();$(".elgg-plugin-details-screenshots > div > img[rel='"+$(this).attr("rel")+"']").show();};init();})
$vars['type']
Definition: save.php:11
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
elgg_get_config($name, $default=null)
Get an Elgg configuration value.