feat(transloco): transpile function arguments in FunctionalTranspiler (#829)#832
Conversation
…jsverse#829) Signed-off-by: isc-auf <frederic.aubert@isc-ejpd.admin.ch>
@jsverse/transloco
@jsverse/transloco-locale
@jsverse/transloco-messageformat
@jsverse/transloco-optimize
@jsverse/transloco-persist-lang
@jsverse/transloco-persist-translations
@jsverse/transloco-preload-langs
@jsverse/transloco-schematics
@jsverse/transloco-scoped-libs
@jsverse/transloco-utils
@jsverse/transloco-validator
commit: |
|
@shaharkazaz ? May I assist you in letting this merged? thxs |
| return func.transpile(...getFunctionArgs(args)); | ||
| return func.transpile( | ||
| ...getFunctionArgs(args).map((arg) => | ||
| this.transpile({ value: arg, ...rest }), | ||
| ), |
There was a problem hiding this comment.
The question here do we want to support nested function transpilations? I'm not sure that would actually work.
Add a test case, if that works, cool. otherwise let's skip directly to the parent transpiler
const transpiledArgs = super.transpile({value: getFunctionArgs(args), ...rest});
return func.transpile(...transpiledArgs);
There was a problem hiding this comment.
You are right. As far as I can tell, this PR doesn't implements nesting function because getFunctionArgs use a simple pattern to separate the args, namely on comma. A regexp engine with support of nesting would be needed. I sure can look into that, but I could also live with this limitation.
There was a problem hiding this comment.
Make the changes and test the pkg-pr-new release
There was a problem hiding this comment.
Not exactly sure what do you want me to do / change? I think the original code with the map call should do it... Thks
There was a problem hiding this comment.
Please call the super like in the code I suggested
5597e5d to
ec8ff1c
Compare
…jsverse#829) Signed-off-by: isc-auf <frederic.aubert@isc-ejpd.admin.ch>
|
I pushed what you suggested. I called this.transpile (instead of super.transpile) on the functionArgs. It shouldn't have any impact, but would allow nesting function if we ever improved the parsing in getFunctionArgs (to ignore coma when in a nested context such as [[ or {{). |
|
Hello @shaharkazaz would you agree to go forwards? I'd enjoy this or a new similar pr merged |
|
Hello @shaharkazaz? Can we imagine merging it? Thks |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughUpdated the Changes
Fun fact: Did you know that some languages have different plural forms depending on the number? For example, in Polish, the word "kotów" (cats) has multiple plural forms depending on whether you're talking about 2-4 cats, 5+ cats, or just 1 cat. This is why robust i18n systems like Transloco must support complex pluralization rules beyond the simple singular/plural distinction! 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@shaharkazaz wow! great didn't expect it now, nice gift. Thanks for your work. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: 829
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Bug Fixes
Tests