languages.php 838 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @uses $vars['language']
  4. */
  5. $language = elgg_extract('language', $vars);
  6. if (empty($language)) {
  7. // try to detect it
  8. preg_match("/\/js\/languages\/(.*?).js+/", current_page_url(), $matches);
  9. if (!empty($matches) && isset($matches[1])) {
  10. $language = $matches[1];
  11. }
  12. }
  13. if (empty($language)) {
  14. // fallback to 'en'
  15. $language = 'en';
  16. }
  17. $all_translations = elgg_get_config('translations');
  18. $translations = $all_translations['en'];
  19. if ($language != 'en' && !isset($all_translations[$language])) {
  20. // try to reload missing translations
  21. reload_all_translations();
  22. $all_translations = elgg_get_config('translations');
  23. }
  24. if ($language != 'en' && isset($all_translations[$language])) {
  25. $translations = array_merge($translations, $all_translations[$language]);
  26. }
  27. ?>
  28. define(<?php echo json_encode($translations); ?>);