gview_i18n.go 713 B

1234567891011121314151617181920212223
  1. // Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gview
  7. import "github.com/gogf/gf/util/gconv"
  8. // i18nTranslate translate the content with i18n feature.
  9. func (view *View) i18nTranslate(content string, params Params) string {
  10. if view.config.I18nManager != nil {
  11. if v, ok := params["I18nLanguage"]; ok {
  12. language := gconv.String(v)
  13. if language != "" {
  14. return view.config.I18nManager.T(content, language)
  15. }
  16. }
  17. return view.config.I18nManager.T(content)
  18. }
  19. return content
  20. }