forked from vhenriquez/Glosbe-Translate-PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.php
40 lines (27 loc) · 740 Bytes
/
cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* User: ms
* Date: 23.09.15
* Time: 20:14
*
* API Documentation
* https://glosbe.com/a-api
*/
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
$glosbe = new \Translate\GlosbeTranslate("ita", "de");
$glosbe->translate('come');
#var_dump( $glosbe->translationsOnly());
$csv = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'words.csv';
$words = array();
$lines =file_get_contents($csv);
$translations = array();
foreach(explode("\n",$lines) as $line) {
$words []= explode(';', $line)[0];
}
foreach($words as $word) {
var_dump($glosbe->translate($word));
}
/*print_r(
json_decode($glosbe->translate('ciao'))
);*/
#print $glosbe->translate('del caffè');