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

Add onAfterTranslate system event #12985

Closed
wants to merge 1 commit into from

Conversation

vietvh
Copy link
Contributor

@vietvh vietvh commented Nov 23, 2016

Pull Request to add onAfterTranslate system event

Summary of Changes

Add new onAfterTranslate event, allow hooking after the key is translated.

An example use case: It'd be great if Joomla allows developers to override the default "**" (for translated key) and "??" (for untranslated key) characters when language debug is enabled.

Another use case (from @ot2sen): in context (in line) translation for Joomla

Testing Instructions

  • Text shows up normally in both language debug ON/OFF

@Bakual
Copy link
Contributor

Bakual commented Nov 23, 2016

I don't understand the usecase for this.

Text shows up normally in both language debug ON/OFF

Wouldn't that basically make the debug function useless?

@vietvh
Copy link
Contributor Author

vietvh commented Nov 23, 2016

Let's say if a user does not want to show translated key wrapped in **** characters and untranslated key wrapped in ????, he only want to show the translated key as is (no wrapper) and untranslated key in italic. It is just one minor use case, it can be extended by 3rd ext developers to do other things. At this moment Joomla does not allow hooking at that point and that's the purpose of this pull request.

@infograf768
Copy link
Member

We need these when debug as Joomla now loads en-GB strings when they are not present in the language. I also consider this PR as not really useful.

@vietvh
Copy link
Contributor Author

vietvh commented Nov 23, 2016

It does not change anything that could affect the language debug feature, it only allows developers to change the default behavior to suit their needs, and it only increases Joomla's flexibility. It not all about language debug, the use case above is just one minor example how the new event can be utilized.

WordPress has similar one for years when it allows 3rd plugins to change the translated key easily:

https://github.com/WordPress/WordPress/blob/master/wp-includes/l10n.php#L121-L134

@brianteeman
Copy link
Contributor

Yikes - seriously. You want to allow an extension to completely change
strings from anywhere including other extensions?

On 23 November 2016 at 09:15, Viet Hoang Vu notifications@github.com
wrote:

It does not change anything that could affect the language debug feature,
it only allows developers to change the default behavior to suit their
needs, and it only increases Joomla's flexibility. It not all about
language debug, the use case above is just one minor example how the new
event can be utilized.

WordPress has similar one for years when it allows 3rd plugins to change
the translated key easily:

https://github.com/WordPress/WordPress/blob/master/wp-
includes/l10n.php#L121-L134


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#12985 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPH8cMzUe5iOceADGyJ4Nz3dzhoZ695ks5rBAQcgaJpZM4K6Uk4
.

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
https://brian.teeman.net/ http://brian.teeman.net/

Copy link
Member

@jeckodevelopment jeckodevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in favour of this.

@ot2sen
Copy link
Contributor

ot2sen commented Nov 23, 2016

@vietvh would a use case be something like connecting with a 3rd party translation tools to do a kind of 'in context translation' of a joomla website?

@vietvh
Copy link
Contributor Author

vietvh commented Nov 23, 2016

Hi Brian,

WordPress has that feature for years and I've not seen any problems with it.

Do we need to restrict developers to extend Joomla just because we are afraid something bad happened?

With the existing event onAfterRender, every plugins can replace the whole website output easily, or with the template override system, a template can totally replace a component's view easily, are those bad features?

Hope you get my point.

@vietvh
Copy link
Contributor Author

vietvh commented Nov 23, 2016

@ot2sen Yes, why not, it is a great idea for this feature's use case.

@brianteeman
Copy link
Contributor

Joomla !=wordpress

On 23 November 2016 at 09:40, Viet Hoang Vu notifications@github.com
wrote:

@ot2sen https://github.com/ot2sen Yes, why not, it is a great idea for
this feature's use case.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#12985 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPH8X5-J_l8sg_eT3kYYAdn4sWrxvZZks5rBAofgaJpZM4K6Uk4
.

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
https://brian.teeman.net/ http://brian.teeman.net/

@vietvh
Copy link
Contributor Author

vietvh commented Nov 23, 2016

@brianteeman

Not sure what you meant specifically.

But as a die hard Joomla's fan and a professional Joomla developer for 10 years, with nearly 2 years working with WordPress recently in parallel, I'd say to some extent:

Joomla's flexibility != WordPress's flexibility

@Bakual
Copy link
Contributor

Bakual commented Nov 23, 2016

would a use case be something like connecting with a 3rd party translation tools to do a kind of 'in context translation' of a joomla website?

@ot2sen That's already possible as it is. Just install https://github.com/Bakual/crowdinachug/releases follow the instruction and start translating 😄

@vietvh
Copy link
Contributor Author

vietvh commented Nov 23, 2016

The video from Roberto Segura is also a great potential use case of this pull request:

https://www.youtube.com/watch?v=YXsdSiNLV2s

@mbabker
Copy link
Contributor

mbabker commented Nov 23, 2016

👎

A translation system should NOT have a hook where a plugin can alter the translated string.

Your use case is you want to change the debug markers. Move them to class level properties that can be altered instead of hardcoded into the method directly and that gives you the flexibility you want.

I honestly could care less what WordPress is doing. Just because they do something does not make it right by any measure. This is something that is not right at all, if a plugin can change the result of a translation then it effectively cripples the translation system and makes user expectations and experience much more complex.

Now speaking purely on a technical perspective. How is this going to cripple performance since you are dispatching an event every time a string is translated (and that can easily be 500 strings on a page)?

@Bakual
Copy link
Contributor

Bakual commented Nov 23, 2016

Closing as there is no support for it.

@Bakual Bakual closed this Nov 23, 2016
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

8 participants