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

Allow sending elements as parameter #520

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mbenoukaiss
Copy link

@mbenoukaiss mbenoukaiss commented Jan 13, 2024

Firstly thank you for your work !

Problem

I started using your library however there is one feature which I needed and was not covered by your library which is to allow using elements as params to the translation function. This may be needed when someone wants to have elements like inputs in the end result for example.

It may already already be achieved by just splitting the translation string into multiple strings like Delete {user}'s {object} would become Delete and 's however this is not practical and you would most likely end up in awkward translations since the order of words changes depending on the language.
For example in french one way to say it would be Supprime le {object} de {user}, literally Delete the {object} of {user}, correct english but the unnecessary "of" preposition adds to wordiness.
(there are probably better examples)

Proposed fix

One way I found to do it without breaking existing uses of the library would be to keep the current code and make the function return a string if there is no object (read JSX.Element) in the params, else it returns an array that may contain strings, numbers or JSX.Element.

I don't know much about (p)react or typescript since I am quite new to both, so there may be better ways to do it, let me know if you want me to change some things.

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

Successfully merging this pull request may close these issues.

None yet

1 participant