AdminLangBehavior.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. // +---------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +---------------------------------------------------------------------
  5. // | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
  6. // +---------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +---------------------------------------------------------------------
  9. // | Author: Dean <zxxjjforever@163.com>
  10. // +---------------------------------------------------------------------
  11. namespace cmf\behavior;
  12. use think\Lang;
  13. use think\Request;
  14. class AdminLangBehavior
  15. {
  16. // 行为扩展的执行入口必须是run
  17. public function run()
  18. {
  19. $request = Request::instance();
  20. $langSet = $request->langset();
  21. // 加载应用后台菜单语言包
  22. $apps = cmf_scan_dir(APP_PATH . '*', GLOB_ONLYDIR);
  23. foreach ($apps as $app) {
  24. Lang::load([
  25. APP_PATH . $app . DS . 'lang' . DS . $langSet . DS . 'admin_menu' . EXT,
  26. APP_PATH . $app . DS . 'lang' . DS . $langSet . DS . 'admin' . EXT,
  27. ]);
  28. }
  29. // 加后台菜单动态语言包
  30. $defaultLangDir = config('DEFAULT_LANG');
  31. Lang::load([
  32. CMF_ROOT . "data/lang/" . $defaultLangDir . "/admin_menu.php"
  33. ]);
  34. }
  35. }