einenlum/linguee-api

安装: 20

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

语言:HTML

v0.1.1 2022-01-13 09:46 UTC

This package is auto-updated.

Last update: 2024-09-13 15:40:42 UTC


README

CircleCI Latest Stable Version Latest Unstable Version

询问linguee任何事情。该项目深受此 JS项目 启发。Linguee没有API。这是一个PHP库,用于向Linguee发送HTTP请求并获取响应(它填充了一个 Einenlum\LingueeApi\Response\DTO\Response 对象,并可序列化为JSON)。

安装

composer require einenlum/linguee-api

使用

<?php
use Einenlum\LingueeApi\Factory;

$linguee = Factory::create();

// Example: https://www.linguee.com/english-german/search?query=desert
$response = $linguee->translate('desert', 'eng', 'ger');

// $response is an instance of Einenlum\LingueeApi\Response\DTO\Response
echo $response->toJson();

/*
Prints:

{
  "query": "desert",
  "words": [
    {
      "term": "desert",
      "additionalInformation": null,
      "type": "noun",
      "audio":
        "https://www.linguee.com/mp3/EN_US/3f/3fd6b6210e33bb046e69f256a138e28d-101",
      "translations": [
        {
          "term": "W\u00fcste",
          "audio":
            "https://www.linguee.com/mp3/DE/c4/c4e37c83329756bbd9c02791bd76199d-104",
          "type": "f",
          "alternatives": [],
          "examples": [
            {
              "from": "In the desert, water is a scarce resource.",
              "to": "In der W\u00fcste ist Wasser eine knappe Ressource."
            },
            {
              "from": "The desert is arid with sparse vegetation.",
              "to": "Die W\u00fcste ist trocken mit karger Vegetation."
            }
          ]
        }
      ]
    },
    {
      "term": "desert",
      "additionalInformation": null,
      "type": "adjective",
      "audio":
        "https://www.linguee.com/mp3/EN_US/3f/3fd6b6210e33bb046e69f256a138e28d-300",
      "translations": [
        {
          "term": "w\u00fcst",
          "audio":
            "https://www.linguee.com/mp3/DE/1c/1cb563d1405f4092dd6abc05456ca5b9-300",
          "type": "adj",
          "alternatives": [],
          "examples": []
        }
      ]
    },
    {
      "term": "desert",
      "additionalInformation": null,
      "type": "verb",
      "audio":
        "https://www.linguee.com/mp3/EN_US/3f/3fd6b6210e33bb046e69f256a138e28d-200",
      "translations": [
        {
          "term": "desertieren",
          "audio":
            "https://www.linguee.com/mp3/DE/c3/c39c3bdec7b4b5bd85fcb745a2798347-202",
          "type": "v",
          "alternatives": [],
          "examples": [
            {
              "from": "The soldiers deserted as defeat became inevitable.",
              "to":
                "Die Soldaten desertierten, als eine Niederlage unausweichlich wurde."
            }
          ]
        }
      ]
    }
  ],
  "examples": [
    {
      "from": {"content": "Mojave Desert", "type": "n", "audio": null},
      "tos": [{"content": "Mojave-W\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "desert dunes", "type": "pl", "audio": null},
      "tos": [{"content": "W\u00fcstend\u00fcnen", "type": "pl"}]
    },
    {
      "from": {"content": "desert conditions", "type": "pl", "audio": null},
      "tos": [{"content": "W\u00fcstenbedingungen", "type": "pl"}]
    },
    {
      "from": {"content": "coastal desert", "type": "n", "audio": null},
      "tos": [{"content": "K\u00fcstenw\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "desert terrain", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenterrain", "type": "nt"}]
    },
    {
      "from": {"content": "desert heat", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenhitze", "type": "f"}]
    },
    {
      "from": {"content": "desert country", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenstaat", "type": "m"}]
    },
    {
      "from": {"content": "Arabian desert", "type": "n", "audio": null},
      "tos": [{"content": "arabische W\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "desert areas", "type": "pl", "audio": null},
      "tos": [{"content": "W\u00fcstengebiete", "type": "pl"}]
    },
    {
      "from": {"content": "desert lynx", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenluchs", "type": "m"}]
    },
    {
      "from": {"content": "desert coast", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenk\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "red desert", "type": "n", "audio": null},
      "tos": [{"content": "rote W\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "strip of desert", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenstreifen", "type": "m"}]
    },
    {
      "from": {"content": "desert ground", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenboden", "type": "m"}]
    },
    {
      "from": {
        "content": "desert to the enemy",
        "type": "v",
        "audio":
          "https://www.linguee.com/mp3/EN_UK/a2/a2f1c88946632af7e4715e87f492d66f-200"
      },
      "tos": [{"content": "zum Feind \u00fcberlaufen", "type": "v"}]
    },
    {
      "from": {"content": "desert from the army", "type": "v", "audio": null},
      "tos": [{"content": "von der Armee desertieren", "type": "v"}]
    },
    {
      "from": {"content": "desert surface", "type": "n", "audio": null},
      "tos": [
        {"content": "W\u00fcstenboden", "type": "m"},
        {"content": "W\u00fcstenfl\u00e4che", "type": "f"}
      ]
    },
    {
      "from": {"content": "desert plant", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenpflanze", "type": "f"}]
    },
    {
      "from": {"content": "desert foxes", "type": "pl", "audio": null},
      "tos": [{"content": "W\u00fcstenf\u00fcchse", "type": "pl"}]
    },
    {
      "from": {"content": "desert animals", "type": "pl", "audio": null},
      "tos": [{"content": "W\u00fcstentiere", "type": "pl"}]
    },
    {
      "from": {"content": "desert sun", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstensonne", "type": "f"}]
    },
    {
      "from": {"content": "desert race", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenrennen", "type": "nt"}]
    },
    {
      "from": {"content": "flowering desert", "type": "n", "audio": null},
      "tos": [{"content": "bl\u00fchende W\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "desert wind", "type": "n", "audio": null},
      "tos": [{"content": "W\u00fcstenwind", "type": "m"}]
    },
    {
      "from": {"content": "blooming desert", "type": "n", "audio": null},
      "tos": [{"content": "bl\u00fchende W\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "desert adventures", "type": "pl", "audio": null},
      "tos": [{"content": "W\u00fcstenausfl\u00fcge", "type": "pl"}]
    },
    {
      "from": {"content": "desert formations", "type": "pl", "audio": null},
      "tos": [{"content": "W\u00fcstenbildungen", "type": "pl"}]
    },
    {
      "from": {"content": "huge desert", "type": "n", "audio": null},
      "tos": [{"content": "gro\u00dfe W\u00fcste", "type": "f"}]
    },
    {
      "from": {"content": "emotional desert", "type": "n", "audio": null},
      "tos": [{"content": "emotionale W\u00fcste", "type": "f"}]
    }
  ]
}
*/

配置

可用语言

  • 'eng' : 英语
  • 'ger' : 德语
  • 'fra' : 法语
  • 'spa' : 西班牙语
  • 'chi' : 中文
  • 'rus' : 俄语
  • 'jpn' : 日语
  • 'por' : 葡萄牙语
  • 'ita' : 意大利语
  • 'dut' : 荷兰语
  • 'pol' : 波兰语
  • 'swe' : 瑞典语
  • 'dan' : 丹麦语
  • 'fin' : 芬兰语
  • 'gre' : 希腊语
  • 'cze' : 捷克语
  • 'rum' : 罗马尼亚语
  • 'hun' : 匈牙利语
  • 'slo' : 斯洛伐克语
  • 'bul' : 保加利亚语
  • 'slv' : 斯洛文尼亚语
  • 'lit' : 立陶宛语
  • 'lav' : 拉脱维亚语
  • 'est' : 爱沙尼亚语
  • 'mlt' : 马耳他语

测试

感谢PHPStan、PHPSpec和PHPUnit进行测试。要启动测试

composer test

编码规范

编码规范通过PHP-CS-Fixer进行检查和修复。要修复您的代码,只需运行composer cs-fix。

贡献

请自由贡献并改进此项目。

许可证

MIT

请尊重Linguee的 条款和条件