You can simply use the functions bindtextdomainand textdomainagain to set the new translation file as the default resource.
A good way to simplify would be to create a let say utility function selectTrFile($filename)that makes it look like this:
function selectTrFile($trFile) {
bindtextdomain($trFile, TRANSLATION_BASE_DIR);
textdomain($trFile);
}
selectTrFile('default');
selectTrFile('anotherTranslationsResource');
, , .
function _f($msgid, $trFile){
selectTrFile($trFile);
return _($msgid);
}
$f1 = 'lang';
$f2 = 'brand';
_f("to be translated in file 'lang'", $f1);
_f("to be translated in file 'brand'", $f2);
, , _f($msgid, $trFile);
function _f($msgid){
selectTrFile('lang');
$msgstr = _($msgid);
if($msgstr == $msgid){
selectTrFile('brand');
$msgstr = _$(msgid);
}
return $msgstr;
}
, , , . , 'lang', , , - .
, . . .mo, .
msgfmt , . .po/.mo. Mo - .
, , .po. , .
: . ( , ), .
, .
msgid "first String in file.php"
msgstr "first translation in file.php
.
.
.
msgid "other translation"
msgstr "and then you go on"
, , .mo .php, .
. ( PO).