aboutsummaryrefslogtreecommitdiff
path: root/views/default/js/languages.php
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/js/languages.php')
-rw-r--r--views/default/js/languages.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/views/default/js/languages.php b/views/default/js/languages.php
new file mode 100644
index 000000000..fcf903d4b
--- /dev/null
+++ b/views/default/js/languages.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * @uses $vars['language']
+ * @uses $vars['lc'] if present, client will be sent long expires headers
+ */
+
+$language = $vars['language'];
+$lastcache = elgg_extract('lc', $vars, 0);
+
+// @todo add server-side caching
+if ($lastcache) {
+ // we're relying on lastcache changes to predict language changes
+ $etag = '"' . md5("$language|$lastcache") . '"';
+
+ header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true);
+ header("Pragma: public", true);
+ header("Cache-Control: public", true);
+ header("ETag: $etag");
+
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) === $etag) {
+ header("HTTP/1.1 304 Not Modified");
+ exit;
+ }
+}
+
+$all_translations = elgg_get_config('translations');
+$translations = $all_translations['en'];
+
+if ($language != 'en') {
+ $translations = array_merge($translations, $all_translations[$language]);
+}
+
+echo json_encode($translations); \ No newline at end of file