Skip to content

Commit

Permalink
fixed locale to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
ugol committed Apr 27, 2023
1 parent 3504b6d commit 28881fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"os"
"os/signal"
"regexp"
"strings"
"text/template"
"time"
)
Expand Down Expand Up @@ -147,7 +148,7 @@ jr run --templateFileName ~/.jr/templates/net_device.tpl
functions.JrContext.Num = num
functions.JrContext.Range = make([]int, num)
functions.JrContext.Frequency = frequency
functions.JrContext.Locale = locale
functions.JrContext.Locale = strings.ToLower(locale)
functions.JrContext.Seed = seed
functions.JrContext.TemplateDir = templateDir
functions.JrContext.Ctx = make(map[string]string)
Expand Down Expand Up @@ -284,7 +285,7 @@ func init() {
runCmd.Flags().String("outputTemplate", "{{.V}}\n", "Formatting of K,V on standard output")
runCmd.Flags().BoolP("oneline", "l", false, "strips /n from output, for example to be pipelined to tools like kcat")
runCmd.Flags().BoolP("autocreate", "a", false, "if enabled, autocreate topics")
runCmd.Flags().String("locale", functions.JrContext.Locale, "List of locales")
runCmd.Flags().String("locale", functions.JrContext.Locale, "Locale")

runCmd.Flags().BoolP("schemaRegistry", "s", false, "If you want to use Confluent Schema Registry")
runCmd.Flags().String("serializer", "json-schema", "Type of serializer: json-schema, avro-generic, avro, protobuf")
Expand Down
2 changes: 1 addition & 1 deletion functions/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func init() {
Range: make([]int, NUM),
Frequency: FREQUENCY,
Duration: DURATION,
Locale: "US",
Locale: "us",
Seed: time.Now().UTC().UnixNano(),
Counters: make(map[string]int),
}
Expand Down
2 changes: 1 addition & 1 deletion functions/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func cache(name string) (bool, error) {
if v == nil {
locale := JrContext.Locale
filename := fmt.Sprintf("%s/data/%s/%s", JrContext.TemplateDir, locale, name)
if locale != "US" && !(fileExists(filename)) {
if locale != "us" && !(fileExists(filename)) {
filename = fmt.Sprintf("%s/data/%s/%s", JrContext.TemplateDir, "US", name)
}
data[name] = initialize(filename)
Expand Down

0 comments on commit 28881fb

Please sign in to comment.