Page MenuHomePhabricator

Provide a "getHumanReadable" method on the ZObject class in WikiLambda
Closed, ResolvedPublic

Description

Mostly we need this so that we can return human-readable ZErrors, translate a Z5 into its labelled version.

Done:

  • Implementation of ZObject::getHumanReadable() method
  • Use of ZError::getHumanReadable() to return the information if API fails (https://phabricator.wikimedia.org/T292534)
  • Tests for ZObject::getHumanReadable()

Details

Event Timeline

Jdforrester-WMF renamed this task from Labelize ZObject in WikiLambda to Provide a "labelize" method on the ZObject class in WikiLambda.Nov 3 2021, 4:38 PM

Sharing some fun stuff from current WIP:

Exporting the test type to English returns:

{
    "type": "Persistent object",
    "id": "Z0",
    "value": {
        "type": "Type",
        "identity": "Z111",
        "keys": [
            {
                "type": "Key",
                "value type": "String",
                "key id": "Z111K1",
                "label": {
                    "type": "Multilingual text",
                    "texts": [
                        {
                            "type": "Monolingual text",
                            "language": "English",
                            "text": "Demonstration key"
                        },
                        {
                            "type": "Monolingual text",
                            "language": "French",
                            "text": "Index pour d\u00e9monstration"
                        }
                    ]
                }
            },
            {
                "type": "Key",
                "value type": "String",
                "key id": "Z111K2",
                "label": {
                    "type": "Multilingual text",
                    "texts": [
                        {
                            "type": "Monolingual text",
                            "language": "English",
                            "text": "Other demonstration key"
                        },
                        {
                            "type": "Monolingual text",
                            "language": "French",
                            "text": "Autre index pour d\u00e9monstration"
                        }
                    ]
                }
            }
        ],
        "validator": "Z111"
    },
    "labels": {
        "type": "Multilingual text",
        "texts": [
            {
                "type": "Monolingual text",
                "language": "English",
                "text": "Demonstration type"
            },
            {
                "type": "Monolingual text",
                "language": "French",
                "text": "Type pour d\u00e9monstration"
            }
        ]
    },
    "aliases": {
        "type": "Multilingual stringset",
        "stringset": [
            {
                "type": "Monolingual stringset",
                "language": "English",
                "stringset": [
                    "Demonstration type alias",
                    "Demonstration type second alias"
                ]
            },
            {
                "type": "Monolingual stringset",
                "language": "French",
                "stringset": [
                    "Alias de type pour d\u00e9monstration"
                ]
            }
        ]
    }
}

Trying this for Spanish:

{
    "type": "No label defined in this language or accepted fallbacks",
    "id": "Z0",
    "value": {
        "type": "No label defined in this language or accepted fallbacks",
        "identity": "Z111",
        "keys": [
            {
                "type": "No label defined in this language or accepted fallbacks",
                "value type": "No label defined in this language or accepted fallbacks",
                "key id": "Z111K1",
                "label": {
                    "type": "No label defined in this language or accepted fallbacks",
                    "texts": [
                        {
                            "type": "No label defined in this language or accepted fallbacks",
                            "language": "No label defined in this language or accepted fallbacks",
                            "text": "Demonstration key"
                        },
                        {
                            "type": "No label defined in this language or accepted fallbacks",
                            "language": "No label defined in this language or accepted fallbacks",
                            "text": "Index pour d\u00e9monstration"
                        }
                    ]
                }
            },
            {
                "type": "No label defined in this language or accepted fallbacks",
                "value type": "No label defined in this language or accepted fallbacks",
                "key id": "Z111K2",
                "label": {
                    "type": "No label defined in this language or accepted fallbacks",
                    "texts": [
                        {
                            "type": "No label defined in this language or accepted fallbacks",
                            "language": "No label defined in this language or accepted fallbacks",
                            "text": "Other demonstration key"
                        },
                        {
                            "type": "No label defined in this language or accepted fallbacks",
                            "language": "No label defined in this language or accepted fallbacks",
                            "text": "Autre index pour d\u00e9monstration"
                        }
                    ]
                }
            }
        ],
        "validator": "Z111"
    },
    "labels": {
        "type": "No label defined in this language or accepted fallbacks",
        "texts": [
            {
                "type": "No label defined in this language or accepted fallbacks",
                "language": "No label defined in this language or accepted fallbacks",
                "text": "Demonstration type"
            },
            {
                "type": "No label defined in this language or accepted fallbacks",
                "language": "No label defined in this language or accepted fallbacks",
                "text": "Type pour d\u00e9monstration"
            }
        ]
    },
    "aliases": {
        "type": "No label defined in this language or accepted fallbacks",
        "stringset": [
            {
                "type": "No label defined in this language or accepted fallbacks",
                "language": "No label defined in this language or accepted fallbacks",
                "stringset": [
                    "Demonstration type alias",
                    "Demonstration type second alias"
                ]
            },
            {
                "type": "No label defined in this language or accepted fallbacks",
                "language": "No label defined in this language or accepted fallbacks",
                "stringset": [
                    "Alias de type pour d\u00e9monstration"
                ]
            }
        ]
    }
}

Probably not the best multilingual readability yet :D

Change 738450 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] [WIP] Add labelize method to ZObject

https://gerrit.wikimedia.org/r/738450

Jdforrester-WMF renamed this task from Provide a "labelize" method on the ZObject class in WikiLambda to Provide a "getHumanReadable" method on the ZObject class in WikiLambda.Nov 24 2021, 10:24 AM
Jdforrester-WMF updated the task description. (Show Details)

Change 738450 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Add getHumanReadable method to ZObject

https://gerrit.wikimedia.org/r/738450