Ejemplo n.º 1
0
	static function getTranslation($messageKey)
	{
		if ($translation=self::translationFromCache($messageKey))
			return $translation;

		$lang=LPC_Language::getCurrent();
		$entry=new LPC_I18n_message();
		$entries=$entry->search(
			array('message_key','language'),
			array($messageKey,$lang->id)
		);

		if (!$entries)
			$entries=$entry->search(
				array('message_key','language'),
				array($messageKey,LPC_language::getDefault()->id)
			);

		if ($entries) {
			$translation=$entries[0]->getAttr('translation');
			self::translationToCache($messageKey,$translation);
			return $translation;
		}

		self::checkReference($messageKey);

		return "[[".$messageKey."]]";
	}
Ejemplo n.º 2
0
	foreach($msgData['translations'] as $trnData) {
		$msg=new LPC_I18n_message();
		$msgs=$msg->search(
			array(
				'language',
				'message_key',
			),
			array(
				$langMapping[$trnData['language']],
				$ref->id
			)
		);
		if ($msgs) {
			$msg=$msgs[0];
			$msg->load();
		} else {
			$msg=new LPC_I18n_message();
			$msg->setAttrs(array(
				'language'=>$langMapping[$trnData['language']],
				'message_key'=>$ref->id,
			));
		}
		$msg->setAttr('translation',$trnData['translation']);
		$msg->save();
	}
}

echo "Clean exit, all messages from $filename imported into the local database.\n";
if (defined('LPC_CACHE_TYPE') && in_array(LPC_CACHE_TYPE,array('session','apc')))
	echo "WARNING! You're using ".LPC_CACHE_TYPE." caching, which means that messages updated by this import (if any) might still be cached in the old form!\n";
Ejemplo n.º 3
0
";
$rs=$msg->query($sql);
if (!$rs->EOF && $rs->fields[0]!=$msgKey)
	$links[]="[<a href='?m=".rawurlencode($rs->fields[0])."'>Find an untranslated message</a>]";
$p->a("<p class='container'>".implode(" &bull; ",$links)."</p>");
// Done links

$ref_trans=new LPC_I18n_message();
$ref_trans=$ref_trans->search(
	array('language','message_key'),
	array($_SESSION['LPC_reference_lang'],$msgKey)
);
if ($ref_trans)
	$ref_trans=$ref_trans[0];
else
	$ref_trans=new LPC_I18n_message();

$form=new LPC_HTML_form();
$form->a("<input type='hidden' name='m' value=\"".$msg->getAttrF('message_key')."\">");
$p->a($form);
$t=new LPC_HTML_table();
$t->addClass('two-column-60');
$form->a($t);

$t->a(new LPC_HTML_form_row(array(
	'label'=>'Message key',
	'input'=>$msg->getAttrH('message_key'),
)));
$t->a(new LPC_HTML_form_row(array(
	'label'=>'Message in reference language ('.$reference_lang->getAttrH('name').')',
	'input'=>"<div style='max-height: 300px; overflow: auto'><tt>".nl2br($ref_trans->getAttrH('translation'))."</tt></div>",