-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTinydbFunctions.php
More file actions
35 lines (32 loc) · 1.03 KB
/
TinydbFunctions.php
File metadata and controls
35 lines (32 loc) · 1.03 KB
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
<?php
/**
* Tinydb用関数
*/
/**
* __tinydbd __dの代わりに使う. 具象プラグインに同じメッセージの翻訳が定義されてたらそちらを使う。
* なければ、Tinydbのメッセージを使う
*
* @param string $domain domain
* @param string $msg message
* @param mixed|null $args その他引数
* @return string
*/
function __tinydbd($domain, $msg, $args = null) {
if ($domain !== 'tinydb') {
return __d($domain, $msg, $args);
}
$dbTypeInstance = \NetCommons\Tinydb\Lib\CurrentDbType::instance();
if ($dbTypeInstance === null) {
return __d($domain, $msg, $args);
}
$dbType = $dbTypeInstance->getDbType();
$domain = Inflector::underscore($dbType);
App::uses('I18n', 'I18n');
// dbtypeの言語で翻訳
$translated = I18n::translate($msg, null, $domain);
// 翻訳されてなければtinydbで翻訳される
$translated = I18n::translate($translated, null, 'tinydb');
// 引数差し込む
$arguments = func_get_args();
return I18n::insertArgs($translated, array_slice($arguments, 2));
}