Comments

blueminds’s picture

Priority: Normal » Major

Setting to major priority as without this tmgmt_server does not work well with tmgmt_local

blueminds’s picture

Proposed solutions:

- The translator plugin should be able to implement method getAvailableLanguagePairs()
- The default implementation of getAvailableLanguagePairs() will just collect target languages for each source language.
- This can be then used by tmgmt_server to expose language capabilities

blueminds’s picture

Assigned: Unassigned » blueminds
blueminds’s picture

Attached patch that deals with language pairs provided by a translator. This can then be used i.e. by tmgmt_server to collect language pairs from all installed translators.

This does not touch the capabilities logic around user skills in the tmgmt_local. I think this can be done in the follow up after we cleanup tmgmt_local from tmgmt_server stuff.

blueminds’s picture

Status: Active » Needs review
berdir’s picture

+++ b/plugin/tmgmt.plugin.interface.translator.incundefined
@@ -133,6 +133,8 @@ interface TMGMTTranslatorPluginControllerInterface extends TMGMTPluginBaseInterf
+  public function getSupportedLanguagePairs(TMGMTTranslator $translator);

+++ b/plugin/tmgmt.plugin.translator.incundefined
@@ -127,6 +127,13 @@ abstract class TMGMTDefaultTranslatorPluginController extends TMGMTPluginBase im
+  public function getSupportedLanguagePairs(TMGMTTranslator $translator) {
+    return array();

Looks nice, just needs some documentation and the default implementation that we discussed :)

blueminds’s picture

Added documentation

blueminds’s picture

so the third try ;)

berdir’s picture

+++ b/entity/tmgmt.entity.translator.incundefined
@@ -123,6 +130,48 @@ class TMGMTTranslator extends Entity {
+        // Even if we successfully queried the cache it might not have an entry
+        // for our source language yet.

The comment needs to be updated.

+++ b/entity/tmgmt.entity.translator.incundefined
@@ -123,6 +130,48 @@ class TMGMTTranslator extends Entity {
+    cache_clear_all('languages::' . $this->name, 'cache_tmgmt');
+    cache_clear_all('languages::pairs_' . $this->name, 'cache_tmgmt');

No idea why it is :: right now, but let's use a single : :)

+++ b/entity/tmgmt.entity.translator.incundefined
@@ -238,6 +287,7 @@ class TMGMTTranslator extends Entity {
+        cache_set('languages:pairs_' . $this->name, $this->languagePairsCache, 'cache_tmgmt');

language_pairs:$name would make more sense as the cid name I think.

+++ b/plugin/tmgmt.plugin.translator.incundefined
@@ -127,6 +127,21 @@ abstract class TMGMTDefaultTranslatorPluginController extends TMGMTPluginBase im
+    foreach ($this->getSupportedRemoteLanguages($translator) as $source_language) {
+      foreach ($this->getSupportedTargetLanguages($translator, $source_language) as $target_language) {
+        $language_pairs[] = array('source_language' => $source_language, 'target_language' => $target_language);
+      }

Maybe add a comment above this that says something like "Slow default implementation, translator implementations are encouraged to provide a more efficient implementation if possible.

Looks nice otherwise.

blueminds’s picture

comments implemented

berdir’s picture

Status: Needs review » Active

Commited.

As that's only part of what this issue is about, setting back to active for now, might also open a new issue but doesn't really matter.

blueminds’s picture

Status: Active » Needs review
StatusFileSize
new18.75 KB

Provided suggested API for translator capabilities.

To optimise capability query I dropped the capabilities hook. I did not see any practical use for it at this moment and the complexity it introduced prevent from optimising the query.

So, what do you think?

berdir’s picture

Category: feature » task
StatusFileSize
new2.88 KB
new18.67 KB

This looks a lot better already, yes. The page no longer takes forever to load when you have 10k+ users ;)

Did some documentation improvements and removed a weird change at the beginning of the patch. This should be good to go.

Status: Needs review » Needs work

The last submitted patch, tmgmt-capabilities_api-1895432-13.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new2.73 KB
new20.58 KB

Hah, so my only functional change killed it ;)

I prefer to enforce types, so I changed the calls to an array.

Status: Needs review » Needs work

The last submitted patch, tmgmt-capabilities_api-1895432-15.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new20.18 KB
new643 bytes

This should be green, replaced too much.

berdir’s picture

Status: Needs review » Fixed

Committed and pushed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.