Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request]: Translation key as vector (similar to how get-in works) #27

Open
kirillsalykin opened this issue Aug 18, 2021 · 2 comments

Comments

@kirillsalykin
Copy link

In some scenarios accessing translation by namespaced key overcomplicates things, just vector with path can work.

Consider this scenario:
You want to show a document title per type.

i18n.clj

...
        :documents {:type1 {:title "type1"
                                           :filename "f1"}
                              :type2 {:title "type2"
                                           :filename "f2"}
                              :type1 {:title "type3"
                                           :filename "f3"}
(for [t [:type1 :type2 :type3]
  (translate :en (keyword (str "documents." (name t)) "filename" )))

This adds keyword manipulation.

Compare with

(for [t [:type1 :type2 :type3]
  (translate :en [:documents t :filename])))

This feels way simpler and cleaner.

What do you think?

@tonsky
Copy link
Owner

tonsky commented Aug 18, 2021

Yes, looks good. Want to make a PR?

@kirillsalykin
Copy link
Author

Will try to make one, may take a while tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants