Jump to content

Let us manipulate translate table before it's sent to output


TSP

Recommended Posts

Hello, 

In applications/core/modules/admin/languages/languages.php

Method translate()

Could you possibly split this method up so the $table-initializations happens in its own method and returned from that method? So the table settings can be easier manipulated by a hook. 

Ideally I think I would also like translateWord() to be refactored, but given you don't officially support adding columns on existing database tables, I guess I'll have to manage without. 

Link to comment
Share on other sites

2 minutes ago, Daniel F said:

Couldn’t you create a hook for the Table\Db class with a condition for the database table name and module or url Param to run the custom code only for this specific case? 

I guess... But then it would only make sense to hook into the toString-method, since I can't know when the table initialization has been "done" otherwise. 

Just seems a bit over the top to override the toString-method (even though I obviously would limit the cases it would run), but if you feel that's the best approach, then I can do that. 

Link to comment
Share on other sites

15 minutes ago, Daniel F said:

Could you explain what you’re trying to achieve? I’m usually hooking into the constructor or getRows method to customize the table data. 

I'm adding a field to show the last time a language string was changed and by whom (as well as having both of these sortable). Also removing the Plugin and Theme-columns. I've also added a search field to limit translations to those done by a specific member id. 

604668118_Skjermbilde2019-08-01kl_11_17_24.thumb.png.50f7110f878a501279098340421090ce.png

Currently I've just copied the entire translateWord and translate-methods and then added my changes to them. And then I also manually added two columns to the core_sys_lang_words-table to track the time changed and by whom. 

Currently just for my use... However, in order to not get in trouble with later upgrades, possibly distributing on MP etc. I'm considering doing it in a more proper way at a later point. 😃

I guess the $table will be the least of my worries, as I'll also need to left join (if that's even possible with the Db Form Table?) with another table so I can get that information (and still be able to sort) from another table instead.  

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...