Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Issue 104 : use pluginsettings directory path for i18n folder location (
Browse files Browse the repository at this point in the history
#105)

* take plugins folder path from settings.

* version bump
  • Loading branch information
scottleedavis authored May 22, 2019
1 parent d13e51b commit b90600d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "com.github.scottleedavis.mattermost-plugin-remind",
"name": "Remind Bot Mattermost Plugin",
"description": "Sets Reminders",
"version": "0.2.7",
"version": "0.2.8",
"server": {
"executables": {
"linux-amd64": "server/dist/plugin-linux-amd64",
Expand Down
13 changes: 5 additions & 8 deletions server/activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,16 @@ func (p *Plugin) OnActivate() error {
}

p.router = p.InitAPI()

p.ensureBotExists()
p.emptyTime = time.Time{}.AddDate(1, 1, 1)
p.supportedLocales = []string{"en"}

for _, team := range teams {
if err := p.registerCommand(team.Id); err != nil {
return errors.Wrap(err, "failed to register command")
}
}

if err := TranslationsPreInit(); err != nil {
return errors.Wrap(err, "failed to initialize translations OnActivate message")
}

p.emptyTime = time.Time{}.AddDate(1, 1, 1)
p.supportedLocales = []string{"en"}

p.Run()

return nil
Expand All @@ -80,6 +74,9 @@ func (p *Plugin) OnDeactivate() error {
func (p *Plugin) OnConfigurationChange() error {
p.ServerConfig = p.API.GetConfig()
p.URL = fmt.Sprintf("%s", *p.ServerConfig.ServiceSettings.SiteURL)
if err := p.TranslationsPreInit(); err != nil {
return errors.Wrap(err, "failed to initialize translations")
}
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions server/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/nicksnyder/go-i18n/i18n"
)

var locales map[string]string = make(map[string]string)
var locales = make(map[string]string)

func TranslationsPreInit() error {
func (p *Plugin) TranslationsPreInit() error {

i18nDirectory, found := fileutils.FindDir("plugins/" + manifest.Id + "/server/dist/i18n/")
i18nDirectory, found := fileutils.FindDir(*p.ServerConfig.PluginSettings.Directory + "/" + manifest.Id + "/server/dist/i18n/")
if !found {
return fmt.Errorf("unable to find i18n directory")
}
Expand Down
2 changes: 1 addition & 1 deletion server/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ var manifest = struct {
Version string
}{
Id: "com.github.scottleedavis.mattermost-plugin-remind",
Version: "0.2.7",
Version: "0.2.8",
}

0 comments on commit b90600d

Please sign in to comment.