diff --git a/lib/Alchemy/Phrasea/Controller/Root/Root.php b/lib/Alchemy/Phrasea/Controller/Root/Root.php
index ea4940ad17..4b755d5e71 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Root.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Root.php
@@ -31,6 +31,10 @@ class Root implements ControllerProviderInterface
->get('/', $this->call('getRoot'))
->bind('root');
+ $controllers
+ ->get('/available-languages', $this->call('getAvailableLanguages'))
+ ->bind('available_languages');
+
$controllers
->get('/robots.txt', $this->call('getRobots'))
->bind('robots');
@@ -70,6 +74,11 @@ class Root implements ControllerProviderInterface
return $response;
}
+ public function getAvailableLanguages(Application $app, Request $request)
+ {
+ return $app->json($app['locales.I18n.available']);
+ }
+
/**
* Prefix the method to call with the controller class name
*
diff --git a/templates/web/admin/fields/templates.html.twig b/templates/web/admin/fields/templates.html.twig
index f79122d5a9..b1e5e2d40b 100644
--- a/templates/web/admin/fields/templates.html.twig
+++ b/templates/web/admin/fields/templates.html.twig
@@ -55,15 +55,13 @@
@@ -105,15 +103,15 @@
- - FR
- - EN
- - DE
- - NL
+
+ <% _.each(field.labels, function(value, code) { %>
+ - <%= code %>
+ <% }); %>
+
-
-
-
-
+ <% _.each(field.labels, function(value, code) { %>
+ >
+ <% }); %>
|
diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php
index 174527ef36..f1d26abbd8 100644
--- a/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php
+++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php
@@ -40,6 +40,14 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertRegExp('/^\/login\/\?redirect=[\/a-zA-Z]+/', $response->headers->get('location'));
}
+ public function testRouteAvailableLanguages()
+ {
+ $crawler = self::$DI['client']->request('GET', '/available-languages');
+ $response = self::$DI['client']->getResponse();
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals((array) json_decode($response->getContent()), self::$DI['app']['locales.I18n.available']);
+ }
+
public function testRouteRobots()
{
$original_value = self::$DI['app']['phraseanet.registry']->get('GV_allow_search_engine');
diff --git a/www/scripts/apps/admin/fields/app.js b/www/scripts/apps/admin/fields/app.js
index 3916b05b8a..64e039fe2f 100644
--- a/www/scripts/apps/admin/fields/app.js
+++ b/www/scripts/apps/admin/fields/app.js
@@ -58,13 +58,19 @@ define([
AdminFieldApp.dcFieldsCollection = new DcFieldsCollection();
// load strings
- i18n.init({ resGetPath: "/admin/fields/language.json"});
+ i18n.init({resGetPath: "/admin/fields/language.json"});
// load all collections
$.when.apply($, [
AdminFieldApp.fieldsCollection.fetch(),
AdminFieldApp.vocabularyCollection.fetch(),
- AdminFieldApp.dcFieldsCollection.fetch()
+ AdminFieldApp.dcFieldsCollection.fetch(),
+ $.ajax({
+ url: '/available-languages',
+ success: function(languages) {
+ AdminFieldApp.languages = languages;
+ }
+ })
]).done(
function() {
// register views
diff --git a/www/scripts/apps/admin/fields/views/create.js b/www/scripts/apps/admin/fields/views/create.js
index 9dd020aedf..0cc395dc01 100644
--- a/www/scripts/apps/admin/fields/views/create.js
+++ b/www/scripts/apps/admin/fields/views/create.js
@@ -25,7 +25,9 @@ define([
"click .lng-label a": "_toggleLabels"
},
render: function() {
- var template = _.template($("#create_template").html());
+ var template = _.template($("#create_template").html(), {
+ languages: AdminFieldApp.languages
+ });
this.$el.html(template);
diff --git a/www/scripts/apps/admin/fields/views/list.js b/www/scripts/apps/admin/fields/views/list.js
index 96f93a1fc2..c8f0b0c1c2 100644
--- a/www/scripts/apps/admin/fields/views/list.js
+++ b/www/scripts/apps/admin/fields/views/list.js
@@ -54,7 +54,7 @@ define([
});
},
render: function() {
- var template = _.template($("#item_list_view_template").html(), {});
+ var template = _.template($("#item_list_view_template").html());
this.$el.empty().html(template);