Last active
August 31, 2016 12:45
-
-
Save vincenzo/31fab09c7bb0f7271316a6910ae70897 to your computer and use it in GitHub Desktop.
Exporting date formats to code with Multilingual Drupal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
features[variable][] = date_first_day | |
features[variable][] = date_format_long | |
features[variable][] = date_format_medium | |
features[variable][] = date_format_month_year | |
features[variable][] = date_format_short | |
features[variable][] = date_format_time | |
features[variable][] = date_format_year |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
function settings_post_features_revert($component) { | |
$date_formats = module_invoke('bcshop_settings', 'date_formats'); | |
foreach ($date_formats as $date_format) { | |
foreach ($date_format['locales'] as $locale) { | |
if (drupal_multilingual()) { | |
locale_date_format_save($locale, $date_format['type'], $date_format['format']); | |
} | |
} | |
} | |
} | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
** | |
* Implements hook_date_format_types(). | |
*/ | |
function settings_date_format_types() { | |
return array( | |
'month_year' => 'Month Year', | |
'year' => 'Year', | |
'time' => 'Time', | |
); | |
} | |
/** | |
* Implements hook_date_formats(). | |
*/ | |
function settings_date_formats() { | |
$formats = array(); | |
$formats[] = array( | |
'type' => 'long', | |
'format' => 'l, j \d\e F \d\e Y H:i', | |
'locales' => array('es'), | |
); | |
$formats[] = array( | |
'type' => 'long', | |
'format' => 'l j F Y H:i', | |
'locales' => array('en'), | |
); | |
$formats[] = array( | |
'type' => 'medium', | |
'format' => 'j \d\e F \d\e Y H:i', | |
'locales' => array('es'), | |
); | |
$formats[] = array( | |
'type' => 'medium', | |
'format' => 'j F Y H:i', | |
'locales' => array('en'), | |
); | |
$formats[] = array( | |
'type' => 'short', | |
'format' => 'd/m/y H:i', | |
'locales' => array('es', 'en'), | |
); | |
$formats[] = array( | |
'type' => 'year', | |
'format' => 'Y', | |
'locales' => array('es', 'en'), | |
); | |
$formats[] = array( | |
'type' => 'month_year', | |
'format' => 'F \d\e Y', | |
'locales' => array('es'), | |
); | |
$formats[] = array( | |
'type' => 'month_year', | |
'format' => 'F Y', | |
'locales' => array('en'), | |
); | |
$formats[] = array( | |
'type' => 'time', | |
'format' => 'H:i', | |
'locales' => array('es', 'en'), | |
); | |
return $formats; | |
} | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
$strongarm = new stdClass(); | |
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ | |
$strongarm->api_version = 1; | |
$strongarm->name = 'date_first_day'; | |
$strongarm->value = '1'; | |
$export['date_first_day'] = $strongarm; | |
$strongarm = new stdClass(); | |
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ | |
$strongarm->api_version = 1; | |
$strongarm->name = 'date_format_long'; | |
$strongarm->value = 'l, j \\d\\e F \\d\\e Y H:i'; | |
$export['date_format_long'] = $strongarm; | |
$strongarm = new stdClass(); | |
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ | |
$strongarm->api_version = 1; | |
$strongarm->name = 'date_format_medium'; | |
$strongarm->value = 'j \\d\\e F \\d\\e Y H:i'; | |
$export['date_format_medium'] = $strongarm; | |
$strongarm = new stdClass(); | |
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ | |
$strongarm->api_version = 1; | |
$strongarm->name = 'date_format_month_year'; | |
$strongarm->value = 'F \\d\\e Y'; | |
$export['date_format_month_year'] = $strongarm; | |
$strongarm = new stdClass(); | |
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ | |
$strongarm->api_version = 1; | |
$strongarm->name = 'date_format_short'; | |
$strongarm->value = 'd/m/y H:i'; | |
$export['date_format_short'] = $strongarm; | |
$strongarm = new stdClass(); | |
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ | |
$strongarm->api_version = 1; | |
$strongarm->name = 'date_format_time'; | |
$strongarm->value = 'H:i'; | |
$export['date_format_time'] = $strongarm; | |
$strongarm = new stdClass(); | |
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ | |
$strongarm->api_version = 1; | |
$strongarm->name = 'date_format_year'; | |
$strongarm->value = 'Y'; | |
$export['date_format_year'] = $strongarm; | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment