public static function getDefault() { if (!defined('LPC_default_language')) throw new RuntimeException("You have to define constant LPC_default_language if you want to rely on LPC defaults."); if (isset(self::$defaultInstance)) return self::$defaultInstance; $lang=self::newLanguage(LPC_default_language); if (!$lang->probe()) throw new RuntimeException("No entry found in the languages table for the default language code (constant LPC_default_language=\"".LPC_default_language."\")"); self::$defaultInstance=$lang; return self::$defaultInstance; }
function getDefault($className,$attName,$languageID=0) { if (!$languageID) $languageID=LPC_Language::getCurrent()->id; if (!isset(self::$currentInstance)) self::$currentInstance=new LPC_Scaffolding_default(); $sd=&self::$currentInstance; $ds=$sd->search( array('className','attName','language'), array($className,$attName,$languageID) ); if (!$ds) return ""; return $ds[0]->getAttr('defaultValue'); }
public function render($indent=0) { $lang = LPC_Language::getCurrent(); $POSIX = $lang->getAttr("locale_POSIX"); if (strlen($POSIX) > 1) // at least 2 $this->setAttr("lang", substr($POSIX, 0, 2)); $this->prepareContent($this->content); if ($this->doctype & LPC_HTML_doctype::type_XHTML1) $this->setAttr("xmlns","http://www.w3.org/1999/xhtml"); if (!$this->body->content || self::RM_NONE == $this->renderMode) return ''; if (!$this->beforeRender($indent)) return ''; if (self::RM_RAW == $this->renderMode) return $this->body->renderContent($indent); if (self::RM_HTML != $this->renderMode) throw new RuntimeException("Unknown render mode: [".$this->renderMode."]"); $title=""; if ($this->title) { $titleObj=new LPC_HTML_fragment(); $titleObj->content=$this->title; $titleObj->compact=true; $title=$titleObj->render(); } if (strlen(trim($title))) $this->content['head']->content['title']->content=sprintf($this->title_format,$title); else $this->content['head']->content['title']->content=$this->title_default; $content=$this->output(LPC_HTML_doctype::$doctypes[$this->doctype],$indent); // <!DOCTYPE...> $content.=parent::render($indent); $this->onRender($indent); return $content; }
function prepare() { $this->setClass('LPC_translated_message_list'); foreach(LPC_I18n_messageFormatter::$object_cache as $langID=>$msgs) { $this->a("<h1>Messages used in this page</h1>"); $lang=LPC_Language::newLanguage($langID); $this->a("<h2>".$lang->getNameH()."</h2>"); $msgList=new LPC_HTML_node(); $this->a($msgList); foreach($msgs as $key=>$obj) { $a=new LPC_HTML_node('a'); $a->a(htmlspecialchars($key)); $a->setAttr('href',LPC_url."/translate/message_translate.php?l=$langID&m=".rawurlencode($key)); if ($trans=$obj->getPattern()) $a->setAttr('title',$trans); if ($msgList->content) $msgList->a(" • "); $msgList->a($a); } } }
static function getCacheKey($messageKey,$langID=0) { if (!$langID) $langID=LPC_Language::getCurrent()->id; return "LPC.i18n.".$langID."-".$messageKey; }
$p->title="Set language"; $p->st(); $p->a("<p>Please select a language to translate to, and a reference language. You only need to do this once per session (or if you want to translate to a different language).</p>"); $form=new LPC_HTML_form(); $p->a($form); $form->a("<input type='hidden' name='m' value=\"".addslashes($msgKey)."\">"); $t=new LPC_HTML_table(); $form->a($t); $ref_selector=new LPC_HTML_select('reference_lang','LPC_target_lang',$_SESSION); $lng=new LPC_Language(); $langs=$lng->search('translated',1,'name'); foreach($langs as $lang) $ref_selector->addOption($lang->getAttrF('name'),$lang->id); $t->a(new LPC_HTML_form_row(array( 'label'=>'Reference language', 'input'=>$ref_selector ))); $target_selector=new LPC_HTML_select('target_lang','LPC_reference_lang',$_SESSION); $langs=$lng->search(NULL,NULL,'name'); foreach($langs as $lang) $target_selector->addOption($lang->getAttrF('name'),$lang->id); $t->a(new LPC_HTML_form_row(array(
function initI18nChild($id,$langID=0) { $this->checkI18nChild(); if (!$langID) $langID=LPC_Language::getCurrent()->id; $this->setAttr($this->user_fields['i18n_parent'],$id); $this->setAttr($this->user_fields['i18n_language'],$langID); }
define("LPC_SkipAuthentication",true); require_once dirname(dirname(__FILE__))."/include/LPC_lib.php"; while(ob_get_level()) ob_end_clean(); // Languages $langMapping=array(); foreach($inData['languages'] as $langData) { $lang=new LPC_Language(); $langs=$lang->search('locale_POSIX',$langData['locale_POSIX']); if ($langs) { $lang=$langs[0]; $lang->load(); } else { $lang=new LPC_Language(); $lang->setAttr('locale_POSIX',$langData['locale_POSIX']); } $lang->setAttr('name',$langData['name']); $lang->save(); $langMapping[$langData['id']]=$lang->id; } // Messages foreach($inData['messages'] as $msgKey=>$msgData) { $ref=new LPC_I18n_reference($msgKey); if ($ref->probe()) { $ref->load(); $ref->setAttrs(array( 'comment'=>$msgData['comment'], 'system'=>$msgData['system'],
header("Location: ".LPC_URI::getCurrent()->delVar('langID')->toString()); exit; } } $langSelect=new LPC_HTML_node('div'); $langSelect->setAttr('style','float: right'); $langSelect->a(_LH('scaffoldingSelectLang')." "); $langs=new LPC_HTML_select(); $langSelect->a($langs); $langObjs=new LPC_Language(); $langObjs=$langObjs->search(NULL,NULL,'name'); foreach($langObjs as $langObj) $langs->addOption($langObj->getAttr('name'),$langObj->id); $langs->setAttr('onChange',"window.location=location.pathname+location.search+(location.search?'&':'?')+'langID='+this.options[this.selectedIndex].value;"); $langs->selected=LPC_Language::getCurrent()->id; LPC_Page::getCurrent()->a($langSelect); function exposeDirClasses($dir) { $result=array( 'name'=>array(), 'formal'=>array(), ); $d = dir($dir); while (false !== ($entry = $d->read())) { $fname=$dir."/".$entry; $class=substr($entry,0,-4); // First skip filesystem entries and known auxiliary classes if (!validClassFile($fname) || !validClassName($class))
$ref=new LPC_I18n_reference($msgKey); if (!$ref->probe()) { $p->a("<div class='container'>← <a href='message_select.php'>Back to the message list</a></div>"); $p->a(new LPC_HTML_error("This reference message was not found in the database: [".htmlspecialchars($msgKey)."]")); $p->show(); return; $p->show(); } if (isset($_POST['delete'])) { $ref->delete(); header("Location: message_select.php"); exit; } $target_lang=new LPC_Language($_SESSION['LPC_target_lang']); $reference_lang=new LPC_Language($_SESSION['LPC_reference_lang']); if (isset($_POST['submit'])) { LPC_HTML_form::enforceSK(); $msg->setAttr('translation',$_POST['translation']); $msg->save(); $ref->setAttrs(array( 'comment'=>$_POST['comment'], 'system'=>isset($_POST['system']), )); $ref->save(); } // The links on the top of the page $links=array( "[<a href='lang_select.php?m=".rawurlencode($msgKey)."'>Translate this message to another language</a>]",