Added support for language LDAP attribute
This commit is contained in:
@@ -6,6 +6,7 @@ New features:
|
|||||||
* Added automated action to change task color based on the priority
|
* Added automated action to change task color based on the priority
|
||||||
* Added support for LDAP Posix Groups (OpenLDAP with memberUid)
|
* Added support for LDAP Posix Groups (OpenLDAP with memberUid)
|
||||||
* Added support for LDAP user photo attribute (Avatar image)
|
* Added support for LDAP user photo attribute (Avatar image)
|
||||||
|
* Added support for language LDAP attribute
|
||||||
* Search in activity stream
|
* Search in activity stream
|
||||||
* Search in comments
|
* Search in comments
|
||||||
* Search by task creator
|
* Search by task creator
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class App extends \Kanboard\Core\Base
|
|||||||
{
|
{
|
||||||
public function getTimezone()
|
public function getTimezone()
|
||||||
{
|
{
|
||||||
return $this->config->get('application_timezone');
|
return $this->timezone->getCurrentTimezone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Config extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config->save($values)) {
|
if ($this->config->save($values)) {
|
||||||
$this->config->reload();
|
$this->language->loadCurrentLanguage();
|
||||||
$this->flash->success(t('Settings saved successfully.'));
|
$this->flash->success(t('Settings saved successfully.'));
|
||||||
} else {
|
} else {
|
||||||
$this->flash->failure(t('Unable to save your settings.'));
|
$this->flash->failure(t('Unable to save your settings.'));
|
||||||
@@ -90,8 +90,8 @@ class Config extends Base
|
|||||||
$this->common('application');
|
$this->common('application');
|
||||||
|
|
||||||
$this->response->html($this->helper->layout->config('config/application', array(
|
$this->response->html($this->helper->layout->config('config/application', array(
|
||||||
'languages' => $this->config->getLanguages(),
|
'languages' => $this->language->getLanguages(),
|
||||||
'timezones' => $this->config->getTimezones(),
|
'timezones' => $this->timezone->getTimezones(),
|
||||||
'date_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateFormats()),
|
'date_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateFormats()),
|
||||||
'datetime_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateTimeFormats()),
|
'datetime_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateTimeFormats()),
|
||||||
'time_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getTimeFormats()),
|
'time_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getTimeFormats()),
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class Currency extends Base
|
|||||||
$values = $this->request->getValues();
|
$values = $this->request->getValues();
|
||||||
|
|
||||||
if ($this->config->save($values)) {
|
if ($this->config->save($values)) {
|
||||||
$this->config->reload();
|
|
||||||
$this->flash->success(t('Settings saved successfully.'));
|
$this->flash->success(t('Settings saved successfully.'));
|
||||||
} else {
|
} else {
|
||||||
$this->flash->failure(t('Unable to save your settings.'));
|
$this->flash->failure(t('Unable to save your settings.'));
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Doc extends Base
|
|||||||
$page = 'index';
|
$page = 'index';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config->getCurrentLanguage() === 'fr_FR') {
|
if ($this->language->getCurrentLanguage() === 'fr_FR') {
|
||||||
$filename = __DIR__.'/../../doc/fr/' . $page . '.markdown';
|
$filename = __DIR__.'/../../doc/fr/' . $page . '.markdown';
|
||||||
} else {
|
} else {
|
||||||
$filename = __DIR__ . '/../../doc/' . $page . '.markdown';
|
$filename = __DIR__ . '/../../doc/' . $page . '.markdown';
|
||||||
@@ -83,7 +83,7 @@ class Doc extends Base
|
|||||||
*/
|
*/
|
||||||
public function replaceImageUrl(array $matches)
|
public function replaceImageUrl(array $matches)
|
||||||
{
|
{
|
||||||
if ($this->config->getCurrentLanguage() === 'fr_FR') {
|
if ($this->language->getCurrentLanguage() === 'fr_FR') {
|
||||||
return '('.$this->helper->url->base().'doc/fr/'.$matches[1].')';
|
return '('.$this->helper->url->base().'doc/fr/'.$matches[1].')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ class User extends Base
|
|||||||
$is_remote = $this->request->getIntegerParam('remote') == 1 || (isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1);
|
$is_remote = $this->request->getIntegerParam('remote') == 1 || (isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1);
|
||||||
|
|
||||||
$this->response->html($this->helper->layout->app($is_remote ? 'user/create_remote' : 'user/create_local', array(
|
$this->response->html($this->helper->layout->app($is_remote ? 'user/create_remote' : 'user/create_local', array(
|
||||||
'timezones' => $this->config->getTimezones(true),
|
'timezones' => $this->timezone->getTimezones(true),
|
||||||
'languages' => $this->config->getLanguages(true),
|
'languages' => $this->language->getLanguages(true),
|
||||||
'roles' => $this->role->getApplicationRoles(),
|
'roles' => $this->role->getApplicationRoles(),
|
||||||
'projects' => $this->project->getList(),
|
'projects' => $this->project->getList(),
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
@@ -121,8 +121,8 @@ class User extends Base
|
|||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$this->response->html($this->helper->layout->user('user/show', array(
|
$this->response->html($this->helper->layout->user('user/show', array(
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'timezones' => $this->config->getTimezones(true),
|
'timezones' => $this->timezone->getTimezones(true),
|
||||||
'languages' => $this->config->getLanguages(true),
|
'languages' => $this->language->getLanguages(true),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ class User extends Base
|
|||||||
|
|
||||||
$this->response->html($this->helper->layout->user('user/integrations', array(
|
$this->response->html($this->helper->layout->user('user/integrations', array(
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'values' => $this->userMetadata->getall($user['id']),
|
'values' => $this->userMetadata->getAll($user['id']),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,8 +365,8 @@ class User extends Base
|
|||||||
'values' => $values,
|
'values' => $values,
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'timezones' => $this->config->getTimezones(true),
|
'timezones' => $this->timezone->getTimezones(true),
|
||||||
'languages' => $this->config->getLanguages(true),
|
'languages' => $this->language->getLanguages(true),
|
||||||
'roles' => $this->role->getApplicationRoles(),
|
'roles' => $this->role->getApplicationRoles(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ use Pimple\Container;
|
|||||||
* @property \Kanboard\Model\ProjectFile $projectFile
|
* @property \Kanboard\Model\ProjectFile $projectFile
|
||||||
* @property \Kanboard\Model\Group $group
|
* @property \Kanboard\Model\Group $group
|
||||||
* @property \Kanboard\Model\GroupMember $groupMember
|
* @property \Kanboard\Model\GroupMember $groupMember
|
||||||
|
* @property \Kanboard\Model\Language $language
|
||||||
* @property \Kanboard\Model\LastLogin $lastLogin
|
* @property \Kanboard\Model\LastLogin $lastLogin
|
||||||
* @property \Kanboard\Model\Link $link
|
* @property \Kanboard\Model\Link $link
|
||||||
* @property \Kanboard\Model\Notification $notification
|
* @property \Kanboard\Model\Notification $notification
|
||||||
@@ -95,6 +96,7 @@ use Pimple\Container;
|
|||||||
* @property \Kanboard\Model\TaskPosition $taskPosition
|
* @property \Kanboard\Model\TaskPosition $taskPosition
|
||||||
* @property \Kanboard\Model\TaskStatus $taskStatus
|
* @property \Kanboard\Model\TaskStatus $taskStatus
|
||||||
* @property \Kanboard\Model\TaskMetadata $taskMetadata
|
* @property \Kanboard\Model\TaskMetadata $taskMetadata
|
||||||
|
* @property \Kanboard\Model\Timezone $timezone
|
||||||
* @property \Kanboard\Model\Transition $transition
|
* @property \Kanboard\Model\Transition $transition
|
||||||
* @property \Kanboard\Model\User $user
|
* @property \Kanboard\Model\User $user
|
||||||
* @property \Kanboard\Model\UserLocking $userLocking
|
* @property \Kanboard\Model\UserLocking $userLocking
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ class User
|
|||||||
$entry->getFirstValue($this->getAttributeEmail()),
|
$entry->getFirstValue($this->getAttributeEmail()),
|
||||||
$this->getRole($groupIds),
|
$this->getRole($groupIds),
|
||||||
$groupIds,
|
$groupIds,
|
||||||
$entry->getFirstValue($this->getAttributePhoto())
|
$entry->getFirstValue($this->getAttributePhoto()),
|
||||||
|
$entry->getFirstValue($this->getAttributeLanguage())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +167,7 @@ class User
|
|||||||
$this->getAttributeEmail(),
|
$this->getAttributeEmail(),
|
||||||
$this->getAttributeGroup(),
|
$this->getAttributeGroup(),
|
||||||
$this->getAttributePhoto(),
|
$this->getAttributePhoto(),
|
||||||
|
$this->getAttributeLanguage(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +238,17 @@ class User
|
|||||||
return strtolower(LDAP_USER_ATTRIBUTE_PHOTO);
|
return strtolower(LDAP_USER_ATTRIBUTE_PHOTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get LDAP language attribute
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAttributeLanguage()
|
||||||
|
{
|
||||||
|
return strtolower(LDAP_USER_ATTRIBUTE_LANGUAGE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get LDAP Group User filter
|
* Get LDAP Group User filter
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class TaskCalendarFormatter extends BaseTaskCalendarFormatter implements Formatt
|
|||||||
|
|
||||||
foreach ($this->query->findAll() as $task) {
|
foreach ($this->query->findAll() as $task) {
|
||||||
$events[] = array(
|
$events[] = array(
|
||||||
'timezoneParam' => $this->config->getCurrentTimezone(),
|
'timezoneParam' => $this->timezone->getCurrentTimezone(),
|
||||||
'id' => $task['id'],
|
'id' => $task['id'],
|
||||||
'title' => t('#%d', $task['id']).' '.$task['title'],
|
'title' => t('#%d', $task['id']).' '.$task['title'],
|
||||||
'backgroundColor' => $this->color->getBackgroundColor($task['color_id']),
|
'backgroundColor' => $this->color->getBackgroundColor($task['color_id']),
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class AppHelper extends Base
|
|||||||
*/
|
*/
|
||||||
public function jsLang()
|
public function jsLang()
|
||||||
{
|
{
|
||||||
return $this->config->getJsLanguageCode();
|
return $this->language->getJsLanguageCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,7 +101,7 @@ class AppHelper extends Base
|
|||||||
*/
|
*/
|
||||||
public function getTimezone()
|
public function getTimezone()
|
||||||
{
|
{
|
||||||
return $this->config->getCurrentTimezone();
|
return $this->timezone->getCurrentTimezone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Kanboard\Model;
|
namespace Kanboard\Model;
|
||||||
|
|
||||||
use Kanboard\Core\Translator;
|
|
||||||
use Kanboard\Core\Security\Token;
|
use Kanboard\Core\Security\Token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,162 +13,7 @@ use Kanboard\Core\Security\Token;
|
|||||||
class Config extends Setting
|
class Config extends Setting
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get available timezones
|
* Get a config variable with in-memory caching
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param boolean $prepend Prepend a default value
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTimezones($prepend = false)
|
|
||||||
{
|
|
||||||
$timezones = timezone_identifiers_list();
|
|
||||||
$listing = array_combine(array_values($timezones), $timezones);
|
|
||||||
|
|
||||||
if ($prepend) {
|
|
||||||
return array('' => t('Application default')) + $listing;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $listing;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get current timezone
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCurrentTimezone()
|
|
||||||
{
|
|
||||||
if ($this->userSession->isLogged() && ! empty($this->sessionStorage->user['timezone'])) {
|
|
||||||
return $this->sessionStorage->user['timezone'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->get('application_timezone', 'UTC');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set timezone
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function setupTimezone()
|
|
||||||
{
|
|
||||||
date_default_timezone_set($this->getCurrentTimezone());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get available languages
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param boolean $prepend Prepend a default value
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getLanguages($prepend = false)
|
|
||||||
{
|
|
||||||
// Sorted by value
|
|
||||||
$languages = array(
|
|
||||||
'id_ID' => 'Bahasa Indonesia',
|
|
||||||
'bs_BA' => 'Bosanski',
|
|
||||||
'cs_CZ' => 'Čeština',
|
|
||||||
'da_DK' => 'Dansk',
|
|
||||||
'de_DE' => 'Deutsch',
|
|
||||||
'en_US' => 'English',
|
|
||||||
'es_ES' => 'Español',
|
|
||||||
'fr_FR' => 'Français',
|
|
||||||
'el_GR' => 'Grec',
|
|
||||||
'it_IT' => 'Italiano',
|
|
||||||
'hu_HU' => 'Magyar',
|
|
||||||
'my_MY' => 'Melayu',
|
|
||||||
'nl_NL' => 'Nederlands',
|
|
||||||
'nb_NO' => 'Norsk',
|
|
||||||
'pl_PL' => 'Polski',
|
|
||||||
'pt_PT' => 'Português',
|
|
||||||
'pt_BR' => 'Português (Brasil)',
|
|
||||||
'ru_RU' => 'Русский',
|
|
||||||
'sr_Latn_RS' => 'Srpski',
|
|
||||||
'fi_FI' => 'Suomi',
|
|
||||||
'sv_SE' => 'Svenska',
|
|
||||||
'tr_TR' => 'Türkçe',
|
|
||||||
'ko_KR' => '한국어',
|
|
||||||
'zh_CN' => '中文(简体)',
|
|
||||||
'ja_JP' => '日本語',
|
|
||||||
'th_TH' => 'ไทย',
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($prepend) {
|
|
||||||
return array('' => t('Application default')) + $languages;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $languages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get javascript language code
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getJsLanguageCode()
|
|
||||||
{
|
|
||||||
$languages = array(
|
|
||||||
'cs_CZ' => 'cs',
|
|
||||||
'da_DK' => 'da',
|
|
||||||
'de_DE' => 'de',
|
|
||||||
'en_US' => 'en',
|
|
||||||
'es_ES' => 'es',
|
|
||||||
'fr_FR' => 'fr',
|
|
||||||
'it_IT' => 'it',
|
|
||||||
'hu_HU' => 'hu',
|
|
||||||
'nl_NL' => 'nl',
|
|
||||||
'nb_NO' => 'nb',
|
|
||||||
'pl_PL' => 'pl',
|
|
||||||
'pt_PT' => 'pt',
|
|
||||||
'pt_BR' => 'pt-br',
|
|
||||||
'ru_RU' => 'ru',
|
|
||||||
'sr_Latn_RS' => 'sr',
|
|
||||||
'fi_FI' => 'fi',
|
|
||||||
'sv_SE' => 'sv',
|
|
||||||
'tr_TR' => 'tr',
|
|
||||||
'ko_KR' => 'ko',
|
|
||||||
'zh_CN' => 'zh-cn',
|
|
||||||
'ja_JP' => 'ja',
|
|
||||||
'th_TH' => 'th',
|
|
||||||
'id_ID' => 'id',
|
|
||||||
'el_GR' => 'el',
|
|
||||||
);
|
|
||||||
|
|
||||||
$lang = $this->getCurrentLanguage();
|
|
||||||
|
|
||||||
return isset($languages[$lang]) ? $languages[$lang] : 'en';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get current language
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCurrentLanguage()
|
|
||||||
{
|
|
||||||
if ($this->userSession->isLogged() && ! empty($this->sessionStorage->user['language'])) {
|
|
||||||
return $this->sessionStorage->user['language'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->get('application_language', 'en_US');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load translations
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function setupTranslations()
|
|
||||||
{
|
|
||||||
Translator::load($this->getCurrentLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a config variable from the session or the database
|
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $name Parameter name
|
* @param string $name Parameter name
|
||||||
@@ -182,16 +26,6 @@ class Config extends Setting
|
|||||||
return isset($options[$name]) && $options[$name] !== '' ? $options[$name] : $default_value;
|
return isset($options[$name]) && $options[$name] !== '' ? $options[$name] : $default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reload settings in the session and the translations
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function reload()
|
|
||||||
{
|
|
||||||
$this->setupTranslations();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimize the Sqlite database
|
* Optimize the Sqlite database
|
||||||
*
|
*
|
||||||
@@ -200,7 +34,7 @@ class Config extends Setting
|
|||||||
*/
|
*/
|
||||||
public function optimizeDatabase()
|
public function optimizeDatabase()
|
||||||
{
|
{
|
||||||
return $this->db->getconnection()->exec('VACUUM');
|
return $this->db->getConnection()->exec('VACUUM');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
178
app/Model/Language.php
Normal file
178
app/Model/Language.php
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Model;
|
||||||
|
|
||||||
|
use Kanboard\Core\Translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Language
|
||||||
|
*
|
||||||
|
* @package Kanboard\Model
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class Language extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get all language codes
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @access public
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public static function getCodes()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'id_ID',
|
||||||
|
'bs_BA',
|
||||||
|
'cs_CZ',
|
||||||
|
'da_DK',
|
||||||
|
'de_DE',
|
||||||
|
'en_US',
|
||||||
|
'es_ES',
|
||||||
|
'fr_FR',
|
||||||
|
'el_GR',
|
||||||
|
'it_IT',
|
||||||
|
'hu_HU',
|
||||||
|
'my_MY',
|
||||||
|
'nl_NL',
|
||||||
|
'nb_NO',
|
||||||
|
'pl_PL',
|
||||||
|
'pt_PT',
|
||||||
|
'pt_BR',
|
||||||
|
'ru_RU',
|
||||||
|
'sr_Latn_RS',
|
||||||
|
'fi_FI',
|
||||||
|
'sv_SE',
|
||||||
|
'tr_TR',
|
||||||
|
'ko_KR',
|
||||||
|
'zh_CN',
|
||||||
|
'ja_JP',
|
||||||
|
'th_TH',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find language code
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @access public
|
||||||
|
* @param string $code
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function findCode($code)
|
||||||
|
{
|
||||||
|
$code = str_replace('-', '_', $code);
|
||||||
|
return in_array($code, self::getCodes()) ? $code : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get available languages
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param boolean $prepend Prepend a default value
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getLanguages($prepend = false)
|
||||||
|
{
|
||||||
|
// Sorted by value
|
||||||
|
$languages = array(
|
||||||
|
'id_ID' => 'Bahasa Indonesia',
|
||||||
|
'bs_BA' => 'Bosanski',
|
||||||
|
'cs_CZ' => 'Čeština',
|
||||||
|
'da_DK' => 'Dansk',
|
||||||
|
'de_DE' => 'Deutsch',
|
||||||
|
'en_US' => 'English',
|
||||||
|
'es_ES' => 'Español',
|
||||||
|
'fr_FR' => 'Français',
|
||||||
|
'el_GR' => 'Grec',
|
||||||
|
'it_IT' => 'Italiano',
|
||||||
|
'hu_HU' => 'Magyar',
|
||||||
|
'my_MY' => 'Melayu',
|
||||||
|
'nl_NL' => 'Nederlands',
|
||||||
|
'nb_NO' => 'Norsk',
|
||||||
|
'pl_PL' => 'Polski',
|
||||||
|
'pt_PT' => 'Português',
|
||||||
|
'pt_BR' => 'Português (Brasil)',
|
||||||
|
'ru_RU' => 'Русский',
|
||||||
|
'sr_Latn_RS' => 'Srpski',
|
||||||
|
'fi_FI' => 'Suomi',
|
||||||
|
'sv_SE' => 'Svenska',
|
||||||
|
'tr_TR' => 'Türkçe',
|
||||||
|
'ko_KR' => '한국어',
|
||||||
|
'zh_CN' => '中文(简体)',
|
||||||
|
'ja_JP' => '日本語',
|
||||||
|
'th_TH' => 'ไทย',
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
return array('' => t('Application default')) + $languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get javascript language code
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getJsLanguageCode()
|
||||||
|
{
|
||||||
|
$languages = array(
|
||||||
|
'cs_CZ' => 'cs',
|
||||||
|
'da_DK' => 'da',
|
||||||
|
'de_DE' => 'de',
|
||||||
|
'en_US' => 'en',
|
||||||
|
'es_ES' => 'es',
|
||||||
|
'fr_FR' => 'fr',
|
||||||
|
'it_IT' => 'it',
|
||||||
|
'hu_HU' => 'hu',
|
||||||
|
'nl_NL' => 'nl',
|
||||||
|
'nb_NO' => 'nb',
|
||||||
|
'pl_PL' => 'pl',
|
||||||
|
'pt_PT' => 'pt',
|
||||||
|
'pt_BR' => 'pt-br',
|
||||||
|
'ru_RU' => 'ru',
|
||||||
|
'sr_Latn_RS' => 'sr',
|
||||||
|
'fi_FI' => 'fi',
|
||||||
|
'sv_SE' => 'sv',
|
||||||
|
'tr_TR' => 'tr',
|
||||||
|
'ko_KR' => 'ko',
|
||||||
|
'zh_CN' => 'zh-cn',
|
||||||
|
'ja_JP' => 'ja',
|
||||||
|
'th_TH' => 'th',
|
||||||
|
'id_ID' => 'id',
|
||||||
|
'el_GR' => 'el',
|
||||||
|
);
|
||||||
|
|
||||||
|
$lang = $this->getCurrentLanguage();
|
||||||
|
|
||||||
|
return isset($languages[$lang]) ? $languages[$lang] : 'en';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current language
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCurrentLanguage()
|
||||||
|
{
|
||||||
|
if ($this->userSession->isLogged() && ! empty($this->sessionStorage->user['language'])) {
|
||||||
|
return $this->sessionStorage->user['language'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->config->get('application_language', 'en_US');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load translations for the current language
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function loadCurrentLanguage()
|
||||||
|
{
|
||||||
|
Translator::load($this->getCurrentLanguage());
|
||||||
|
}
|
||||||
|
}
|
||||||
56
app/Model/Timezone.php
Normal file
56
app/Model/Timezone.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Timezone
|
||||||
|
*
|
||||||
|
* @package Kanboard\Model
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class Timezone extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get available timezones
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param boolean $prepend Prepend a default value
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getTimezones($prepend = false)
|
||||||
|
{
|
||||||
|
$timezones = timezone_identifiers_list();
|
||||||
|
$listing = array_combine(array_values($timezones), $timezones);
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
return array('' => t('Application default')) + $listing;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $listing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current timezone
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCurrentTimezone()
|
||||||
|
{
|
||||||
|
if ($this->userSession->isLogged() && ! empty($this->sessionStorage->user['timezone'])) {
|
||||||
|
return $this->sessionStorage->user['timezone'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->config->get('application_timezone', 'UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set timezone
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function setCurrentTimezone()
|
||||||
|
{
|
||||||
|
date_default_timezone_set($this->getCurrentTimezone());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,7 +54,7 @@ class UserNotification extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore locales
|
// Restore locales
|
||||||
$this->config->setupTranslations();
|
$this->language->loadCurrentLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class ClassProvider implements ServiceProviderInterface
|
|||||||
'CustomFilter',
|
'CustomFilter',
|
||||||
'Group',
|
'Group',
|
||||||
'GroupMember',
|
'GroupMember',
|
||||||
|
'Language',
|
||||||
'LastLogin',
|
'LastLogin',
|
||||||
'Link',
|
'Link',
|
||||||
'Notification',
|
'Notification',
|
||||||
@@ -66,6 +67,7 @@ class ClassProvider implements ServiceProviderInterface
|
|||||||
'TaskPosition',
|
'TaskPosition',
|
||||||
'TaskStatus',
|
'TaskStatus',
|
||||||
'TaskMetadata',
|
'TaskMetadata',
|
||||||
|
'Timezone',
|
||||||
'Transition',
|
'Transition',
|
||||||
'User',
|
'User',
|
||||||
'UserLocking',
|
'UserLocking',
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ class BootstrapSubscriber extends BaseSubscriber implements EventSubscriberInter
|
|||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$this->logger->debug('Subscriber executed: '.__METHOD__);
|
$this->logger->debug('Subscriber executed: '.__METHOD__);
|
||||||
$this->config->setupTranslations();
|
$this->language->loadCurrentLanguage();
|
||||||
$this->config->setupTimezone();
|
$this->timezone->setCurrentTimezone();
|
||||||
$this->actionManager->attachEvents();
|
$this->actionManager->attachEvents();
|
||||||
|
|
||||||
if ($this->userSession->isLogged()) {
|
if ($this->userSession->isLogged()) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Kanboard\User;
|
namespace Kanboard\User;
|
||||||
|
|
||||||
use Kanboard\Core\User\UserProviderInterface;
|
use Kanboard\Core\User\UserProviderInterface;
|
||||||
|
use Kanboard\Model\Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LDAP User Provider
|
* LDAP User Provider
|
||||||
@@ -68,6 +69,14 @@ class LdapUserProvider implements UserProviderInterface
|
|||||||
*/
|
*/
|
||||||
protected $photo = '';
|
protected $photo = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User language
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $language = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@@ -80,7 +89,7 @@ class LdapUserProvider implements UserProviderInterface
|
|||||||
* @param string[] $groupIds
|
* @param string[] $groupIds
|
||||||
* @param string $photo
|
* @param string $photo
|
||||||
*/
|
*/
|
||||||
public function __construct($dn, $username, $name, $email, $role, array $groupIds, $photo = '')
|
public function __construct($dn, $username, $name, $email, $role, array $groupIds, $photo = '', $language = '')
|
||||||
{
|
{
|
||||||
$this->dn = $dn;
|
$this->dn = $dn;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
@@ -89,6 +98,7 @@ class LdapUserProvider implements UserProviderInterface
|
|||||||
$this->role = $role;
|
$this->role = $role;
|
||||||
$this->groupIds = $groupIds;
|
$this->groupIds = $groupIds;
|
||||||
$this->photo = $photo;
|
$this->photo = $photo;
|
||||||
|
$this->language = $language;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,9 +208,13 @@ class LdapUserProvider implements UserProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function getExtraAttributes()
|
public function getExtraAttributes()
|
||||||
{
|
{
|
||||||
return array(
|
$attributes = array('is_ldap_user' => 1);
|
||||||
'is_ldap_user' => 1,
|
|
||||||
);
|
if (! empty($this->language)) {
|
||||||
|
$attributes['language'] = Language::findCode($this->language);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ defined('LDAP_USER_ATTRIBUTE_FULLNAME') or define('LDAP_USER_ATTRIBUTE_FULLNAME'
|
|||||||
defined('LDAP_USER_ATTRIBUTE_EMAIL') or define('LDAP_USER_ATTRIBUTE_EMAIL', 'mail');
|
defined('LDAP_USER_ATTRIBUTE_EMAIL') or define('LDAP_USER_ATTRIBUTE_EMAIL', 'mail');
|
||||||
defined('LDAP_USER_ATTRIBUTE_GROUPS') or define('LDAP_USER_ATTRIBUTE_GROUPS', 'memberof');
|
defined('LDAP_USER_ATTRIBUTE_GROUPS') or define('LDAP_USER_ATTRIBUTE_GROUPS', 'memberof');
|
||||||
defined('LDAP_USER_ATTRIBUTE_PHOTO') or define('LDAP_USER_ATTRIBUTE_PHOTO', '');
|
defined('LDAP_USER_ATTRIBUTE_PHOTO') or define('LDAP_USER_ATTRIBUTE_PHOTO', '');
|
||||||
|
defined('LDAP_USER_ATTRIBUTE_LANGUAGE') or define('LDAP_USER_ATTRIBUTE_LANGUAGE', '');
|
||||||
defined('LDAP_USER_CREATION') or define('LDAP_USER_CREATION', true);
|
defined('LDAP_USER_CREATION') or define('LDAP_USER_CREATION', true);
|
||||||
|
|
||||||
defined('LDAP_GROUP_ADMIN_DN') or define('LDAP_GROUP_ADMIN_DN', '');
|
defined('LDAP_GROUP_ADMIN_DN') or define('LDAP_GROUP_ADMIN_DN', '');
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ define('LDAP_USER_ATTRIBUTE_GROUPS', 'memberof');
|
|||||||
// LDAP attribute for user avatar image: thumbnailPhoto or jpegPhoto
|
// LDAP attribute for user avatar image: thumbnailPhoto or jpegPhoto
|
||||||
define('LDAP_USER_ATTRIBUTE_PHOTO', '');
|
define('LDAP_USER_ATTRIBUTE_PHOTO', '');
|
||||||
|
|
||||||
|
// LDAP attribute for user language, example: 'preferredlanguage'
|
||||||
|
// Put an empty string to disable language sync
|
||||||
|
define('LDAP_USER_ATTRIBUTE_LANGUAGE', '');
|
||||||
|
|
||||||
// Allow automatic LDAP user creation
|
// Allow automatic LDAP user creation
|
||||||
define('LDAP_USER_CREATION', true);
|
define('LDAP_USER_CREATION', true);
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,10 @@ define('LDAP_USER_ATTRIBUTE_GROUPS', 'memberof');
|
|||||||
// LDAP attribute for user avatar image: thumbnailPhoto or jpegPhoto
|
// LDAP attribute for user avatar image: thumbnailPhoto or jpegPhoto
|
||||||
define('LDAP_USER_ATTRIBUTE_PHOTO', '');
|
define('LDAP_USER_ATTRIBUTE_PHOTO', '');
|
||||||
|
|
||||||
|
// LDAP attribute for user language, example: 'preferredlanguage'
|
||||||
|
// Put an empty string to disable language sync
|
||||||
|
define('LDAP_USER_ATTRIBUTE_LANGUAGE', '');
|
||||||
|
|
||||||
// Allow automatic LDAP user creation
|
// Allow automatic LDAP user creation
|
||||||
define('LDAP_USER_CREATION', true);
|
define('LDAP_USER_CREATION', true);
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Here is the list of available LDAP parameters:
|
|||||||
| `LDAP_USER_ATTRIBUTE_EMAIL` | mail | LDAP attribute for user email |
|
| `LDAP_USER_ATTRIBUTE_EMAIL` | mail | LDAP attribute for user email |
|
||||||
| `LDAP_USER_ATTRIBUTE_GROUPS` | memberof | LDAP attribute to find groups in user profile |
|
| `LDAP_USER_ATTRIBUTE_GROUPS` | memberof | LDAP attribute to find groups in user profile |
|
||||||
| `LDAP_USER_ATTRIBUTE_PHOTO` | Empty | LDAP attribute to find user photo (jpegPhoto or thumbnailPhoto |
|
| `LDAP_USER_ATTRIBUTE_PHOTO` | Empty | LDAP attribute to find user photo (jpegPhoto or thumbnailPhoto |
|
||||||
|
| `LDAP_USER_ATTRIBUTE_LANGUAGE` | Empty | LDAP attribute for user language (preferredlanguage), the accepted language format is "fr-FR" |
|
||||||
| `LDAP_USER_CREATION` | true | Enable automatic LDAP user creation |
|
| `LDAP_USER_CREATION` | true | Enable automatic LDAP user creation |
|
||||||
| `LDAP_GROUP_ADMIN_DN` | Empty | LDAP DN for administrators (Example: "CN=Kanboard-Admins,CN=Users,DC=kanboard,DC=local") |
|
| `LDAP_GROUP_ADMIN_DN` | Empty | LDAP DN for administrators (Example: "CN=Kanboard-Admins,CN=Users,DC=kanboard,DC=local") |
|
||||||
| `LDAP_GROUP_MANAGER_DN` | Empty | LDAP DN for managers (Example: "CN=Kanboard Managers,CN=Users,DC=kanboard,DC=local") |
|
| `LDAP_GROUP_MANAGER_DN` | Empty | LDAP DN for managers (Example: "CN=Kanboard Managers,CN=Users,DC=kanboard,DC=local") |
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ Plugin can be translated in the same way as the rest of the application. You mus
|
|||||||
|
|
||||||
```php
|
```php
|
||||||
$this->on('app.bootstrap', function($container) {
|
$this->on('app.bootstrap', function($container) {
|
||||||
Translator::load($container['config']->getCurrentLanguage(), __DIR__.'/Locale');
|
Translator::load($container['language']->getCurrentLanguage(), __DIR__.'/Locale');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ How to translate Kanboard to a new language?
|
|||||||
1. Make a new directory: `app/Locale/xx_XX` for example `app/Locale/fr_CA` for French Canadian
|
1. Make a new directory: `app/Locale/xx_XX` for example `app/Locale/fr_CA` for French Canadian
|
||||||
2. Create a new file for the translation: `app/Locale/xx_XX/translations.php`
|
2. Create a new file for the translation: `app/Locale/xx_XX/translations.php`
|
||||||
3. Use the content of the French locales and replace the values
|
3. Use the content of the French locales and replace the values
|
||||||
4. Inside the file `app/Model/Config.php`, add a new entry for your translation inside the function `getLanguages()`
|
4. Update the file `app/Model/Language.php`
|
||||||
5. Check with your local installation of Kanboard if everything is OK
|
5. Check with your local installation of Kanboard if everything is OK
|
||||||
6. Send a [pull-request with Github](https://help.github.com/articles/using-pull-requests/)
|
6. Send a [pull-request with Github](https://help.github.com/articles/using-pull-requests/)
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,8 @@
|
|||||||
<const name="DB_USERNAME" value="root" />
|
<const name="DB_USERNAME" value="root" />
|
||||||
<const name="DB_PASSWORD" value="" />
|
<const name="DB_PASSWORD" value="" />
|
||||||
<const name="DB_PORT" value="" />
|
<const name="DB_PORT" value="" />
|
||||||
|
<const name="DB_SSL_KEY" value="" />
|
||||||
|
<const name="DB_SSL_CA" value="" />
|
||||||
|
<const name="DB_SSL_CERT" value="" />
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
@@ -6,66 +6,6 @@ use Kanboard\Model\Config;
|
|||||||
|
|
||||||
class ConfigTest extends Base
|
class ConfigTest extends Base
|
||||||
{
|
{
|
||||||
public function testGetTimezones()
|
|
||||||
{
|
|
||||||
$configModel = new Config($this->container);
|
|
||||||
$this->assertNotEmpty($configModel->getTimezones());
|
|
||||||
$this->assertArrayHasKey('Europe/Paris', $configModel->getTimezones());
|
|
||||||
$this->assertContains('Europe/Paris', $configModel->getTimezones());
|
|
||||||
$this->assertArrayNotHasKey('', $configModel->getTimezones());
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('', $configModel->getTimezones(true));
|
|
||||||
$this->assertContains('Application default', $configModel->getTimezones(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetLanguages()
|
|
||||||
{
|
|
||||||
$configModel = new Config($this->container);
|
|
||||||
$this->assertNotEmpty($configModel->getLanguages());
|
|
||||||
$this->assertArrayHasKey('fr_FR', $configModel->getLanguages());
|
|
||||||
$this->assertContains('Français', $configModel->getLanguages());
|
|
||||||
$this->assertArrayNotHasKey('', $configModel->getLanguages());
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('', $configModel->getLanguages(true));
|
|
||||||
$this->assertContains('Application default', $configModel->getLanguages(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetJsLanguage()
|
|
||||||
{
|
|
||||||
$configModel = new Config($this->container);
|
|
||||||
$this->assertEquals('en', $configModel->getJsLanguageCode());
|
|
||||||
|
|
||||||
$this->container['sessionStorage']->user = array('language' => 'fr_FR');
|
|
||||||
$this->assertEquals('fr', $configModel->getJsLanguageCode());
|
|
||||||
|
|
||||||
$this->container['sessionStorage']->user = array('language' => 'xx_XX');
|
|
||||||
$this->assertEquals('en', $configModel->getJsLanguageCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCurrentLanguage()
|
|
||||||
{
|
|
||||||
$configModel = new Config($this->container);
|
|
||||||
$this->assertEquals('en_US', $configModel->getCurrentLanguage());
|
|
||||||
|
|
||||||
$this->container['sessionStorage']->user = array('language' => 'fr_FR');
|
|
||||||
$this->assertEquals('fr_FR', $configModel->getCurrentLanguage());
|
|
||||||
|
|
||||||
$this->container['sessionStorage']->user = array('language' => 'xx_XX');
|
|
||||||
$this->assertEquals('xx_XX', $configModel->getCurrentLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCurrentTimezone()
|
|
||||||
{
|
|
||||||
$configModel = new Config($this->container);
|
|
||||||
$this->assertEquals('UTC', $configModel->getCurrentTimezone());
|
|
||||||
|
|
||||||
$this->container['sessionStorage']->user = array('timezone' => 'Europe/Paris');
|
|
||||||
$this->assertEquals('Europe/Paris', $configModel->getCurrentTimezone());
|
|
||||||
|
|
||||||
$this->container['sessionStorage']->user = array('timezone' => 'Something');
|
|
||||||
$this->assertEquals('Something', $configModel->getCurrentTimezone());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRegenerateToken()
|
public function testRegenerateToken()
|
||||||
{
|
{
|
||||||
$configModel = new Config($this->container);
|
$configModel = new Config($this->container);
|
||||||
|
|||||||
58
tests/units/Model/LanguageTest.php
Normal file
58
tests/units/Model/LanguageTest.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Kanboard\Model\Language;
|
||||||
|
|
||||||
|
require_once __DIR__.'/../Base.php';
|
||||||
|
|
||||||
|
class LanguageTest extends Base
|
||||||
|
{
|
||||||
|
public function testGetCodes()
|
||||||
|
{
|
||||||
|
$codes = Language::getCodes();
|
||||||
|
$this->assertContains('fr_FR', $codes);
|
||||||
|
$this->assertContains('en_US', $codes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFindCode()
|
||||||
|
{
|
||||||
|
$this->assertSame('', Language::findCode('xx-XX'));
|
||||||
|
$this->assertSame('fr_FR', Language::findCode('fr-FR'));
|
||||||
|
$this->assertSame('en_US', Language::findCode('en-US'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetJsLanguage()
|
||||||
|
{
|
||||||
|
$languageModel = new Language($this->container);
|
||||||
|
$this->assertEquals('en', $languageModel->getJsLanguageCode());
|
||||||
|
|
||||||
|
$this->container['sessionStorage']->user = array('language' => 'fr_FR');
|
||||||
|
$this->assertEquals('fr', $languageModel->getJsLanguageCode());
|
||||||
|
|
||||||
|
$this->container['sessionStorage']->user = array('language' => 'xx_XX');
|
||||||
|
$this->assertEquals('en', $languageModel->getJsLanguageCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetCurrentLanguage()
|
||||||
|
{
|
||||||
|
$languageModel = new Language($this->container);
|
||||||
|
$this->assertEquals('en_US', $languageModel->getCurrentLanguage());
|
||||||
|
|
||||||
|
$this->container['sessionStorage']->user = array('language' => 'fr_FR');
|
||||||
|
$this->assertEquals('fr_FR', $languageModel->getCurrentLanguage());
|
||||||
|
|
||||||
|
$this->container['sessionStorage']->user = array('language' => 'xx_XX');
|
||||||
|
$this->assertEquals('xx_XX', $languageModel->getCurrentLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLanguages()
|
||||||
|
{
|
||||||
|
$languageModel = new Language($this->container);
|
||||||
|
$this->assertNotEmpty($languageModel->getLanguages());
|
||||||
|
$this->assertArrayHasKey('fr_FR', $languageModel->getLanguages());
|
||||||
|
$this->assertContains('Français', $languageModel->getLanguages());
|
||||||
|
$this->assertArrayNotHasKey('', $languageModel->getLanguages());
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('', $languageModel->getLanguages(true));
|
||||||
|
$this->assertContains('Application default', $languageModel->getLanguages(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,10 +15,10 @@ class ProjectTest extends Base
|
|||||||
{
|
{
|
||||||
public function testCreationForAllLanguages()
|
public function testCreationForAllLanguages()
|
||||||
{
|
{
|
||||||
$c = new Config($this->container);
|
|
||||||
$p = new Project($this->container);
|
$p = new Project($this->container);
|
||||||
|
|
||||||
foreach ($c->getLanguages() as $locale => $language) {
|
foreach ($this->container['language']->getLanguages() as $locale => $language) {
|
||||||
|
Translator::unload();
|
||||||
Translator::load($locale);
|
Translator::load($locale);
|
||||||
$this->assertNotFalse($p->create(array('name' => 'UnitTest '.$locale)), 'Unable to create project with '.$locale.':'.$language);
|
$this->assertNotFalse($p->create(array('name' => 'UnitTest '.$locale)), 'Unable to create project with '.$locale.':'.$language);
|
||||||
}
|
}
|
||||||
|
|||||||
32
tests/units/Model/TimezoneTest.php
Normal file
32
tests/units/Model/TimezoneTest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/../Base.php';
|
||||||
|
|
||||||
|
use Kanboard\Model\Timezone;
|
||||||
|
|
||||||
|
class TimezoneTest extends Base
|
||||||
|
{
|
||||||
|
public function testGetTimezones()
|
||||||
|
{
|
||||||
|
$timezoneModel = new Timezone($this->container);
|
||||||
|
$this->assertNotEmpty($timezoneModel->getTimezones());
|
||||||
|
$this->assertArrayHasKey('Europe/Paris', $timezoneModel->getTimezones());
|
||||||
|
$this->assertContains('Europe/Paris', $timezoneModel->getTimezones());
|
||||||
|
$this->assertArrayNotHasKey('', $timezoneModel->getTimezones());
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('', $timezoneModel->getTimezones(true));
|
||||||
|
$this->assertContains('Application default', $timezoneModel->getTimezones(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetCurrentTimezone()
|
||||||
|
{
|
||||||
|
$timezoneModel = new Timezone($this->container);
|
||||||
|
$this->assertEquals('UTC', $timezoneModel->getCurrentTimezone());
|
||||||
|
|
||||||
|
$this->container['sessionStorage']->user = array('timezone' => 'Europe/Paris');
|
||||||
|
$this->assertEquals('Europe/Paris', $timezoneModel->getCurrentTimezone());
|
||||||
|
|
||||||
|
$this->container['sessionStorage']->user = array('timezone' => 'Something');
|
||||||
|
$this->assertEquals('Something', $timezoneModel->getCurrentTimezone());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user