Comment 2 for bug 1504915

Revision history for this message
James Tait (jamestait) wrote :

The problem for the store here (using the Camera example) is that no translations have been added to the metadata. The phone will send an `Accept-Language` header with the request to indicate the language in use on the device, and we will search using the terms entered by the user against that language and the default, untranslated metadata, scoring packages that match the translated fields more highly.

As an example:

```
$ curl -s 'https://search.apps.ubuntu.com/api/v1/search?q=otp%20transit&fields=title,description,keywords,translations' | jq .
{
  "_embedded": {
    "clickindex:package": [
      {
        "description": "Calculate your public transport itineraries in Île de France using Mobile OTP Transit Planner for Paris!\nCalculate your trips in public transport using Mobile OTP Transit Planner for Paris, the mobile webapp version of http://plannerparis.acolytesanonymes.org.\r\n\r\nThis webapp currently supports the following transportation networks: RATP, RER, Transilien, TER and Intercités. OPTILE network should follow soon.\r\n\r\nThis app is based on https://github.com/HSLdevcom/navigator-proto, and makes use of OpenTripPlanner (https://github.com/OpenTripPlanner/OpenTripPlanner) for routing.",
        "title": "Mobile OTP Transit Planner for Paris",
        "translations": {
          "fr": {
            "keywords": [
              "déplacements",
              "transports en commun",
              "transilien",
              "metro",
              "RER",
              "Paris",
              "tramway",
              "OPTILE",
              "SNCF",
              "RATP",
              "TER",
              "Intercités"
            ],
            "website": "http://plannerparis.acolytesanonymes.org",
            "support_url": "mailto:<email address hidden>",
            "description": "Déplacez-vous en transports en commun facilement sur l'Île de France grâce à MOTPP, la version mobile de http://plannerparis.acolytesanonymes.org.\r\n\r\nCette webapp réalise actuellement ses calculs d'itinéraires en région parisienne en prenant en compte les réseaux suivants : RATP (bus, tramways, métros), RER, Transilien, TER et Intercités. Le support OPTILE est prévu pour mi-octobre.",
            "title": "Planificateur de trajets en transports en commun pour Paris"
          }
        },
        "_links": {
          "self": {
            "href": "https://search.apps.ubuntu.com/api/v1/package/mobileotptransitplan.kalon33"
          }
        },
        "keywords": [
          "transit",
          "public transport",
          "transilien",
          "metro",
          "RER",
          "Paris",
          "tramway",
          "OPTILE",
          "SNCF",
          "RATP",
          "TER",
          "Intercités"
        ]
      },
...
$ curl -s 'https://search.apps.ubuntu.com/api/v1/search?q=planificateur' | jq .
{
  "_links": {
    "curies": [
      {
        "href": "https://wiki.ubuntu.com/AppStore/Interfaces/ClickPackageIndex#reltype_{rel}",
        "name": "clickindex",
        "templated": true
      }
    ],
    "self": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=planificateur&page=1"
    },
    "last": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=planificateur&page=1"
    },
    "first": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=planificateur&page=1"
    }
  }
}
$ curl -s 'https://search.apps.ubuntu.com/api/v1/search?q=planificateur' -H 'Accept-Language: fr' | jq .
{
  "_embedded": {
    "clickindex:package": [
      {
        "publisher": "Nicolas DERIVE",
        "ratings_average": 5,
        "name": "mobileotptransitplan.kalon33",
        "title": "Planificateur de trajets en transports en commun pour Paris",
        "icon_url": "https://myapps.developer.ubuntu.com/site_media/appmedia/2015/10/gnome-maps.png",
        "price": 0,
        "sequence": 3,
        "content": "application",
        "alias": null,
        "version": "0.3",
        "_links": {
          "self": {
            "href": "https://search.apps.ubuntu.com/api/v1/package/mobileotptransitplan.kalon33"
          }
        },
        "architecture": [
          "all"
        ],
        "prices": {},
        "revision": 3
      }
    ]
  },
  "_links": {
    "curies": [
      {
        "href": "https://wiki.ubuntu.com/AppStore/Interfaces/ClickPackageIndex#reltype_{rel}",
        "name": "clickindex",
        "templated": true
      }
    ],
    "self": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=planificateur&page=1"
    },
    "last": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=planificateur&page=1"
    },
    "first": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=planificateur&page=1"
    }
  }
}
```

The solution that will work today is for the uploader to add the translations. A possible future improvement would be to try to extract the translations from, say, a `.desktop` file in the package, but that's problematic for various reasons:

 * What about packages that only ship scopes (no `.desktop` file)?
 * What about packages that ship several apps (several `.desktop` files)?
 * What about snap packages that are targeting IoT/Ubuntu Core (zero or more `.desktop` files, but not referenced in the manifest)?