Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

starting on multilingual

  • Loading branch information...
commit 6fa14c0631685c3e7e5b3951ecf9f9db0ad49c61 1 parent aff7f55
@aembler aembler authored
View
18 web/concrete/config/app.php
@@ -16,6 +16,24 @@
Cache::disableCache();
}
+if (!defined('LOCALE')) {
+ Config::getOrDefine('LOCALE', 'en_US');
+}
+
+if (strpos(LOCALE, '_') > -1) {
+ $loc = explode('_', LOCALE);
+ if (is_array($loc) && count($loc) == 2) {
+ define('LANGUAGE', $loc[0]);
+ }
+}
+
+if (!defined("LANGUAGE")) {
+ define("LANGUAGE", LOCALE);
+}
+
+// initialize localization immediately following defining locale
+Localization::init();
+
if (ENABLE_CACHE) {
Config::getOrDefine('FULL_PAGE_CACHE_GLOBAL', 'blocks');
}
View
21 web/concrete/config/base.php
@@ -107,21 +107,6 @@
define('DB_COLLATE', '');
}
-if (!defined('LOCALE')) {
- define("LOCALE", 'en_US');
-}
-
-if (strpos(LOCALE, '_') > -1) {
- $loc = explode('_', LOCALE);
- if (is_array($loc) && count($loc) == 2) {
- define('LANGUAGE', $loc[0]);
- }
-}
-
-if (!defined("LANGUAGE")) {
- define("LANGUAGE", LOCALE);
-}
-
define("LANGUAGE_DOMAIN_CORE", "messages");
# Path to the core files shared between all concrete 5 installations
@@ -232,6 +217,7 @@
define('ASSETS_URL_IMAGES', $ap . '/images');
define('ASSETS_URL_FLASH', $ap . '/flash');
+
# Pages/Collections
define('FILENAME_COLLECTION_VIEW', 'view.php');
define('FILENAME_COLLECTION_ACCESS', 'access.xml');
@@ -285,6 +271,11 @@
define('THEMES_THUMBNAIL_WIDTH', 120);
define('THEMES_THUMBNAIL_HEIGHT', 90);
+# languages
+define('DIR_LANGUAGES', DIR_BASE . '/' . DIRNAME_LANGUAGES);
+define('DIR_LANGUAGES_CORE', DIR_BASE_CORE . '/' . DIRNAME_LANGUAGES);
+
+
# Mail templates are just another kind of element, but with some special properties
define('DIR_FILES_EMAIL_TEMPLATES', DIR_BASE . '/mail');
define('DIR_FILES_EMAIL_TEMPLATES_CORE', DIR_BASE_CORE . '/mail');
View
12 web/concrete/config/install/no_sample_content.sql
@@ -122,7 +122,8 @@ INSERT INTO CollectionVersions VALUES(2,1,NULL,NULL,NULL,NOW(),NOW(),'Initial Ve
,(75,1,'Composer','composer','Write for your site',NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
,(76,1,'Write','write',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
,(77,1,'Drafts','drafts',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
- ,(78,1,'Composer','composer',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL);
+ ,(78,1,'Composer','composer',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
+ ,(79,1,'Multilingual Settings','multilingual',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL);
INSERT INTO Collections VALUES(1,NOW(),NOW(),'home')
@@ -181,7 +182,8 @@ INSERT INTO Collections VALUES(1,NOW(),NOW(),'home')
,(75,NOW(),NOW(),'composer')
,(76,NOW(),NOW(),'write')
,(77,NOW(),NOW(),'drafts')
- ,(78,NOW(),NOW(),'composer');
+ ,(78,NOW(),NOW(),'composer')
+ ,(79,NOW(),NOW(),'multilingual');
INSERT INTO DashboardHomepage VALUES(1,'activity','Site Activity',0,0)
,(2,'reports','Statistics',0,0)
@@ -262,7 +264,8 @@ INSERT INTO PagePaths VALUES(1,5,'/login','1')
,(69,75,'/dashboard/composer','1')
,(70,76,'/dashboard/composer/write','1')
,(71,77,'/dashboard/composer/drafts','1')
- ,(72,78,'/dashboard/pages/types/composer','1');
+ ,(72,78,'/dashboard/pages/types/composer','1')
+ ,(73,79,'/dashboard/settings/multilingual','1');
INSERT INTO PagePermissions VALUES(5,1,0,'r',NULL,NULL)
@@ -339,7 +342,8 @@ INSERT INTO Pages VALUES(1,1,'0',1,1,1,NOW(),NOW(),NULL,NOW(),NULL,NULL,1,1,'OVE
,(64,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,1,'PARENT','/members.php',0,NULL,0,0,7,1,0,0,-1,'0',0)
,(76,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/composer/write.php',0,NULL,0,0,0,75,0,0,-1,'0',0)
,(77,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/composer/drafts.php',0,NULL,0,0,1,75,0,0,-1,'0',0)
-,(78,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/pages/types/composer.php',0,NULL,0,0,1,43,0,0,-1,'0',0);
+,(78,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/pages/types/composer.php',0,NULL,0,0,1,43,0,0,-1,'0',0)
+ ,(79,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/settings/multilingual/view.php',0,NULL,0,0,1,52,0,0,-1,'0',0);
INSERT INTO TaskPermissions VALUES(1,'access_task_permissions','Change Task Permissions','',0)
View
12 web/concrete/config/install/sample_content.sql
@@ -604,7 +604,8 @@ INSERT INTO CollectionVersions VALUES(2,1,NULL,NULL,NULL,NOW(),NOW(),'Initial Ve
,(75,1,'Composer','composer','Write for your site',NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
,(76,1,'Write','write',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
,(77,1,'Drafts','drafts',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
- ,(78,1,'Composer','composer',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL);
+ ,(78,1,'Composer','composer',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL)
+ ,(79,1,'Multilingual Settings','multilingual',NULL,NOW(),NOW(),'Initial Version',1,0,1,NULL,NULL);
INSERT INTO Collections VALUES(1,NOW(),NOW(),'home')
,(2,NOW(),NOW(),NULL)
@@ -672,7 +673,8 @@ INSERT INTO Collections VALUES(1,NOW(),NOW(),'home')
,(75,NOW(),NOW(),'composer')
,(76,NOW(),NOW(),'write')
,(77,NOW(),NOW(),'drafts')
- ,(78,NOW(),NOW(),'composer');
+ ,(78,NOW(),NOW(),'composer')
+ ,(79,NOW(),NOW(),'multilingual');
INSERT INTO DashboardHomepage VALUES(1,'activity','Site Activity',0,0)
,(2,'reports','Statistics',0,0)
@@ -798,7 +800,8 @@ INSERT INTO PagePaths VALUES(1,5,'/login','1')
,(69,75,'/dashboard/composer','1')
,(70,76,'/dashboard/composer/write','1')
,(71,77,'/dashboard/composer/drafts','1')
- ,(72,78,'/dashboard/pages/types/composer','1');
+ ,(72,78,'/dashboard/pages/types/composer','1')
+ ,(73,79,'/dashboard/settings/multilingual','1');
INSERT INTO PagePermissions VALUES(5,1,0,'r',NULL,NULL)
@@ -910,7 +913,8 @@ INSERT INTO Pages VALUES(1,1,'0',1,0,NULL,NULL,NOW(),NULL,NOW(),NULL,NULL,1,1,'O
,(75,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/composer/view.php',0,NULL,0,2,0,15,0,0,-1,'0',0)
,(76,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/composer/write.php',0,NULL,0,0,0,75,0,0,-1,'0',0)
,(77,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/composer/drafts.php',0,NULL,0,0,1,75,0,0,-1,'0',0)
- ,(78,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/pages/types/composer.php',0,NULL,0,0,1,43,0,0,-1,'0',0);
+ ,(78,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/pages/types/composer.php',0,NULL,0,0,1,43,0,0,-1,'0',0)
+ ,(79,0,'0',1,0,NULL,NULL,NULL,NULL,NOW(),NULL,NULL,1,15,'PARENT','/dashboard/settings/multilingual/view.php',0,NULL,0,0,1,52,0,0,-1,'0',0);
INSERT INTO TaskPermissions VALUES(1,'access_task_permissions','Change Task Permissions','',0)
View
15 web/concrete/controllers/dashboard/base.php
@@ -0,0 +1,15 @@
+<?
+defined('C5_EXECUTE') or die("Access Denied.");
+class DashboardBaseController extends Controller {
+
+ protected $error;
+
+ public function on_start() {
+ $this->error = Loader::helper('validation/error');
+ }
+
+ public function on_before_render() {
+ $this->set('error', $this->error);
+ }
+
+}
View
44 web/concrete/controllers/dashboard/settings/multilingual/controller.php
@@ -0,0 +1,44 @@
+<?
+
+defined('C5_EXECUTE') or die("Access Denied.");
+Loader::controller('/dashboard/base');
+
+class DashboardSettingsMultilingualController extends DashboardBaseController {
+
+ public $helpers = array('form');
+
+ public function view() {
+ Loader::library('3rdparty/Zend/Locale');
+ $languages = Localization::getAvailableInterfaceLanguages();
+ if (count($languages) > 0) {
+ array_unshift($languages, 'en_US');
+ }
+ $locales = array();
+ foreach($languages as $lang) {
+ $loc = new Zend_Locale($lang);
+ $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', LOCALE);
+ }
+ $this->set('LANGUAGE_CHOOSE_ON_LOGIN', Config::get('LANGUAGE_CHOOSE_ON_LOGIN'));
+ $this->set('locales', $locales);
+ $this->set('languages', $languages);
+ }
+
+ public function interface_settings_saved() {
+ $this->set('message', t('Interface settings saved'));
+ $this->view();
+ }
+
+ public function save_interface_language() {
+ if (Loader::helper('validation/token')->validate('save_interface_language')) {
+
+ Config::save('LOCALE', $this->post('LOCALE'));
+ Config::save('LANGUAGE_CHOOSE_ON_LOGIN', $this->post('LANGUAGE_CHOOSE_ON_LOGIN'));
+ $this->redirect('/dashboard/settings/multilingual', 'interface_settings_saved');
+
+ } else {
+ $this->error->add(Loader::helper('validation/token')->getErrorMessage());
+ }
+ $this->view();
+ }
+
+}
View
17 web/concrete/controllers/login.php
@@ -20,6 +20,23 @@ public function on_start() {
$this->set("uName",trim($txt->filterNonAlphaNum($_GET['uName'])));
}
+
+ $languages = array();
+ $locales = array();
+ if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
+ Loader::library('3rdparty/Zend/Locale');
+ $languages = Localization::getAvailableInterfaceLanguages();
+ if (count($languages) > 0) {
+ array_unshift($languages, 'en_US');
+ }
+ $locales = array();
+ foreach($languages as $lang) {
+ $loc = new Zend_Locale($lang);
+ $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', LOCALE);
+ }
+ }
+ $this->set('locales', $locales);
+
$this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
}
View
1  web/concrete/css/ccm.forms.css
@@ -111,7 +111,6 @@ a.ccm-button em.ccm-button-close {background-image: url(../images/icons/close.pn
}
.ccm-button-v2-left {
- float: left;
margin-right: 8px;
}
View
6 web/concrete/dispatcher.php
@@ -90,14 +90,14 @@
## Startup check ##
require(dirname(__FILE__) . '/startup/encoding_check.php');
- ## File types ##
- require(dirname(__FILE__) . '/config/file_types.php');
-
## Startup check, install ##
require(dirname(__FILE__) . '/startup/config_check_complete.php');
## User level config ##
require(dirname(__FILE__) . '/config/app.php');
+
+ ## File types ##
+ require(dirname(__FILE__) . '/config/file_types.php');
## Check host for redirection ##
require(dirname(__FILE__) . '/startup/url_check.php');
View
6 web/concrete/helpers/concrete/upgrade/version_542.php
@@ -30,6 +30,12 @@ public function run() {
$tip->addAccess($g3);
}
}
+
+ $sp = Page::getByPath('/dashboard/settings/multilingual');
+ if ($sp->isError()) {
+ $d1a = SinglePage::add('/dashboard/settings/multilingual');
+ $d1a->update(array('cName'=>t('Multilingual Setup')));
+ }
}
public function prepare() {
View
2  web/concrete/helpers/html/v2.php
@@ -229,7 +229,7 @@ class V2JavaScriptOutputObject extends V2HeaderOutputObject {
public $script; // STRING (the actual JS code)
public $xhtml = true; // BOOL (should we wrap with CDATA...?)
-
+
public function __toString() {
if (!$this->string) { // If __toString() has not yet been run on this object
View
17 web/concrete/libraries/localization.php
@@ -4,6 +4,20 @@ class Localization {
public function init() {Localization::getTranslate();}
+ public static function getAvailableInterfaceLanguages() {
+ $languages = array();
+ $fh = Loader::helper('file');
+
+ if (file_exists(DIR_LANGUAGES)) {
+ $languages = array_merge($languages, $fh->getDirectoryContents(DIR_LANGUAGES));
+ }
+ if (file_exists(DIR_LANGUAGES_CORE)) {
+ $languages = array_merge($languages, $fh->getDirectoryContents(DIR_LANGUAGES_CORE));
+ }
+
+ return $languages;
+ }
+
public function getTranslate() {
if (LOCALE != 'en_US') {
static $translate;
@@ -28,8 +42,6 @@ public function getTranslate() {
}
}
- Localization::init();
-
function t($text) {
$zt = Localization::getTranslate();
if (func_num_args() == 1) {
@@ -50,3 +62,4 @@ function t($text) {
return vsprintf($text, $arg);
}
}
+
View
23 web/concrete/single_pages/dashboard/settings/multilingual/view.php
@@ -0,0 +1,23 @@
+<? defined('C5_EXECUTE') or die("Access Denied.");?>
+
+<h1><span><?=t('Multilingual Setup')?></span></h1>
+<div class="ccm-dashboard-inner">
+<h2><?=t('Interface')?></h2>
+<?
+
+if (count($languages) == 0) { ?>
+ <?=t("You don't have any interface languages installed. You must run concrete5 in English.");?>
+<? } else { ?>
+
+ <form method="post" action="<?=$this->action('save_interface_language')?>">
+ <div><?=$form->checkbox('LANGUAGE_CHOOSE_ON_LOGIN', 1, $LANGUAGE_CHOOSE_ON_LOGIN)?> <?=$form->label('LANGUAGE_CHOOSE_ON_LOGIN', t('Offer choice of language on login.'))?></div>
+ <div><?=$form->label('LOCALE', t('Default Language'))?> <?=$form->select('LOCALE', $locales, LOCALE);?></div>
+
+ <br/>
+ <?=Loader::helper('validation/token')->output('save_interface_language')?>
+ <?= Loader::helper('concrete/interface')->submit(t('Save'), 'save', 'left')?>
+ </form>
+
+<? } ?>
+
+</div>
View
15 web/concrete/single_pages/login.php
@@ -163,19 +163,30 @@
<input type="password" name="uPassword" id="uPassword" class="ccm-input-text">
</div>
- <hr />
<? if (OpenIDAuth::isEnabled()) { ?>
<div>
<label for="uOpenID"><?=t('Or login using an OpenID')?>:</label><br/>
<input type="text" name="uOpenID" id="uOpenID" <?= (isset($uOpenID)?'value="'.$uOpenID.'"':'');?> class="ccm-input-openid">
</div>
+
+ <? } ?>
+
+ <? if (isset($locales) && is_array($locales) && count($locales) > 0) { ?>
+ <div>
+ <br/>
+ <label for="USER_LOCALE"><?=t('Language')?></label><br/>
+ <?=$form->select('USER_LOCALE', $locales)?>
+ </div>
+ <br/>
<? } ?>
- <?=$form->checkbox('uMaintainLogin', 1)?> <label for="uMaintainLogin"><?=t('Remember Me')?></label>
+
+ <div style="float: left; width: 120px; padding-top: 12px"><?=$form->checkbox('uMaintainLogin', 1)?> <label for="uMaintainLogin"><?=t('Remember Me')?></label></div>
<div class="ccm-button">
<?=$form->submit('submit', t('Sign In') . ' &gt;')?>
</div>
+ <div class="ccm-spacer">&nbsp;</div>
<? $rcID = isset($_REQUEST['rcID']) ? preg_replace('/<|>/', '', $_REQUEST['rcID']) : $rcID; ?>
<input type="hidden" name="rcID" value="<?=$rcID?>" />
</form>
Please sign in to comment.
Something went wrong with that request. Please try again.