From 27fd28745cc197dc83821ecb4b8121def8447521 Mon Sep 17 00:00:00 2001 From: Mike McRill Date: Mon, 5 Feb 2024 08:56:19 -0600 Subject: [PATCH] Update shared and fix TypeScript output to match prettier --- go.work.sum | 1 + go/formats_typescript.go | 22 +++++++++++----------- go/formats_typescript_test.go | 26 +++++++++++++------------- shared | 2 +- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/go.work.sum b/go.work.sum index 4ff5eef..b5ac57b 100644 --- a/go.work.sum +++ b/go.work.sum @@ -253,6 +253,7 @@ github.com/googleapis/gax-go/v2 v2.10.0/go.mod h1:4UOEnMCrxsSqQ940WnTiD6qJ63le2e github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/matoous/go-nanoid v1.5.0 h1:VRorl6uCngneC4oUQqOYtO3S0H5QKFtKuKycFG3euek= diff --git a/go/formats_typescript.go b/go/formats_typescript.go index 79ca78d..7eace35 100644 --- a/go/formats_typescript.go +++ b/go/formats_typescript.go @@ -9,32 +9,32 @@ var typescript = format{ //nolint:gochecknoglobals export type ISO639Code = string; export interface Translation { - [key: ISO639Code]: string, + [key: ISO639Code]: string; } export const ISO639Codes: { - [key: ISO639Code]: string, + [key: ISO639Code]: string; } = { {{- range $key, $value := .ISO639Codes }} - {{ $key }}: "{{ $value }}", + {{ $key }}: "{{ $value }}", {{- end }} }; -export function Translate (c: ISO639Code, t: Translation): string { - const code = c.split("-")[0]; - if (t[code] !== undefined) { - return t[code]; - } +export function Translate(c: ISO639Code, t: Translation): string { + const code = c.split("-")[0]; + if (t[code] !== undefined) { + return t[code]; + } - return t["{{ .DefaultCode }}"]; + return t["{{ .DefaultCode }}"]; } {{ range $name, $values := .Translations }} export const {{ $name }}: Translation = { {{- range $code, $value := $values }} {{- if ne $code "context" }} - {{ $code }}: ` + "`{{ $value }}`" + `, + {{ $code }}: ` + "`{{ $value }}`" + `, {{- end }}{{ end }} }; {{ end -}} - `, +`, } diff --git a/go/formats_typescript_test.go b/go/formats_typescript_test.go index 696268e..80d4f6f 100644 --- a/go/formats_typescript_test.go +++ b/go/formats_typescript_test.go @@ -13,32 +13,32 @@ func TestFormatsTypescript(t *testing.T) { export type ISO639Code = string; export interface Translation { - [key: ISO639Code]: string, + [key: ISO639Code]: string; } export const ISO639Codes: { - [key: ISO639Code]: string, + [key: ISO639Code]: string; } = { - de: "Deutsch", - en: "English", + de: "Deutsch", + en: "English", }; -export function Translate (c: ISO639Code, t: Translation): string { - const code = c.split("-")[0]; - if (t[code] !== undefined) { - return t[code]; - } +export function Translate(c: ISO639Code, t: Translation): string { + const code = c.split("-")[0]; + if (t[code] !== undefined) { + return t[code]; + } - return t["en"]; + return t["en"]; } export const HelloWorld: Translation = { - de: ` + "`Hallo Welt`" + `, - en: ` + "`Hello World`" + `, + de: ` + "`Hallo Welt`" + `, + en: ` + "`Hello World`" + `, }; export const TranslateMe: Translation = { - en: ` + "`Translate Me`" + `, + en: ` + "`Translate Me`" + `, }; `, }) diff --git a/shared b/shared index 597e9e6..f4aebe5 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit 597e9e6d0ba7264c68403d773b4ca89cfa19d6ed +Subproject commit f4aebe5e334467e2a5730380c7b9c4415c1a9122