github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/utils/i18n.go (about) 1 package utils 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 8 "github.com/masterhung0112/hk_server/v5/shared/i18n" 9 "github.com/masterhung0112/hk_server/v5/utils/fileutils" 10 ) 11 12 // this functions loads translations from filesystem if they are not 13 // loaded already and assigns english while loading server config 14 func TranslationsPreInit() error { 15 translationsDir := "i18n" 16 if mattermostPath := os.Getenv("HK_SERVER_PATH"); mattermostPath != "" { 17 translationsDir = filepath.Join(mattermostPath, "i18n") 18 } 19 20 i18nDirectory, found := fileutils.FindDirRelBinary(translationsDir) 21 if !found { 22 return fmt.Errorf("unable to find i18n directory at %q", translationsDir) 23 } 24 25 return i18n.TranslationsPreInit(i18nDirectory) 26 }