This commit is contained in:
1 parent
c08dd355c0
commit
297efaa4a6
3 files changed
+45
-24
No files matched your search
@@ -53,13 +53,21 @@ func Path(ctx context.Context, pp ...string) string {
|
||||
}
|
||||
|
||||
func PathForLang(ctx context.Context, lang string, pp ...string) string {
|
||||
slog.Debug("computing path for lang", "pp", pp, "lang", lang)
|
||||
s, ok := ctx.Value(serviceKey).(*Service)
|
||||
if !ok {
|
||||
slog.Error("could not extract translation service from context for translating path", "ctx", ctx, "path", pp)
|
||||
return path.Join(pp...)
|
||||
}
|
||||
|
||||
// remove leading ""
|
||||
for len(pp) > 0 && pp[0] == "" {
|
||||
pp = pp[1:]
|
||||
}
|
||||
|
||||
if len(pp) > 0 {
|
||||
|
||||
slog.Debug("computing path for lang", "pp", pp, "lang", lang, "pp[0]", pp[0], "translations", s.translations)
|
||||
if _, ok := s.translations[pp[0]]; ok {
|
||||
pp = pp[1:]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user