Refactor localization support
Add the standard languages selector block to navbar, register default languages, enable l10n_updates. The groups_language_switcher module is deprecated now, will be removed in a future release. Change-Id: I4ae0582bd9b153503a22edc5e83d38efa7eff8a1
This commit is contained in:
parent
a80b024810
commit
cfb223b9ea
|
@ -14,6 +14,7 @@ dependencies[] = field_ui
|
|||
dependencies[] = file
|
||||
dependencies[] = image
|
||||
dependencies[] = list
|
||||
dependencies[] = locale
|
||||
dependencies[] = menu
|
||||
dependencies[] = number
|
||||
dependencies[] = options
|
||||
|
@ -46,6 +47,7 @@ dependencies[] = googleanalytics
|
|||
dependencies[] = http_client
|
||||
dependencies[] = jquery_update
|
||||
dependencies[] = libraries
|
||||
dependencies[] = l10n_update
|
||||
dependencies[] = markdown
|
||||
dependencies[] = media
|
||||
dependencies[] = media_internet
|
||||
|
@ -147,7 +149,6 @@ dependencies[] = field_group_location
|
|||
|
||||
; Features
|
||||
dependencies[] = groups_groups
|
||||
dependencies[] = groups_language_switcher
|
||||
dependencies[] = groups_directory
|
||||
dependencies[] = groups_footer
|
||||
dependencies[] = groups_homepage
|
||||
|
|
|
@ -81,6 +81,9 @@ function groups_install() {
|
|||
);
|
||||
drupal_write_record('block', $search_block);
|
||||
|
||||
_groups_enable_default_languages();
|
||||
_groups_add_language_selector_block();
|
||||
|
||||
// Create a default role for site administrators, with all available permissions assigned.
|
||||
// $admin_role = new stdClass();
|
||||
// $admin_role->name = 'administrator';
|
||||
|
@ -109,6 +112,40 @@ function groups_install() {
|
|||
_groups_add_markdown_filter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add language selector block to header region.
|
||||
*
|
||||
* @see groups_install()
|
||||
*/
|
||||
function _groups_add_language_selector_block() {
|
||||
$block = array(
|
||||
'module' => 'locale',
|
||||
'delta' => 'language',
|
||||
'theme' => 'openstack_bootstrap',
|
||||
'visibility' => 0,
|
||||
'region' => 'header',
|
||||
'status' => 1,
|
||||
'pages' => '',
|
||||
'weight' => 2,
|
||||
'title' => '<none>',
|
||||
);
|
||||
drupal_write_record('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable default languages.
|
||||
*/
|
||||
function _groups_enable_default_languages() {
|
||||
include_once DRUPAL_ROOT . '/includes/locale.inc';
|
||||
include_once DRUPAL_ROOT . '/includes/iso.inc';
|
||||
$default_languages = variable_get('groups_default_languages', 'hu,es,de,ru,zh-hans,ja,fi');
|
||||
$languages = explode(',', $default_languages);
|
||||
foreach ($languages as $langcode) {
|
||||
locale_add_language($langcode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable markdown module if it is not already enabled.
|
||||
*/
|
||||
|
@ -234,6 +271,32 @@ function groups_update_7112() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add language selector as a block and enable locale, l10n_update modules.
|
||||
*/
|
||||
function groups_update_7113() {
|
||||
drupal_uninstall_schema('locale');
|
||||
drupal_flush_all_caches();
|
||||
module_enable(array('locale', 'l10n_update'));
|
||||
module_disable(array('groups_language_switcher'));
|
||||
_groups_add_language_selector_block();
|
||||
_groups_enable_default_languages();
|
||||
_groups_set_language_negotiation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language negotiation to URL based.
|
||||
*/
|
||||
function _groups_set_language_negotiation() {
|
||||
require_once DRUPAL_ROOT . '/includes/language.inc';
|
||||
require_once DRUPAL_ROOT . '/includes/locale.inc';
|
||||
$negotiation = array(
|
||||
LOCALE_LANGUAGE_NEGOTIATION_URL => 2,
|
||||
LANGUAGE_NEGOTIATION_DEFAULT => 10,
|
||||
);
|
||||
language_negotiation_set(LANGUAGE_TYPE_INTERFACE, $negotiation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add markdown filter with permissions.
|
||||
*/
|
||||
|
|
|
@ -40,4 +40,12 @@ h1 {
|
|||
-webkit-box-shadow: none !important;
|
||||
-moz-box-shadow: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
button:focus,
|
||||
button:active,
|
||||
button:hover
|
||||
{
|
||||
outline:0px !important;
|
||||
-webkit-appearance:none;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
.block-locale {
|
||||
padding-top: 10px;
|
||||
h2 {
|
||||
text-align: center;
|
||||
}
|
||||
background: none repeat scroll 0% 0% #EDF2F7;
|
||||
ul {
|
||||
list-style: none;
|
||||
@include content-columns(3);
|
||||
}
|
||||
li {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
}
|
||||
li a {
|
||||
font-size: 16px;
|
||||
color: #2A4E68;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-language {
|
||||
float: right;
|
||||
padding-right: 7px;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
outline: none;
|
||||
button {
|
||||
padding-top: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
border: 0px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.btn-language {
|
||||
@include button-variant(#2A4E68, #EDF2F7, #888);
|
||||
@include button-size(15, 15, 12px, 20px, 0px);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.collapsed {
|
||||
@include button-variant(#888, #ffffff, #888);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
@import 'partials/post';
|
||||
@import 'partials/profile';
|
||||
@import 'partials/event';
|
||||
@import 'partials/language';
|
||||
|
||||
/* Custom override */
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<section id="<?php print $block_html_id; ?>" class="<?php print $classes; ?> clearfix collapse"<?php print $attributes; ?>>
|
||||
|
||||
<?php print render($title_prefix); ?>
|
||||
<h2><?php print t('Select language'); ?></h2>
|
||||
<?php print render($title_suffix); ?>
|
||||
|
||||
<?php print $content ?>
|
||||
|
||||
</section> <!-- /.block -->
|
|
@ -99,6 +99,11 @@
|
|||
<?php if (!empty($primary_nav) || !empty($secondary_nav) || !empty($page['navigation'])): ?>
|
||||
<div class="navbar-collapse collapse">
|
||||
<nav role="navigation">
|
||||
<div class="menu-language">
|
||||
<button type="button" class="btn btn-language btn-xs collapsed" data-toggle="collapse" data-target="#block-locale-language">
|
||||
<?php print $language->name; ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php if (!empty($page['utility'])): ?>
|
||||
<?php print render($page['utility']); ?>
|
||||
<?php endif; ?>
|
||||
|
@ -116,6 +121,7 @@
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php print render($page['header']); ?>
|
||||
</header>
|
||||
|
||||
<div class="main-container">
|
||||
|
@ -124,8 +130,6 @@
|
|||
<?php if (!empty($site_slogan)): ?>
|
||||
<p class="lead"><?php print $site_slogan; ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php print render($page['header']); ?>
|
||||
</header> <!-- /#page-header -->
|
||||
|
||||
<div class="row">
|
||||
|
|
Loading…
Reference in New Issue