chore: remove template languague (#6245)
This commit is contained in:
parent
75e3ca02b1
commit
af883a4b3f
6 changed files with 14 additions and 18 deletions
|
|
@ -114,7 +114,7 @@ func (c *CmdConfigure) configureLinkedTypes(templateItem templates.Template) {
|
|||
break
|
||||
}
|
||||
|
||||
linkedTemplateItem.SetCombinedTitle()
|
||||
linkedTemplateItem.SetCombinedTitle(c.lang)
|
||||
|
||||
category := DeviceCategory(linkedTemplate.Usage)
|
||||
localizeMap := localizeMap{
|
||||
|
|
|
|||
|
|
@ -328,10 +328,9 @@ func (c *CmdConfigure) fetchElements(deviceCategory DeviceCategory) []templates.
|
|||
titleTmpl := templates.Template{
|
||||
TemplateDefinition: tmpl.TemplateDefinition,
|
||||
ConfigDefaults: tmpl.ConfigDefaults,
|
||||
Lang: c.lang,
|
||||
}
|
||||
title := t
|
||||
groupTitle := titleTmpl.GroupTitle()
|
||||
groupTitle := titleTmpl.GroupTitle(c.lang)
|
||||
if groupTitle != "" {
|
||||
title += " [" + groupTitle + "]"
|
||||
}
|
||||
|
|
@ -359,7 +358,7 @@ func (c *CmdConfigure) fetchElements(deviceCategory DeviceCategory) []templates.
|
|||
return true
|
||||
}
|
||||
if items[i].Group != items[j].Group {
|
||||
return strings.ToLower(items[i].GroupTitle()) < strings.ToLower(items[j].GroupTitle())
|
||||
return strings.ToLower(items[i].GroupTitle(c.lang)) < strings.ToLower(items[j].GroupTitle(c.lang))
|
||||
}
|
||||
return strings.ToLower(items[i].Title()) < strings.ToLower(items[j].Title())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func (c *CmdConfigure) askSelection(message string, items []string) (string, int
|
|||
|
||||
// selectItem selects item from list
|
||||
func (c *CmdConfigure) selectItem(deviceCategory DeviceCategory) templates.Template {
|
||||
emptyItem := templates.Template{Lang: c.lang}
|
||||
var emptyItem templates.Template
|
||||
emptyItem.SetTitle(c.localizedString("ItemNotPresent", nil))
|
||||
|
||||
elements := c.fetchElements(deviceCategory)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
language = "de"
|
||||
docsPath = "../../../templates/docs"
|
||||
websitePath = "../../../templates/evcc.io"
|
||||
)
|
||||
|
|
@ -49,7 +50,7 @@ func generateClass(class templates.Class) error {
|
|||
}
|
||||
|
||||
for index, product := range tmpl.Products {
|
||||
fmt.Println(tmpl.Template + ": " + product.Title(tmpl.Lang))
|
||||
fmt.Println(tmpl.Template + ": " + product.Title(language))
|
||||
|
||||
if err := writeTemplate(class, index, product, tmpl); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ type Template struct {
|
|||
|
||||
ConfigDefaults ConfigDefaults `json:"-"`
|
||||
|
||||
Lang string
|
||||
|
||||
title string
|
||||
titles []string
|
||||
}
|
||||
|
|
@ -84,9 +82,9 @@ func (t *Template) Validate() error {
|
|||
}
|
||||
|
||||
// set the language title by combining all product titles
|
||||
func (t *Template) SetCombinedTitle() {
|
||||
func (t *Template) SetCombinedTitle(lang string) {
|
||||
if len(t.titles) == 0 {
|
||||
t.resolveTitles()
|
||||
t.resolveTitles(lang)
|
||||
}
|
||||
|
||||
t.title = strings.Join(t.titles, "/")
|
||||
|
|
@ -104,19 +102,17 @@ func (t *Template) Title() string {
|
|||
|
||||
// return the language specific product titles
|
||||
func (t *Template) Titles(lang string) []string {
|
||||
t.Lang = lang
|
||||
|
||||
if len(t.titles) == 0 {
|
||||
t.resolveTitles()
|
||||
t.resolveTitles(lang)
|
||||
}
|
||||
|
||||
return t.titles
|
||||
}
|
||||
|
||||
// set the language specific product titles
|
||||
func (t *Template) resolveTitles() {
|
||||
func (t *Template) resolveTitles(lang string) {
|
||||
for _, p := range t.Products {
|
||||
t.titles = append(t.titles, p.Title(t.Lang))
|
||||
t.titles = append(t.titles, p.Title(lang))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,9 +159,9 @@ func (t *Template) ResolveGroup() error {
|
|||
}
|
||||
|
||||
// return the language specific group title
|
||||
func (t *Template) GroupTitle() string {
|
||||
func (t *Template) GroupTitle(lang string) string {
|
||||
tl := t.ConfigDefaults.DeviceGroups[t.Group]
|
||||
return tl.String(t.Lang)
|
||||
return tl.String(lang)
|
||||
}
|
||||
|
||||
// Defaults returns a map of default values for the template
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func (t *Template) RenderDocumentation(product Product, values map[string]interf
|
|||
"Template": t.Template,
|
||||
"ProductBrand": product.Brand,
|
||||
"ProductDescription": product.Description.String(lang),
|
||||
"ProductGroup": t.GroupTitle(),
|
||||
"ProductGroup": t.GroupTitle(lang),
|
||||
"Capabilities": t.Capabilities,
|
||||
"Requirements": t.Requirements.EVCC,
|
||||
"RequirementDescription": t.Requirements.Description.String(lang),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue