-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[Translation] Phrase translation provider #49231
Conversation
wickedOne
commented
Feb 4, 2023
Q | A |
---|---|
Branch? | 6.3 |
Bug fix? | no |
New feature? | yes |
Deprecations? | no |
Tickets | Fix #49142 |
License | MIT |
Doc PR | symfony/symfony-docs#17861 |
Recipe PR | symfony/recipes#1172 |
not sure what's wrong with the license file... and the possible typo according to fabbot.io appears to be an unrelated false positive |
thanks @xabbuh for the hint: fixed the licence problem |
out of curiosity: why is the |
Nice one @wickedOne! Just tested it with the Symfony demo and initial push and pull works quite well with the recipe & docs, but when I update something in Phrase and do a pull again, there is no change in local files. do i miss something? btw, see #28423 for strict_type |
hmmm, @chr-hertel that's weird, and thanks for linking the stric types discussion, revealed some things i wasn't aware of. nevertheless i think this mr has things covered regardless |
Okay, tried it again. what I did:
With explicit locales/messages on pull it works, at least for other locales than tr. don't get it. it's available in phrase... |
yes, looks like the --force is needed to do the intesect |
@chr-hertel sorry, completely misread your initial question where you were talking about a pull rather than a push. |
[deleted some of my comments to remove the noise] @chr-hertel it appears this is intended behaviour: in order to overwrite your application's messages with changes done in phrase the
similar behaviour for the push command where the checking this behaviour however, i did notice a bug in the delete routine ( |
ok, added fix for the |
fixed the locale initialisation which caused the error message mentioned in #issuecomment-1416735752 |
Nice, yes, now it works for me with the demo! 👍 |
src/Symfony/Component/Translation/Bridge/Phrase/Event/AbstractPhraseEvent.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Translation/Bridge/Phrase/Event/AbstractPhraseEvent.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Translation/Bridge/Phrase/PhraseProvider.php
Outdated
Show resolved
Hide resolved
@chr-hertel resolved the event setter discussion and the readme one, also added a bit about locale matching in phrase (which indeed is intended behaviour from phrase's side, also see their updated documentation on that) still like to have your thoughts about the concurrency bit... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and works with Symfony Demo. Haven't tested the event system, but looks good as well!
not sure whether i agree for the read & write config as the read config contains logic regarding for phrase fallback locales as well removing the class would result in array operations in the provider. for consistency i'd keep the write config around. for the cached response an array might suffice |
671c85b
to
f2e28b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wickedOne I'd love to be able to merge this one in 6.3. We're closing 6.3 for new features in about a week from now, will you be able to finish the work here (at least, make sure that all comments are taken into account)?
@fabpot that would be great and yes i'm able to allocate some time to it this week. this probably would exclude #49520 which i willingly put on the backburner until this one got resolved so have to look into it and a week might be a little short for that however, i think some discussions are still unresolved (and the reason there has been little to no activity):
github comments might not be the most efficient way to get these resolved in a week so feel free propose an alternative; i'm open to it |
6e9b892
to
10e902c
Compare
replaced |
src/Symfony/Component/Translation/Bridge/Phrase/PhraseProvider.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Translation/Bridge/Phrase/PhraseProvider.php
Outdated
Show resolved
Hide resolved
/** | ||
* @author wicliff <[email protected]> | ||
*/ | ||
class ReadConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this class (and the other one for write) is only used in PhraseProvider
, I'm not convinced there is any advantage to have it standalone. Could you consider integrate it in PhraseProvider
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my main motivation was not to clutter the provider itself with configuration logic, bit similar to configuring the http client. also probably a bit easier for those who want to alter the config behaviour?
nevertheless, i could move all that logic to the provider class, but that would be quite a bit of a refactor for which i'm not sure i'll have time before the week's end. perhaps on friday which might not be in time...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to make the Provider fully extensible. The main goal is to allow users to push and pull translations from Phrase, with the same common internal API as other Translation Providers (Loco, Lokalise and Crowdin).
If there is something to be configured by the user for the Provider, it should pass via the DSN.
If I understand correctly the code, WriteConfig is just an array in which you adapt values like the domain or the locale. I think we must simplify it with something like a private property with default config (one for read and one for write if needed) to be tweaked right before each Phrase API call with the right values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, it's open source so thre's no "need" for anything to be extensible, but i know from experience you'll make a bunch of devs happy when they are 😄
correct, the config classes are not too complex and only the read config contains a bit of logic for the provider (the fallback_locale_enabled
one), it's the unsetting of values to basically enforce some values which might not fit into someone's workflow
anyway, i'll have some time today to try and move the logic to the provider so will give it a go. think most time will be spent on re-writing the tests tbh
thanks for the review @welcoMattic! |
@wickedOne We would love to merge this feature for 6.3. The last point to fix is the removal of |
yes sorry, had some other priorities and wasn't able to get back to this. should be able to give this a go over the weekend and if it turns out to be too much work in regards to time at least to state so |
@welcoMattic Can we merge it as is? Or do you think that your last change suggestion is a blocker? |
@fabpot It is not a blocker, as it works, but it not follows the same way to do as all other providers. |
e7fb801
to
b8f35ba
Compare
Thank you @wickedOne. |
@welcoMattic If you can take care of the refactoring, I would be happy to merge a PR on this :) |
I'm on holidays until next monday, I can do it during the next week |
No worries, we have time ;) |
This PR was submitted for the 6.3 branch but it was squashed and merged into the 6.4 branch instead. Discussion ---------- [Translation] phrase translation provider documentation related to [49231](symfony/symfony#49231) as you can see in the [readme](https://github.com/wickedOne/phrase-translation-provider/blob/master/README.md) there's potentially some more documentation to add. what would be the best way to proceed as adding all that to the `translation.rst` might be a bit much? i see several options: - add everything but the config tables to the current `tranlation.rst` - leave it as is (think i touched on the most important parts) and refer to the readme of the provider - create a seperate documentation page for translation providers - leave it to the discovery of the developer as i think is done with the lokalise provider (given that one also creates locales on the fly) - ?? Commits ------- ea9b2a0 [Translation] phrase translation provider
…g into arrays (welcoMattic) This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [Translation] [Phrase] Refacto ReadConfig and WriteConfig into arrays | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #49231 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> This PR follows up #49231 which brings a new Translation Provider for [Phrase](https://phrase.com/). But there was a complexity layer about read and write configuration (means API calls options) in the original code. I've moved `ReadConfig` and `WriteConfig` from their own class into `PhraseProvider` properties. Which is easier to manipulate, to initialize and to test. Commits ------- 54b38e7 [Translation] [Phrase] Refacto ReadConfig and WriteConfig into arrays