File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ func date(fomate string,t time.Time) string{
93
93
en[" money" ] =" USD %d "
94
94
cn[" money" ] =" ¥%d 元"
95
95
96
- fmt.Println (date (msg (lang," date_format" ),100 ))
96
+ fmt.Println (money_format (msg (lang," date_format" ),100 ))
97
97
98
98
func money_format (fomate string ,money int64 ) string {
99
99
return fmt.Sprintf (fomate,money)
@@ -122,19 +122,19 @@ views
122
122
有了这个目录结构后我们就可以在渲染的地方这样来实现代码:
123
123
``` Go
124
124
125
- s1 , _ := template.ParseFiles (" views" +lang+" index.tpl" )
125
+ s1 , _ := template.ParseFiles (" views/ " +lang+" / index.tpl" )
126
126
VV.Lang =lang
127
127
s1.Execute (os.Stdout , VV )
128
128
```
129
129
而对于里面的index.tpl里面的资源设置如下:
130
130
``` html
131
131
132
132
// js文件
133
- <script type =" text/javascript" src =" views/{{.VV. Lang}}/js/jquery/jquery-1.8.0.min.js" ></script >
133
+ <script type =" text/javascript" src =" views/{{.Lang}}/js/jquery/jquery-1.8.0.min.js" ></script >
134
134
// css文件
135
- <link href =" views/{{.VV. Lang}}/css/bootstrap-responsive.min.css" rel =" stylesheet" >
135
+ <link href =" views/{{.Lang}}/css/bootstrap-responsive.min.css" rel =" stylesheet" >
136
136
// 图片文件
137
- <img src =" views/{{.VV. Lang}}/images/btn.png" >
137
+ <img src =" views/{{.Lang}}/images/btn.png" >
138
138
```
139
139
采用这种方式来本地化视图以及资源时,我们就可以很容易的进行扩展了。
140
140
You can’t perform that action at this time.
0 commit comments