Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # **讀取resource/lang方法改善 **
- 欲讀取resource/lang 下所有的php檔方法。
- ### 檔案結構
- ```graphviz
- digraph hierarchy {
- nodesep=1.0 // increases the separation between nodes
- node [color=Red,fontname=Courier,shape=box] //All nodes will this shape and colour
- edge [color=Blue, style=dashed] //All the lines look like this
- Resource->{lang}->{fr it de}
- fr->{fr_1 fr_2}
- it->{it_1 it_2}
- de->{de_1 de_2}
- {rank=same;fr_1 fr_2 it_1 it_2 de_1 de_2}
- }
- ```
- ### 檔案內容:
- ```php
- <?php
- return [
- 'AAAA'=>'AAAA',
- 'BBBB'=>'BBBB',
- ];
- ```
- - A. 使用File::allFiles 讀進來後再用Fopen開檔案去辨識字串在讀入。
- 太麻煩!!! :-1:
- - B. 使用`App::setLocale('fr');` 設定國籍後,再使用`trans('fr_1');` 可以取得fr_1裡面的內容,但是取得it_1內容要在setLcale('it') 一次才有辦法取得。 一直切換國籍不是辦法 :-1:
- ### 改善方法:
- - C. 使用`require('lang_path');` 可取得該php檔案內容,並以陣列方式回傳,即可操作使用。 :thumbsup:
Add Comment
Please, Sign In to add comment