Skip to content

feat: allow array as replacements #201

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

Closed
wants to merge 2 commits into from

Conversation

Fuzzyma
Copy link

@Fuzzyma Fuzzyma commented Feb 24, 2025

This little change in ts allows something that is already possible:

trans('Hello {0}', ['World'])

I often use this pattern because its just easier and less to remember. It also works with vue-i18n.

NOTE: I also removed the count property because I didnt see it used anywhere in the whole codebase. Let me know if that was a feature that you needed or public api and I will add it back.

I also commited the changed package-lock. Seems like the version wasnt updated there in a while

@xiCO2k
Copy link
Owner

xiCO2k commented Feb 24, 2025

Does this work on the php side?

@Fuzzyma
Copy link
Author

Fuzzyma commented Feb 24, 2025

@xiCO2k I only changed the access via javascript. No php involved at all.

Had to add back the count thing tho because its used for transChoice. Tests should pass again

@Fuzzyma
Copy link
Author

Fuzzyma commented Feb 27, 2025

Sorry I just realized I made a mistake in the example. It should obviously be :0 and not {0}. I confused it with vue-i18n. But it works as intended when using :0

@Fuzzyma
Copy link
Author

Fuzzyma commented Mar 7, 2025

@xiCO2k let me know if there is anything I can do to get this over the line :)

@xiCO2k
Copy link
Owner

xiCO2k commented Mar 29, 2025

Closing this one, since on the php side that does not work, and this package tries to mimic everything that laravel does on the php side.

Thanks for the PR.

@xiCO2k xiCO2k closed this Mar 29, 2025
@Fuzzyma
Copy link
Author

Fuzzyma commented Mar 29, 2025

I understand the concern. But I think adapting a lib to the language it's running in is only natural.

This and the fact that the most popular i18n package for vue allows it and people are used to it.

I am also quite surprised that this doesn't work in php. Js objects are php arrays and js arrays are also php arrays. So why would passing in an array not work on the php side?

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.

2 participants