Supported languages of a service and available languages pairs are subject to change.
No code should contain these lists but the current state should be exposed by services.

A feature request is pending.

Related: #1961130: Supported language codes

Comments

oyagev’s picture

I agree.
We will defining two calls as follow:

  1. Get supported languages - returns list of languages with language name and code.
  2. Get supported language pairs - return list of pairs with names and codes. Note: this list can be very long (1000> items).
    Optional parameter - "expertise" - will return pairs that support the selected expertise.

This is on the roadmap for the beginning of May.

berdir’s picture

Great!

In most cases, when we request the language pair, we're interested in the language pairs for a specific source language, as we know which language we are translating from and want to check if the target language selected by the user is supported, so a source language filter would be important. That would also get the number of results down a lot.

For most translator plugins, we cache that information by source language, so that we don't have to request it again if the target language is changed in the UI, so a target language filter isn't that important for us but might make sense too for other use cases.

miro_dietiker’s picture

Also, don't be redundant.
I would only list codes in the pair. A client needs to know your language repository anyway (locally cached) and can use that as a lookup list.

With those lang codes only, say 30 chars per pair incl overhead, we'll have 30kB for 1000 pairs. That's a small payload and doesn't add significant delay.
Just be sure to cache that on the server side too. ;-)

In our case, we will early query the languages, persist/cache them, and later only query for the pair per job / pair request.
If allowed, the pairs will however also be cached for some time.

miro_dietiker’s picture

Assigned: Unassigned » oyagev
mbovan’s picture

Assigned: oyagev » mbovan
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new5.92 KB

Providing a patch. Sorry @oyagev if you worked on this. :P

Applied the patch from #1999992: Update remote languages mappings logic and implemented getSupportedLanguagePairs() and getSupportedLanguages().

Made some cleanup in default mapping list as well. That was supposed to be done in #1961130: Supported language codes.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/tmgmt_oht.plugin.inc
    @@ -83,35 +76,70 @@ class TMGMTOhtPluginController extends TMGMTDefaultTranslatorPluginController {
    +      // @todo: Handle exception.
    

    same as in the other, lets just return an empty array.

  2. +++ b/tmgmt_oht.plugin.inc
    @@ -83,35 +76,70 @@ class TMGMTOhtPluginController extends TMGMTDefaultTranslatorPluginController {
    +    } finally {
    +
    +      return $language_pairs;
         }
    

    finally requires PHP 5.5, don't use that in D7.

    Just put it at the end, the code will go there anyway if you catch the exception.

  3. +++ b/tmgmt_oht.plugin.inc
    @@ -83,35 +76,70 @@ class TMGMTOhtPluginController extends TMGMTDefaultTranslatorPluginController {
    +    $language_pairs = $this->getSupportedLanguagePairs($translator);
    

    cal this method on $translator, then you benefit from the built-in caching there.

mbovan’s picture

Status: Needs work » Needs review
StatusFileSize
new5.89 KB
new1.04 KB

Fixed.

mbovan’s picture

Updated the list of default languages and sorted them alphabetically. There were some languages (language codes) not supported by Drupal and I commented-out them.

berdir’s picture

Status: Needs review » Fixed

Thanks, committed and pushed. Not too happy about the comment style there, but lets make progress.

  • Berdir committed b7c9810 on 7.x-1.x authored by mbovan
    Issue #1963742 by mbovan: OHT feature: Add services based languages...

  • Berdir committed b7c9810 on 8.x-1.x authored by mbovan
    Issue #1963742 by mbovan: OHT feature: Add services based languages...

Status: Fixed » Closed (fixed)

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