Skip to content

Commit 6b6549c

Browse files
committed
standardize i18n keys for consistency rename keys
fix: avatar url `null` console warnings.
1 parent cd4b9a9 commit 6b6549c

File tree

118 files changed

+1515
-992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1515
-992
lines changed

cmd/ai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func handleUpdateAIProvider(r *fastglue.Request) error {
4343
req providerUpdateReq
4444
)
4545
if err := r.Decode(&req, "json"); err != nil {
46-
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), nil))
46+
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil))
4747
}
4848
if err := app.ai.UpdateProvider(req.Provider, req.APIKey); err != nil {
4949
return sendErrorEnvelope(r, err)

cmd/auth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ func handleOIDCCallback(r *fastglue.Request) error {
6363
sessionState, err := app.auth.GetSessionValue(r, oidcStateSessKey)
6464
if err != nil {
6565
app.lo.Error("error getting state from session", "error", err)
66-
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.entities.session}"), nil, envelope.GeneralError)
66+
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.session}"), nil, envelope.GeneralError)
6767
}
6868
if state != sessionState {
69-
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.mismatch", "name", "{globals.entities.state}"), nil, envelope.GeneralError)
69+
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.mismatch", "name", "{globals.terms.state}"), nil, envelope.GeneralError)
7070
}
7171

7272
_, claims, err := app.auth.ExchangeOIDCToken(r.RequestCtx, providerID, code)
7373
if err != nil {
7474
app.lo.Error("error exchanging oidc token", "error", err)
7575
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError,
76-
app.i18n.T("oidc.errorExchangingToken"), nil, envelope.GeneralError)
76+
app.i18n.T("globals.messages.errorExchangingToken"), nil, envelope.GeneralError)
7777
}
7878

7979
// Lookup the user by email and set the session.
@@ -89,7 +89,7 @@ func handleOIDCCallback(r *fastglue.Request) error {
8989
LastName: user.LastName,
9090
}, r); err != nil {
9191
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError,
92-
app.i18n.Ts("globals.messages.errorSaving", "name", "{globals.entities.session}"), nil, envelope.GeneralError)
92+
app.i18n.Ts("globals.messages.errorSaving", "name", "{globals.terms.session}"), nil, envelope.GeneralError)
9393
}
9494

9595
return r.Redirect("/", fasthttp.StatusFound, nil, "")

cmd/automation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func handleUpdateAutomationRule(r *fastglue.Request) error {
5959
}
6060

6161
if err := r.Decode(&rule, "json"); err != nil {
62-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), nil, envelope.InputError)
62+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
6363
}
6464

6565
if err = app.automation.UpdateRule(id, rule); err != nil {
@@ -75,7 +75,7 @@ func handleCreateAutomationRule(r *fastglue.Request) error {
7575
rule = amodels.RuleRecord{}
7676
)
7777
if err := r.Decode(&rule, "json"); err != nil {
78-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), nil, envelope.InputError)
78+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
7979
}
8080
if err := app.automation.CreateRule(rule); err != nil {
8181
return sendErrorEnvelope(r, err)
@@ -106,7 +106,7 @@ func handleUpdateAutomationRuleWeights(r *fastglue.Request) error {
106106
weights = make(map[int]int)
107107
)
108108
if err := r.Decode(&weights, "json"); err != nil {
109-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), nil, envelope.InputError)
109+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
110110
}
111111
err := app.automation.UpdateRuleWeights(weights)
112112
if err != nil {

cmd/business_hours.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func handleGetBusinessHour(r *fastglue.Request) error {
3636
if err == businessHours.ErrBusinessHoursNotFound {
3737
return r.SendErrorEnvelope(fasthttp.StatusNotFound, err.Error(), nil, envelope.NotFoundError)
3838
}
39-
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.entities.businessHour}"), nil, "")
39+
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.businessHour}"), nil, "")
4040
}
4141
return r.SendEnvelope(businessHour)
4242
}
@@ -48,7 +48,7 @@ func handleCreateBusinessHours(r *fastglue.Request) error {
4848
businessHours = models.BusinessHours{}
4949
)
5050
if err := r.Decode(&businessHours, "json"); err != nil {
51-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), nil, envelope.InputError)
51+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
5252
}
5353

5454
if businessHours.Name == "" {
@@ -88,7 +88,7 @@ func handleUpdateBusinessHours(r *fastglue.Request) error {
8888
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
8989
}
9090
if err := r.Decode(&businessHours, "json"); err != nil {
91-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), err.Error(), envelope.InputError)
91+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
9292
}
9393
if businessHours.Name == "" {
9494
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "business hour `Name`"), nil, envelope.InputError)

cmd/conversation.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func handleGetViewConversations(r *fastglue.Request) error {
156156

157157
// No lists found, user doesn't have access to any conversations.
158158
if len(lists) == 0 {
159-
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.T("authz.permissionDenied"), nil, envelope.PermissionError)
159+
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.denied", "name", "{globals.terms.permission}"), nil, envelope.PermissionError)
160160
}
161161

162162
conversations, err := app.conversation.GetViewConversationsList(user.ID, user.Teams.IDs(), lists, order, orderBy, string(view.Filters), page, pageSize)
@@ -460,7 +460,7 @@ func handleUpdateConversationtags(r *fastglue.Request) error {
460460

461461
if err := json.Unmarshal(tagJSON, &tagNames); err != nil {
462462
app.lo.Error("error unmarshalling tags JSON", "error", err)
463-
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), nil, envelope.InputError)
463+
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
464464
}
465465

466466
user, err := app.user.GetAgent(auser.ID)
@@ -624,7 +624,7 @@ func handleCreateConversation(r *fastglue.Request) error {
624624
InboxID: inboxID,
625625
}
626626
if err := app.user.CreateContact(&contact); err != nil {
627-
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorCreating", "name", "{globals.entities.contact}"), nil))
627+
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorCreating", "name", "{globals.terms.contact}"), nil))
628628
}
629629

630630
// Create conversation
@@ -639,7 +639,7 @@ func handleCreateConversation(r *fastglue.Request) error {
639639
)
640640
if err != nil {
641641
app.lo.Error("error creating conversation", "error", err)
642-
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorCreating", "name", "{globals.entities.conversation}"), nil))
642+
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorCreating", "name", "{globals.terms.conversation}"), nil))
643643
}
644644

645645
// Send reply to the created conversation.
@@ -648,7 +648,7 @@ func handleCreateConversation(r *fastglue.Request) error {
648648
if err := app.conversation.DeleteConversation(conversationUUID); err != nil {
649649
app.lo.Error("error deleting conversation", "error", err)
650650
}
651-
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorSending", "name", "{globals.entities.conversation}"), nil))
651+
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorSending", "name", "{globals.terms.conversation}"), nil))
652652
}
653653

654654
// Assign the conversation to the agent or team.

cmd/handlers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func serveIndexPage(r *fastglue.Request) error {
214214
// Serve the index.html file from the embedded filesystem.
215215
file, err := app.fs.Get(path.Join(frontendDir, "index.html"))
216216
if err != nil {
217-
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.entities.file}"), nil, envelope.NotFoundError)
217+
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.file}"), nil, envelope.NotFoundError)
218218
}
219219
r.RequestCtx.Response.Header.Set("Content-Type", "text/html")
220220
r.RequestCtx.SetBody(file.ReadBytes())
@@ -236,7 +236,7 @@ func serveStaticFiles(r *fastglue.Request) error {
236236

237237
file, err := app.fs.Get(filePath)
238238
if err != nil {
239-
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.entities.file}"), nil, envelope.NotFoundError)
239+
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.file}"), nil, envelope.NotFoundError)
240240
}
241241

242242
// Set the appropriate Content-Type based on the file extension.
@@ -261,7 +261,7 @@ func serveFrontendStaticFiles(r *fastglue.Request) error {
261261
finalPath := filepath.Join(frontendDir, filePath)
262262
file, err := app.fs.Get(finalPath)
263263
if err != nil {
264-
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.entities.file}"), nil, envelope.NotFoundError)
264+
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.file}"), nil, envelope.NotFoundError)
265265
}
266266

267267
// Set the appropriate Content-Type based on the file extension.

cmd/inboxes.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func handleGetInbox(r *fastglue.Request) error {
3232
}
3333
if err := inbox.ClearPasswords(); err != nil {
3434
app.lo.Error("error clearing inbox passwords from response", "error", err)
35-
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.entities.inbox}"), nil)
35+
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.inbox}"), nil)
3636
}
3737
return r.SendEnvelope(inbox)
3838
}
@@ -44,7 +44,7 @@ func handleCreateInbox(r *fastglue.Request) error {
4444
inbox = imodels.Inbox{}
4545
)
4646
if err := r.Decode(&inbox, "json"); err != nil {
47-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), err.Error(), envelope.InputError)
47+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
4848
}
4949

5050
if err := app.inbox.Create(inbox); err != nil {
@@ -56,7 +56,7 @@ func handleCreateInbox(r *fastglue.Request) error {
5656
}
5757

5858
if err := reloadInboxes(app); err != nil {
59-
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.entities.inbox}"), nil, envelope.GeneralError)
59+
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
6060
}
6161

6262
return r.SendEnvelope(true)
@@ -75,7 +75,7 @@ func handleUpdateInbox(r *fastglue.Request) error {
7575
}
7676

7777
if err := r.Decode(&inbox, "json"); err != nil {
78-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.entities.request}"), err.Error(), envelope.InputError)
78+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
7979
}
8080

8181
if err := validateInbox(app, inbox); err != nil {
@@ -88,7 +88,7 @@ func handleUpdateInbox(r *fastglue.Request) error {
8888
}
8989

9090
if err := reloadInboxes(app); err != nil {
91-
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.entities.inbox}"), nil, envelope.GeneralError)
91+
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
9292
}
9393

9494
return r.SendEnvelope(inbox)
@@ -110,7 +110,7 @@ func handleToggleInbox(r *fastglue.Request) error {
110110
}
111111

112112
if err := reloadInboxes(app); err != nil {
113-
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.entities.inbox}"), nil, envelope.GeneralError)
113+
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
114114
}
115115

116116
return r.SendEnvelope(true)
@@ -128,7 +128,7 @@ func handleDeleteInbox(r *fastglue.Request) error {
128128
}
129129

130130
if err := reloadInboxes(app); err != nil {
131-
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.entities.inbox}"), nil, envelope.GeneralError)
131+
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
132132
}
133133

134134
return r.SendEnvelope(true)
@@ -138,19 +138,19 @@ func handleDeleteInbox(r *fastglue.Request) error {
138138
func validateInbox(app *App, inbox imodels.Inbox) error {
139139
// Validate from address.
140140
if _, err := mail.ParseAddress(inbox.From); err != nil {
141-
return envelope.NewError(envelope.InputError, app.i18n.Ts("email.invalidFromAddress"), nil)
141+
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalidFromAddress"), nil)
142142
}
143143

144144
if len(inbox.Config) == 0 {
145-
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "{globals.entities.inbox} config"), nil)
145+
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "{globals.terms.inbox} config"), nil)
146146
}
147147

148148
if inbox.Name == "" {
149-
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "{globals.entities.inbox} name"), nil)
149+
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "{globals.terms.inbox} name"), nil)
150150
}
151151

152152
if inbox.Channel == "" {
153-
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "{globals.entities.inbox} channel"), nil)
153+
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "{globals.terms.inbox} channel"), nil)
154154
}
155155
return nil
156156
}

cmd/init.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,10 @@ func initOIDC(db *sqlx.DB, settings *setting.Manager, i18n *i18n.I18n) *oidc.Man
677677

678678
// initI18n inits i18n.
679679
func initI18n(fs stuffbin.FileSystem) *i18n.I18n {
680-
file, err := fs.Get("i18n/" + cmp.Or(ko.String("app.lang"), defLang) + ".json")
680+
fileName := cmp.Or(ko.String("app.lang"), defLang)
681+
file, err := fs.Get("i18n/" + fileName + ".json")
681682
if err != nil {
682-
log.Fatalf("error reading i18n language file: %v", err)
683+
log.Fatalf("error reading i18n language file `%s` : %v", fileName, err)
683684
}
684685
i18n, err := i18n.New(file.ReadBytes())
685686
if err != nil {

cmd/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func handleLogin(r *fastglue.Request) error {
5454
func handleLogout(r *fastglue.Request) error {
5555
var app = r.Context.(*App)
5656
if err := app.auth.DestroySession(r); err != nil {
57-
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorDestroying", "name", "{globals.entities.session}"), nil))
57+
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorDestroying", "name", "{globals.terms.session}"), nil))
5858
}
5959
// Add no-cache headers.
6060
r.RequestCtx.Response.Header.Add("Cache-Control",

0 commit comments

Comments
 (0)