diff --git a/Dockerfile b/Dockerfile index db94166..a11313c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,9 @@ FROM ubuntu:18.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 \ libapache2-mod-php php-gd php-curl php-memcached curl python-setuptools \ - python-pip php-sqlite3 php-xml php-mbstring php-cli cron && \ + python-pip php-sqlite3 php-xml php-mbstring php-cli cron \ + language-pack-pt language-pack-en-base language-pack-es \ + libicu-dev php-intl && \ rm -rf /var/lib/apt/lists/* && \ pip install supervisor diff --git a/Dockerfile-dev b/Dockerfile-dev index 143f471..4a4f4cb 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -3,7 +3,9 @@ FROM ubuntu:18.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 \ libapache2-mod-php php-gd php-curl php-memcached curl python-setuptools \ - python-pip php-sqlite3 php-xml php-mbstring php-cli && \ + python-pip php-sqlite3 php-xml php-mbstring php-cli \ + language-pack-pt language-pack-en-base language-pack-es \ + libicu-dev php-intl && \ rm -rf /var/lib/apt/lists/* && \ pip install supervisor diff --git a/application/controllers/Home.php b/application/controllers/Home.php index ae46e18..5910edf 100644 --- a/application/controllers/Home.php +++ b/application/controllers/Home.php @@ -45,6 +45,7 @@ public function __construct() $this->load_about_link(); // The about link is the same in any page, so I load it here in the constructor. $this->load_openaccessdeclaration_link(); // The open access link in footer section, so I load it here in the constructor. $this->load_footer(); // The footer is the same in any page, so I load it here in the constructor. + $this->currentLocale = setlocale(LC_ALL, 0); // it returns the current locale, e.g: pt_BR.UTF8 } /** @@ -207,7 +208,7 @@ public function list_journals_by_alphabetical_order() return; } - $journals = $this->Journals->list_all_journals($limit, $offset, $params['status'], $params['matching'], $params['search'], $params['letter']); + $journals = $this->Journals->list_all_journals($limit, $offset, $params['status'], $params['matching'], $params['search'], $params['letter'], $this->currentLocale); $total_journals = $this->Journals->total_journals($params['status'], $params['matching'], $params['search'], $params['letter']); $journals_links = $this->get_journals_links(); diff --git a/application/models/Journals.php b/application/models/Journals.php index 518df95..a93cb8a 100644 --- a/application/models/Journals.php +++ b/application/models/Journals.php @@ -30,6 +30,19 @@ class Journals extends CI_Model public function __construct() { parent::__construct(); + + $this->db->conn_id->createFunction( + 'locale', + function ($data, $locale = 'root') { + static $collators = array(); + + if (isset($collators[$locale]) !== true) { + $collators[$locale] = new \Collator($locale); + } + + return $collators[$locale]->getSortKey($data); + } + ); } /** @@ -73,7 +86,7 @@ public function list_all_subject_areas($language) * @param string $letter * @return array */ - public function list_all_journals($limit, $offset, $status = false, $matching = false, $search = false, $letter = false) + public function list_all_journals($limit, $offset, $status = false, $matching = false, $search = false, $letter = false, $locale = 'root') { $this->db->from($this->journals_table); @@ -82,7 +95,7 @@ public function list_all_journals($limit, $offset, $status = false, $matching = $this->db->limit($limit, $offset); $this->db->group_by('title_search'); - $this->db->order_by('title_search', 'ASC'); + $this->db->order_by("locale('title', '$locale')"); return $this->get_results_obj(); }