function twitter_feed_timeago_languages in Twitter_Feed 8
Get timeago languages.
Return value
array The sorted timeago languages.
2 calls to twitter_feed_timeago_languages()
- TwitterFeedConfigForm::buildForm in src/
Form/ TwitterFeedConfigForm.php - Form constructor.
- twitter_feed_library_info_build in ./
twitter_feed.module - Implements hook_library_info_build().
File
- ./
twitter_feed.module, line 114 - Twitter module hooks.
Code
function twitter_feed_timeago_languages() {
if (!function_exists('libraries_get_path')) {
return [];
}
$path = libraries_get_path('timeago');
$files = \Drupal::service('file_system')
->scanDirectory("{$path}/locales", '/timeago\\..{2,14}\\.js$/i', [
'recurse' => FALSE,
'key' => 'name',
]);
$timeago_locales = [];
if ($files) {
foreach ($files as $name => $file) {
preg_match('/timeago\\.(.{2,14})$/i', $name, $matches);
if ($matches[1]) {
$timeago_locales[$matches[1]] = $matches[1];
}
}
}
ksort($timeago_locales);
return $timeago_locales;
}