From 5d826c21dacb4d0023a725f31552b5582b36c0d1 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Thu, 14 Nov 2024 22:35:35 +0100 Subject: [PATCH] RE18 translation (#22) * translate the item for display in the invoice * add documentation to the makefile --- Makefile | 23 +++++++++++++++-------- internal/service/booking/models.go | 22 +++++++++++++++++++++- internal/view/layout/base_templ.go | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 14111f0..b882d90 100644 --- a/Makefile +++ b/Makefile @@ -3,24 +3,31 @@ PORT=8000 DB_USER=ruidy DB_NAME=villafleurie -build: format lint +build: format lint ## Build the binary @docker build -t ${NAME}:latest . -run: build +run: build ## Run the binary @docker run -p ${PORT}:${PORT} -e DATABASE_URL="host=docker.for.mac.host.internal user=${DB_USER} database=${DB_NAME}" -e PORT=${PORT} ${NAME} -dev: +dev: ## Run the binary in dev mode @docker build -t ${NAME}:dev -f Dockerfile.dev . @docker run -p ${PORT}:${PORT} --rm -v `pwd`:/app -v /app/tmp --name ${NAME} -e DATABASE_URL="host=docker.for.mac.host.internal user=${DB_USER} database=${DB_NAME}" -e PORT=${PORT} ${NAME}:dev -test: +test: ## Run the tests @go test ./... -up-deps: +up-deps: ## Update dependencies @go get -u ./... -cron: +cron: ## Run the cron @go run cmd/cron/main.go -format: +format: ## Format the code @templ generate internal/views @templ fmt . @go fmt ./... -lint: +lint: ## Lint the code @golangci-lint run ./... +help: ## Display this help message + @echo "Usage: make [command]" + @echo + @echo "Commands:" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}' + +.DEFAULT_GOAL := help .PHONY: build run dev templ format lint diff --git a/internal/service/booking/models.go b/internal/service/booking/models.go index 04ecd4d..582156f 100644 --- a/internal/service/booking/models.go +++ b/internal/service/booking/models.go @@ -50,7 +50,7 @@ func (b Booking) Serialize(hc *config.Host) map[string]any { "to": b.To.Format("02/01/2006"), "lines": u.Map(b.Items, func(i Item) map[string]any { return map[string]any{ - "name": i.Item, + "name": i.ToFrench(), "quantity": i.Quantity, "price": i.Price, "total": i.Price * float64(i.Quantity), @@ -86,3 +86,23 @@ type Item struct { Quantity int Price float64 `gorm:"type:decimal(10,2)"` } + +// ToFrench translates the item name to french +func (i Item) ToFrench() string { + switch i.Item { + case "T2": + return "T2" + case "T3": + return "T3" + case "Airport": + return "Transport Aéroport" + case "Port": + return "Transport Gare Maritime" + case "Transport": + return "Transport" + case "Taxes": + return "Taxes de sejour" + default: + return i.Item + } +} diff --git a/internal/view/layout/base_templ.go b/internal/view/layout/base_templ.go index 95b5d02..d2e5dc9 100644 --- a/internal/view/layout/base_templ.go +++ b/internal/view/layout/base_templ.go @@ -29,7 +29,7 @@ func BaseLayout() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("RentEase | Your Property Management System
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("RentEase | Your Property Management System
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }