-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.php
63 lines (44 loc) · 1.37 KB
/
test.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
include 'vendor/autoload.php';
require_once('core/pos_info.php');
use Gettext\Translations;
use satellitewp\po;
$pi = new \satellitewp\po\Pos_Info( 'fr-ca', 'fr' );
$pi->set_url( 'https://wordpress.org/plugins/wordpress-seo/' );
$vars = $pi->get_internal();
#var_dump( $vars );
/*
echo 'name: ' . $pi->get_project_name();
echo "\n";
echo 'type: ' . $pi->get_project_type();
echo "\n";
echo "\n";*/
echo $pi->get_base_download_url();
echo "\n";
echo $pi->get_copy_download_url();
exit;
$param = $argv[1];
$base = Translations::fromPoFile('tests/locale/fr-ca/'. $param .'-fr-ca.po');
$copy = Translations::fromPoFile('tests/locale/fr/'. $param .'-fr.po');
//var_dump( count( $base ) ); exit;
foreach( $base as $tr) {
if ( ! $tr->hasTranslation() ) {
$copy_tr = $copy->find( $tr->getContext(), $tr->getOriginal() );
if ($copy_tr !== false) {
$tr->setTranslation( $copy_tr->getTranslation() );
if ($tr->hasPluralTranslations()) {
$tr->setPluralTranslations( $copy_tr->getPluralTranslations() );
}
}
//$tr->addFlag('Maxime');
}
}
$base->toPoFile('result.po');
$res = Translations::fromPoFile('result.po');
$exp = Translations::fromPoFile('tests/locale/expected/'. $param .'-expected-fr-ca.po');
if ($res->toPoString() != $exp->toPoString()) {
echo "different";
}
else {
echo "ok";
}