Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AbstractImportation.php
Go to the documentation of this file.
1<?php
3
7
8abstract class AbstractImportation {
9
10 protected $file;
11
12 public function __construct($file) {
13 $this->file = $file;
14 }
15
19 public abstract function load();
20
21 public function import($locale, $domain) {
22 $msgDomain = new MessagesDomain($locale, TranslatorManager::getLoader(), $domain);
23 $msgDomain->load();
24 $messages = $msgDomain->getMessages();
25 $messagesUpdates = new MessagesUpdates($locale, $domain);
26 $messagesUpdates->load();
27 $messages = $messagesUpdates->mergeMessages($messages);
28 $newMessages = $this->load();
29 foreach ($newMessages as $k => $msg) {
30 if (! isset($messages[$k])) {
31 $messagesUpdates->addValue($k, $msg, uniqid('key'));
32 } else {
33 $messagesUpdates->updateValue($k, $msg);
34 }
35 }
36 $messagesUpdates->save();
37 }
38}
39
Represents a list of messages in a domain for a locale.