the help command is fully translatable

This commit is contained in:
Dawid Wysokiński 2020-07-19 12:42:22 +02:00 committed by Kichiyaki
parent 634088712e
commit 6026b86d27
2 changed files with 150 additions and 53 deletions

View File

@ -29,64 +29,161 @@ const (
func (s *Session) handleHelpCommand(ctx commandCtx, m *discordgo.MessageCreate) { func (s *Session) handleHelpCommand(ctx commandCtx, m *discordgo.MessageCreate) {
tribeCMDWithPrefix := TribeCommand.WithPrefix(s.cfg.CommandPrefix) tribeCMDWithPrefix := TribeCommand.WithPrefix(s.cfg.CommandPrefix)
commandsForAll := fmt.Sprintf(` commandsForAll := fmt.Sprintf(`
- **%s %s** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by ODA. - %s
- **%s %s** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by ODD. - %s
- **%s %s** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by ODS. - %s
- **%s %s** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by OD. - %s
- **%s %s** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by points. - %s
- **%s** - shows how to contact the author - %s
`, `,
tribeCMDWithPrefix, ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
TopAttCommand.String(), MessageID: "help.tribe.topatt",
tribeCMDWithPrefix, DefaultMessage: message.FallbackMsg("help.tribe.topatt", "**{{.Command}}** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by ODA."),
TopDefCommand.String(), TemplateData: map[string]interface{}{
tribeCMDWithPrefix, "Command": tribeCMDWithPrefix + " " + TopAttCommand.String(),
TopSuppCommand.String(), },
tribeCMDWithPrefix, }),
TopTotalCommand.String(), ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
tribeCMDWithPrefix, MessageID: "help.tribe.topdef",
TopPointsCommand.String(), DefaultMessage: message.FallbackMsg("help.tribe.topdef", "**{{.Command}}** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by ODD."),
AuthorCommand.WithPrefix(s.cfg.CommandPrefix), TemplateData: map[string]interface{}{
"Command": tribeCMDWithPrefix + " " + TopDefCommand.String(),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.tribe.topsupp",
DefaultMessage: message.FallbackMsg("help.tribe.topsupp", "**{{.Command}}** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by ODS."),
TemplateData: map[string]interface{}{
"Command": tribeCMDWithPrefix + " " + TopSuppCommand.String(),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.tribe.toptotal",
DefaultMessage: message.FallbackMsg("help.tribe.toptotal", "**{{.Command}}** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by OD."),
TemplateData: map[string]interface{}{
"Command": tribeCMDWithPrefix + " " + TopTotalCommand.String(),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.tribe.toppoints",
DefaultMessage: message.FallbackMsg("help.tribe.toppoints", "**{{.Command}}** [server] [page] [id1] [id2] [id3] [n id] - generates a player list from selected tribes ordered by points."),
TemplateData: map[string]interface{}{
"Command": tribeCMDWithPrefix + " " + TopPointsCommand.String(),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.author",
DefaultMessage: message.FallbackMsg("help.author", "**{{.Command}}** - shows how to contact the author."),
TemplateData: map[string]interface{}{
"Command": AuthorCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
) )
commandsForGuildAdmins := fmt.Sprintf(` commandsForGuildAdmins := fmt.Sprintf(`
- **%s** - adds a new observation group. - %s
- **%s** - shows you a list of groups created by this guild. - %s
- **%s** [group id from %s] - deletes an observation group. - %s
- **%s** [group id from %s] - enables/disables notifications about ennobling barbarian villages. - %s
- **%s** [group id from %s] [server] [tribe id] - command adds a tribe to the observation group. - %s
- **%s** [group id from %s] - shows a list of observed tribes by this group. - %s
- **%s** [group id from %s] [id from %s] - removes a tribe to the observation group. - %s
- **%s** [group id from %s] - changes the channel on which notifications about conquered village will show. IMPORTANT! Call this command on the channel you want to display these notifications. - %s
- **%s** [group id from %s] - disable notifications about conquered villages. - %s
`, `,
AddGroupCommand.WithPrefix(s.cfg.CommandPrefix), ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), MessageID: "help.addgroup",
DeleteGroupCommand.WithPrefix(s.cfg.CommandPrefix), DefaultMessage: message.FallbackMsg("help.addgroup", "**{{.Command}}** - adds a new observation group."),
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), TemplateData: map[string]interface{}{
ShowEnnobledBarbariansCommand.WithPrefix(s.cfg.CommandPrefix), "Command": AddGroupCommand.WithPrefix(s.cfg.CommandPrefix),
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), },
ObserveCommand.WithPrefix(s.cfg.CommandPrefix), }),
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
ObservationsCommand.WithPrefix(s.cfg.CommandPrefix), MessageID: "help.groups",
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), DefaultMessage: message.FallbackMsg("help.groups", "**{{.Command}}** - shows you a list of groups created by this guild."),
UnObserveCommand.WithPrefix(s.cfg.CommandPrefix), TemplateData: map[string]interface{}{
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), "Command": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
ObservationsCommand.WithPrefix(s.cfg.CommandPrefix), },
ConqueredVillagesCommand.WithPrefix(s.cfg.CommandPrefix), }),
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
UnObserveConqueredVillagesCommand.WithPrefix(s.cfg.CommandPrefix), MessageID: "help.deletegroup",
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), DefaultMessage: message.FallbackMsg("help.deletegroup", "**{{.Command}}** [group id from {{.GroupsCommand}}] - deletes an observation group."),
TemplateData: map[string]interface{}{
"Command": DeleteGroupCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.showennobledbarbs",
DefaultMessage: message.FallbackMsg("help.showennobledbarbs", "**{{.Command}}** [group id from {{.GroupsCommand}}] - enables/disables notifications about ennobling barbarian villages."),
TemplateData: map[string]interface{}{
"Command": ShowEnnobledBarbariansCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.observe",
DefaultMessage: message.FallbackMsg("help.observe", "**{{.Command}}** [group id from {{.GroupsCommand}}] [server] [tribe id] - command adds a tribe to the observation group."),
TemplateData: map[string]interface{}{
"Command": ObserveCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.observations",
DefaultMessage: message.FallbackMsg("help.observations", "**{{.Command}}** [group id from {{.GroupsCommand}}] shows a list of observed tribes by this group."),
TemplateData: map[string]interface{}{
"Command": ObservationsCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.unobserve",
DefaultMessage: message.FallbackMsg("help.unobserve", "**{{.Command}}** [group id from {{.GroupsCommand}}] [id from {{.ObservationsCommand}}] - removes a tribe to the observation group."),
TemplateData: map[string]interface{}{
"Command": UnObserveCommand.WithPrefix(s.cfg.CommandPrefix),
"ObservationsCommand": ObservationsCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.conqueredvillages",
DefaultMessage: message.FallbackMsg("help.conqueredvillages", "**{{.Command}}** [group id from {{.GroupsCommand}}] - changes the channel on which notifications about conquered village will show. IMPORTANT! Call this command on the channel you want to display these notifications."),
TemplateData: map[string]interface{}{
"Command": ConqueredVillagesCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.unobserveconqueredvillages",
DefaultMessage: message.FallbackMsg("help.unobserveconqueredvillages", "**{{.Command}}** [group id from {{.GroupsCommand}}] - disable notifications about conquered villages."),
TemplateData: map[string]interface{}{
"Command": UnObserveConqueredVillagesCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
) )
commandsForGuildAdmins2 := fmt.Sprintf(` commandsForGuildAdmins2 := fmt.Sprintf(`
- **%s** [group id from %s] - changes the channel on which notifications about lost village will show. IMPORTANT! Call this command on the channel you want to display these notifications. - %s
- **%s** [group id from %s] - Disable notifications about lost villages. - %s
`, `,
LostVillagesCommand.WithPrefix(s.cfg.CommandPrefix), ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), MessageID: "help.lostvillages",
UnObserveLostVillagesCommand.WithPrefix(s.cfg.CommandPrefix), DefaultMessage: message.FallbackMsg("help.lostvillages", "**{{.Command}}** [group id from {{.GroupsCommand}}] changes the channel on which notifications about lost village will show. IMPORTANT! Call this command on the channel you want to display these notifications."),
GroupsCommand.WithPrefix(s.cfg.CommandPrefix), TemplateData: map[string]interface{}{
"Command": LostVillagesCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: "help.unobservelostvillages",
DefaultMessage: message.FallbackMsg("help.unobservelostvillages", "*{{.Command}}** [group id from {{.GroupsCommand}}] changes the channel on which notifications about lost village will show. IMPORTANT! Call this command on the channel you want to display these notifications."),
TemplateData: map[string]interface{}{
"Command": UnObserveLostVillagesCommand.WithPrefix(s.cfg.CommandPrefix),
"GroupsCommand": GroupsCommand.WithPrefix(s.cfg.CommandPrefix),
},
}),
) )
forAdmins := ctx.localizer.MustLocalize(&i18n.LocalizeConfig{ forAdmins := ctx.localizer.MustLocalize(&i18n.LocalizeConfig{

View File

@ -15,10 +15,10 @@
"help.deletegroup": "**{{.Command}}** [group id from {{.GroupsCommand}}] - deletes an observation group.", "help.deletegroup": "**{{.Command}}** [group id from {{.GroupsCommand}}] - deletes an observation group.",
"help.showennobledbarbs": "**{{.Command}}** [group id from {{.GroupsCommand}}] - enables/disables notifications about ennobling barbarian villages.", "help.showennobledbarbs": "**{{.Command}}** [group id from {{.GroupsCommand}}] - enables/disables notifications about ennobling barbarian villages.",
"help.observe": "**{{.Command}}** [group id from {{.GroupsCommand}}] [server] [tribe id] - command adds a tribe to the observation group.", "help.observe": "**{{.Command}}** [group id from {{.GroupsCommand}}] [server] [tribe id] - command adds a tribe to the observation group.",
"help.observations": "**{{.Command}}** [group id from {{.GroupsCommand}}] shows a list of observed tribes by this group.", "help.observations": "**{{.Command}}** [group id from {{.GroupsCommand}}] - shows a list of observed tribes by this group.",
"help.unobserve": "**{{.Command}}** [group id from {{.GroupsCommand}}] [id from {{.ObservationsCommand}}] - removes a tribe to the observation group.", "help.unobserve": "**{{.Command}}** [group id from {{.GroupsCommand}}] [id from {{.ObservationsCommand}}] - removes a tribe from the observation group.",
"help.conqueredvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] - changes the channel on which notifications about conquered village will show. IMPORTANT! Call this command on the channel you want to display these notifications.", "help.conqueredvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] - changes the channel on which notifications about conquered village will show. **IMPORTANT!** Call this command on the channel you want to display these notifications.",
"help.unobserveconqueredvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] - disable notifications about conquered villages.", "help.unobserveconqueredvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] - disable notifications about conquered villages.",
"help.lostvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] changes the channel on which notifications about lost village will show. IMPORTANT! Call this command on the channel you want to display these notifications.", "help.lostvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] changes the channel on which notifications about lost village will show. **IMPORTANT!** Call this command on the channel you want to display these notifications.",
"help.unobservelostvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] - disable notifications about lost villages." "help.unobservelostvillages": "**{{.Command}}** [group id from {{.GroupsCommand}}] - disable notifications about lost villages."
} }