Loading tacjs.libraries.yml +5 −0 Original line number Diff line number Diff line Loading @@ -29,3 +29,8 @@ tacjs: - core/drupal - core/drupalSettings - tacjs/tarteaucitron.js - tacjs/tarteaucitron.en.js tarteaucitron.en.js: js: assets/vendor/tarteaucitron.js/lang/tarteaucitron.en.js: {} tacjs.module +13 −5 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ */ function tacjs_page_attachments(&$page) { if (!\Drupal::service('router.admin_context')->isAdminRoute()) { $config = Drupal::config('tacjs.settings'); $lang = Drupal::languageManager() $config = \Drupal::config('tacjs.settings'); $lang = \Drupal::languageManager() ->getCurrentLanguage() ->getId(); Loading @@ -29,6 +29,11 @@ function tacjs_page_attachments(&$page) { $page['#attached']['drupalSettings']['tacjs'] = $js_settings; $page['#attached']['library'][] = 'tacjs/tacjs'; if ($lang === "en") { return; } $page['#attached']['library'][] = 'tacjs/tarteaucitron.' . $lang . '.js'; } } Loading @@ -42,9 +47,13 @@ function tacjs_library_info_build() { $libraries = []; /** @var \Drupal\Core\File\FileSystemInterface $fileSystem */ $fileSystem = Drupal::service('file_system'); $fileSystem = \Drupal::service('file_system'); foreach ($fileSystem->scanDirectory(\Drupal::service('extension.list.module')->getPath('tacjs') . '/assets/vendor/tarteaucitron.js/lang/', '/tarteaucitron\.(\w+)\.js/') as $file) { if ($file->filename === "tarteaucitron.en.js") { return; } foreach ($fileSystem->scanDirectory(drupal_get_path('module', 'tacjs') . '/assets/vendor/tarteaucitron.js/lang/', '/tarteaucitron\.(\w+)\.js/') as $file) { $libraries[$file->filename] = [ 'js' => [ '/' . $file->uri => [], Loading @@ -54,4 +63,3 @@ function tacjs_library_info_build() { return $libraries; } Loading
tacjs.libraries.yml +5 −0 Original line number Diff line number Diff line Loading @@ -29,3 +29,8 @@ tacjs: - core/drupal - core/drupalSettings - tacjs/tarteaucitron.js - tacjs/tarteaucitron.en.js tarteaucitron.en.js: js: assets/vendor/tarteaucitron.js/lang/tarteaucitron.en.js: {}
tacjs.module +13 −5 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ */ function tacjs_page_attachments(&$page) { if (!\Drupal::service('router.admin_context')->isAdminRoute()) { $config = Drupal::config('tacjs.settings'); $lang = Drupal::languageManager() $config = \Drupal::config('tacjs.settings'); $lang = \Drupal::languageManager() ->getCurrentLanguage() ->getId(); Loading @@ -29,6 +29,11 @@ function tacjs_page_attachments(&$page) { $page['#attached']['drupalSettings']['tacjs'] = $js_settings; $page['#attached']['library'][] = 'tacjs/tacjs'; if ($lang === "en") { return; } $page['#attached']['library'][] = 'tacjs/tarteaucitron.' . $lang . '.js'; } } Loading @@ -42,9 +47,13 @@ function tacjs_library_info_build() { $libraries = []; /** @var \Drupal\Core\File\FileSystemInterface $fileSystem */ $fileSystem = Drupal::service('file_system'); $fileSystem = \Drupal::service('file_system'); foreach ($fileSystem->scanDirectory(\Drupal::service('extension.list.module')->getPath('tacjs') . '/assets/vendor/tarteaucitron.js/lang/', '/tarteaucitron\.(\w+)\.js/') as $file) { if ($file->filename === "tarteaucitron.en.js") { return; } foreach ($fileSystem->scanDirectory(drupal_get_path('module', 'tacjs') . '/assets/vendor/tarteaucitron.js/lang/', '/tarteaucitron\.(\w+)\.js/') as $file) { $libraries[$file->filename] = [ 'js' => [ '/' . $file->uri => [], Loading @@ -54,4 +63,3 @@ function tacjs_library_info_build() { return $libraries; }