HomeLangBehavior.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 HomeLangBehavior
  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 . 'home' . EXT,
  26. ]);
  27. }
  28. }
  29. }