Guest User

Untitled

a guest
Nov 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. # **讀取resource/lang方法改善 **
  2. 欲讀取resource/lang 下所有的php檔方法。
  3.  
  4. ### 檔案結構
  5. ```graphviz
  6. digraph hierarchy {
  7.  
  8. nodesep=1.0 // increases the separation between nodes
  9.  
  10. node [color=Red,fontname=Courier,shape=box] //All nodes will this shape and colour
  11. edge [color=Blue, style=dashed] //All the lines look like this
  12.  
  13. Resource->{lang}->{fr it de}
  14. fr->{fr_1 fr_2}
  15. it->{it_1 it_2}
  16. de->{de_1 de_2}
  17. {rank=same;fr_1 fr_2 it_1 it_2 de_1 de_2}
  18. }
  19. ```
  20.  
  21. ### 檔案內容:
  22. ```php
  23. <?php
  24. return [
  25. 'AAAA'=>'AAAA',
  26. 'BBBB'=>'BBBB',
  27. ];
  28. ```
  29. - A. 使用File::allFiles 讀進來後再用Fopen開檔案去辨識字串在讀入。
  30. 太麻煩!!! :-1:
  31.  
  32.  
  33. - B. 使用`App::setLocale('fr');` 設定國籍後,再使用`trans('fr_1');` 可以取得fr_1裡面的內容,但是取得it_1內容要在setLcale('it') 一次才有辦法取得。 一直切換國籍不是辦法 :-1:
  34.  
  35.  
  36. ### 改善方法:
  37. - C. 使用`require('lang_path');` 可取得該php檔案內容,並以陣列方式回傳,即可操作使用。 :thumbsup:
Add Comment
Please, Sign In to add comment