evcc-io/cmd/configure/texts.go
Andreas Linde a52f52b406
Template enhancements (#2274)
- Only add SMA HEMS Setup, if required values exist (e.g. machine-id). Also asks the user if this should be added
- New templates: Alfen, PC Electric Garo, go-e V3 (moved into separate template), Tasmota meter, Huawei inverter with Sdongle
- Updated templates: SolarEdge Inverter, Sunspec
- New capabilities can be assigned: 1p3p, RFID
- Added group information instead of `generic` flag. Used e.g. for marking power plugs or generic devices
- Requirement description text can now be markdown text (required for documentation page)
- Replaced `description` with product list, separating brand from description (required for documentation page)
- Generate newly structured documentation yaml files
- Fix https://github.com/evcc-io/evcc/issues/2385
2022-01-23 15:21:13 +01:00

38 lines
1.9 KiB
Go

package configure
import (
"errors"
"github.com/nicksnyder/go-i18n/v2/i18n"
)
// setDefaultTexts sets default language specific texts
func (c *CmdConfigure) setDefaultTexts() {
c.errItemNotPresent = errors.New(c.localizedString("Error_ItemNotPresent", nil))
c.errDeviceNotValid = errors.New(c.localizedString("Error_DeviceNotValid", nil))
c.updateDeviceCategoryTexts(DeviceCategoryCharger, "Category_ChargerTitle", "Category_ChargerArticle", "Category_ChargerAdditional")
c.updateDeviceCategoryTexts(DeviceCategoryGuidedSetup, "Category_SystemTitle", "Category_SystemArticle", "Category_SystemAdditional")
c.updateDeviceCategoryTexts(DeviceCategoryGridMeter, "Category_GridMeterTitle", "Category_GridMeterArticle", "Category_GridMeterAdditional")
c.updateDeviceCategoryTexts(DeviceCategoryPVMeter, "Category_PVMeterTitle", "Category_PVMeterArticle", "Category_PVMeterAdditional")
c.updateDeviceCategoryTexts(DeviceCategoryBatteryMeter, "Category_BatteryMeter", "Category_BatteryMeterArticle", "Category_BatteryMeterAdditional")
c.updateDeviceCategoryTexts(DeviceCategoryChargeMeter, "Category_ChargeMeterTitle", "Category_ChargeMeterArticle", "Category_ChargeMeterAdditional")
c.updateDeviceCategoryTexts(DeviceCategoryVehicle, "Category_VehicleTitle", "Category_VehicleArticle", "Category_VehicleAdditional")
}
// updateDeviceCategoryTexts updates the texts for a device category
func (c *CmdConfigure) updateDeviceCategoryTexts(category DeviceCategory, title, article, additional string) {
data := DeviceCategories[category]
data.title = c.localizedString(title, nil)
data.article = c.localizedString(article, nil)
data.additional = c.localizedString(additional, nil)
DeviceCategories[category] = data
}
// localizedString is a helper for getting a localized string
func (c *CmdConfigure) localizedString(key string, templateData localizeMap) string {
return c.localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: key,
TemplateData: templateData,
})
}