本文整理汇总了PHP中Translate::trans方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::trans方法的具体用法?PHP Translate::trans怎么用?PHP Translate::trans使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translate
的用法示例。
在下文中一共展示了Translate::trans方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strtolower
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param Conf $conf Handler de conf
* @param Translate $langs Handler de langue
* @param User $user Handler du user connecte
*/
function __construct($db, $conf, $langs, $user)
{
$this->id = "Perso";
$this->length = $langs->trans("SetupPerso");
$this->db = $db;
$this->conf = $conf;
$this->langs = $langs;
$this->user = $user;
if (empty($conf->global->USER_PASSWORD_PATTERN)) {
// default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation.
dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1', 'chaine', 0, '', $conf->entity);
}
$this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$this->Min = strtolower($this->Maj);
$this->Nb = "0123456789";
$this->Spe = "!@#\$%&*()_-+={}[]\\|:;'/";
$this->Ambi = array("1", "I", "l", "|", "O", "0");
$tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN);
$this->length2 = $tabConf[0];
$this->NbMaj = $tabConf[1];
$this->NbNum = $tabConf[2];
$this->NbSpe = $tabConf[3];
$this->NbRepeat = $tabConf[4];
$this->WithoutAmbi = $tabConf[5];
if ($this->WithoutAmbi) {
$this->Maj = str_replace($this->Ambi, "", $this->Maj);
$this->Min = str_replace($this->Ambi, "", $this->Min);
$this->Nb = str_replace($this->Ambi, "", $this->Nb);
$this->Spe = str_replace($this->Ambi, "", $this->Spe);
}
$this->All = str_shuffle($this->Maj . $this->Min . $this->Nb . $this->Spe);
//$this->All = $this->Maj. $this->Min. $this->Nb. $this->Spe;
//$this->All = $this->Spe;
}
示例2: info
/**
* Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
*/
function info($langs)
{
global $conf;
global $form;
$langs->load("companies");
$tooltip = '';
$texte = '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
$texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
$texte .= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
$texte .= '<table class="nobordernopadding" width="100%">';
$s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="' . $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER . '">', $tooltip, 1, 1);
$s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="' . $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER . '">', $tooltip, 1, 1);
$texte .= '<tr><td>' . $langs->trans("ModuleCompanyCode" . $this->nom, $s1, $s2) . "<br>\n";
$texte .= '</td>';
$texte .= '<td align="left"> <input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button"></td>';
$texte .= '</tr></table>';
$texte .= '</form>';
return $texte;
}
示例3: testLang
/**
* testBank
*
* @return string
*/
public function testLang()
{
global $conf, $user, $langs, $db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php';
$filesarray = scandir(DOL_DOCUMENT_ROOT . '/langs');
foreach ($filesarray as $key => $code) {
if (!preg_match('/^[a-z]+_[A-Z]+$/', $code)) {
continue;
}
print 'Check language file for lang code=' . $code . "\n";
$tmplangs = new Translate('', $conf);
$langcode = $code;
$tmplangs->setDefaultLang($langcode);
$tmplangs->load("main");
$result = $tmplangs->trans("SeparatorDecimal");
print __METHOD__ . " SeparatorDecimal=" . $result . "\n";
$this->assertContains($result, array('.', ',', '/', ' ', '', 'None'), 'Error for decimal separator for lang code ' . $code);
// Note that ، that is coma for RTL languages is not supported
$result = $tmplangs->trans("SeparatorThousand");
print __METHOD__ . " SeparatorThousand=" . $result . "\n";
$this->assertContains($result, array('.', ',', '/', ' ', '', 'None', 'Space'), 'Error for thousand separator for lang code ' . $code);
// Note that ، that is coma for RTL languages is not supported
// Test java string contains only d,M,y,/,-,. and not m,...
$result = $tmplangs->trans("FormatDateShortJava");
print __METHOD__ . " FormatDateShortJava=" . $result . "\n";
$this->assertRegExp('/^[dMy\\/\\-\\.]+$/', $result, 'FormatDateShortJava KO for lang code ' . $code);
$result = $tmplangs->trans("FormatDateShortJavaInput");
print __METHOD__ . " FormatDateShortJavaInput=" . $result . "\n";
$this->assertRegExp('/^[dMy\\/\\-\\.]+$/', $result, 'FormatDateShortJavaInput KO for lang code ' . $code);
unset($tmplangs);
}
return;
}
示例4: monthArray
/**
* Return array of translated months or selected month.
* This replace old function monthArrayOrSelected.
*
* @param Translate $outputlangs Object langs
* @return array Month string or array if selected < 0
*/
function monthArray($outputlangs)
{
$montharray = array(1 => $outputlangs->trans("January"), 2 => $outputlangs->trans("February"), 3 => $outputlangs->trans("March"), 4 => $outputlangs->trans("April"), 5 => $outputlangs->trans("May"), 6 => $outputlangs->trans("June"), 7 => $outputlangs->trans("July"), 8 => $outputlangs->trans("August"), 9 => $outputlangs->trans("September"), 10 => $outputlangs->trans("October"), 11 => $outputlangs->trans("November"), 12 => $outputlangs->trans("December"));
return $montharray;
}
示例5: info
/**
* Return description of a module
*
* @param Translate $langs Lang object to use for output
* @return string Description
*/
function info($langs)
{
global $conf, $langs;
$langs->load("companies");
$langs->load("errors");
$form = new Form($this->db);
$texte = $this->description . ".<br>\n";
$texte .= '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
$texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) {
$texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
$texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
$texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
}
$texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte .= '<tr><td>';
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\\r\\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
foreach ($listofdir as $key => $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]);
continue;
}
if (!is_dir($tmpdir)) {
$texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
} else {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\\.(ods|odt)');
if (count($tmpfiles)) {
$listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
}
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp .= '<br>' . $langs->trans("FollowingSubstitutionKeysCanBeUsed") . '<br>';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");
// This contains an url, we don't modify it
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte .= '<textarea class="flat" cols="60" name="value1">';
$texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
$texte .= '</textarea>';
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button">';
$texte .= '<br></div></div>';
// Scan directories
if (count($listofdir)) {
$texte .= $langs->trans("NumberOfModelFilesFound") . ': <b>' . count($listoffiles) . '</b>';
if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) {
// Model for creation
$liste = ModelePDFSupplierProposal::liste_modeles($this->db);
$texte .= '<table width="50%;">';
$texte .= '<tr>';
$texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalCreate") . '</td>';
$texte .= '<td colspan="">';
$texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
$texte .= "</td></tr>";
$texte .= '<tr>';
$texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalToBill") . '</td>';
$texte .= '<td colspan="">';
$texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
$texte .= "</td></tr>";
$texte .= '<tr>';
$texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalClosed") . '</td>';
$texte .= '<td colspan="">';
$texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
$texte .= "</td></tr>";
$texte .= '</table>';
}
}
$texte .= '</td>';
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte .= '</td>';
$texte .= '</tr>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
示例6: info
/** Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
*/
function info($langs)
{
$langs->load("companies");
return $langs->trans("LeopardNumRefModelDesc");
}
示例7: pdf_getPDFFontSize
/**
* Return font size to use for PDF generation
*
* @param Translate $outputlangs Output langs object
* @return int Size of font to use
*/
function pdf_getPDFFontSize($outputlangs)
{
$size = 10;
// By default, for FPDI or ISO language on TCPDF
if (class_exists('TCPDF')) {
if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') {
$size = (int) $outputlangs->trans('FONTSIZEFORPDF');
}
}
return $size;
}
示例8: dol_print_reduction
/**
* Returns formated reduction
*
* @param int $reduction Reduction percentage
* @param Translate $langs Output language
* @return string Formated reduction
*/
function dol_print_reduction($reduction, $langs)
{
$string = '';
if ($reduction == 100) {
$string = $langs->trans("Offered");
} else {
$string = $reduction . '%';
}
return $string;
}
示例9: getMaxDeliveryTimeDay
/**
* Return the max number delivery delay in day
*
* @param Translate $langs Language object
* @return Translated string
*/
function getMaxDeliveryTimeDay($langs)
{
if (empty($this->lines)) {
return '';
}
$obj = new ProductFournisseur($this->db);
$nb = 0;
foreach ($this->lines as $line) {
if ($line->fk_product > 0) {
$idp = $obj->find_min_price_product_fournisseur($line->fk_product, $line->qty);
if ($idp) {
$obj->fetch($idp);
if ($obj->delivery_time_days > $nb) {
$nb = $obj->delivery_time_days;
}
}
}
}
if ($nb === 0) {
return '';
} else {
return $nb . ' ' . $langs->trans('Days');
}
}
示例10: getToolTip
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
function getToolTip($langs, $soc, $type)
{
global $conf, $db;
$langs->load("admin");
$s = '';
if ($type == -1) {
$s .= $langs->trans("Name") . ': <b>' . $this->nom . '</b><br>';
}
if ($type == -1) {
$s .= $langs->trans("Version") . ': <b>' . $this->getVersion() . '</b><br>';
}
//$s.='<br>';
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
$s .= '<br>';
if ($type == 0 || $type == -1) {
$result = $this->get_code($db, $soc, 'customer');
$nextval = $this->code;
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Customer") . ')' : '') . ': <b>' . $nextval . '</b><br>';
}
if ($type == 1 || $type == -1) {
$result = $this->get_code($db, $soc, 'supplier');
$nextval = $this->code;
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Supplier") . ')' : '') . ': <b>' . $nextval . '</b>';
}
return $s;
}
示例11: show_subsidiaries
/**
* Show html area for list of subsidiaries
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Database handler
* @param Societe $object Third party object
* @return void
*/
function show_subsidiaries($conf, $langs, $db, $object)
{
global $user;
global $bc;
$i = -1;
$sql = "SELECT s.rowid, s.nom as name, s.address, s.zip, s.town, s.code_client, s.canvas";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= " WHERE s.parent = " . $object->id;
$sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")";
$sql .= " ORDER BY s.nom";
$result = $db->query($sql);
$num = $db->num_rows($result);
if ($num) {
$socstatic = new Societe($db);
print_titre($langs->trans("Subsidiaries"));
print "\n" . '<table class="noborder" width="100%">' . "\n";
print '<tr class="liste_titre"><td>' . $langs->trans("Company") . '</td>';
print '<td>' . $langs->trans("Address") . '</td><td>' . $langs->trans("Zip") . '</td>';
print '<td>' . $langs->trans("Town") . '</td><td>' . $langs->trans("CustomerCode") . '</td>';
print "<td> </td>";
print "</tr>";
$i = 0;
$var = true;
while ($i < $num) {
$obj = $db->fetch_object($result);
$var = !$var;
print "<tr " . $bc[$var] . ">";
print '<td>';
$socstatic->id = $obj->rowid;
$socstatic->name = $obj->name;
$socstatic->canvas = $obj->canvas;
print $socstatic->getNomUrl(1);
print '</td>';
print '<td>' . $obj->address . '</td>';
print '<td>' . $obj->zip . '</td>';
print '<td>' . $obj->town . '</td>';
print '<td>' . $obj->code_client . '</td>';
print '<td align="center">';
print '<a href="' . DOL_URL_ROOT . '/societe/soc.php?socid=' . $obj->rowid . '&action=edit">';
print img_edit();
print '</a></td>';
print "</tr>\n";
$i++;
}
print "\n</table>\n";
}
print "<br>\n";
return $i;
}
示例12: dolGetFirstLastname
$foundtoprocess = 0;
$salerepresentative = dolGetFirstLastname($obj->firstname, $obj->lastname);
if (empty($obj->email)) {
print "Warning: Sale representative " . $salerepresentative . " has no email. Notice disabled.\n";
}
}
// Define line content
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($obj->lang) ? $langs->defaultlang : $obj->lang);
// By default language of sale representative
$outputlangs->load("bills");
$outputlangs->load("main");
$outputlangs->load("contracts");
$outputlangs->load("products");
if (dol_strlen($obj->email)) {
$message .= $outputlangs->trans("Contract") . " " . $obj->ref . ": " . $langs->trans("Service") . " " . dol_concatdesc($obj->plabel, $obj->description) . " (" . price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) . ") " . $obj->name . ", " . $outputlangs->trans("DateEndPlannedShort") . " " . dol_print_date($db->jdate($obj->date_fin_validite), 'day') . "\n\n";
dol_syslog("email_expire_services_to_representatives.php: " . $obj->email);
$foundtoprocess++;
}
print "Service to expire " . $obj->ref . ", label " . dol_concatdesc($obj->plabel, $obj->description) . ", due date " . dol_print_date($db->jdate($obj->date_fin_validite), 'day') . " (linked to company " . $obj->name . ", sale representative " . dolGetFirstLastname($obj->firstname, $obj->lastname) . ", email " . $obj->email . "): ";
if (dol_strlen($obj->email)) {
print "qualified.";
} else {
print "disqualified (no email).";
}
print "\n";
unset($outputlangs);
$total += $obj->total_ttc;
$i++;
}
// Si il reste des envois en buffer
示例13: getExample
/**
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param societe $objsoc Object thirdparty
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Return string example
*/
function getExample($langs, $objsoc = 0, $type = -1)
{
if ($type == 0 || $type == -1) {
$examplecust = $this->getNextValue($objsoc, 0);
if (!$examplecust) {
$examplecust = $langs->trans('NotConfigured');
}
if ($examplecust == "ErrorBadMask") {
$langs->load("errors");
$examplecust = $langs->trans($examplecust);
}
if ($examplecust == "ErrorCantUseRazIfNoYearInMask") {
$langs->load("errors");
$examplecust = $langs->trans($examplecust);
}
if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") {
$langs->load("errors");
$examplecust = $langs->trans($examplecust);
}
}
if ($type == 1 || $type == -1) {
$examplesup = $this->getNextValue($objsoc, 1);
if (!$examplesup) {
$examplesup = $langs->trans('NotConfigured');
}
if ($examplesup == "ErrorBadMask") {
$langs->load("errors");
$examplesup = $langs->trans($examplesup);
}
if ($examplesup == "ErrorCantUseRazIfNoYearInMask") {
$langs->load("errors");
$examplesup = $langs->trans($examplesup);
}
if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") {
$langs->load("errors");
$examplesup = $langs->trans($examplesup);
}
}
if ($type == 0) {
return $examplecust;
}
if ($type == 1) {
return $examplesup;
}
return $examplecust . '<br>' . $examplesup;
}
示例14: updatePriceNextInvoice
/**
* Update price of next invoice
*
* @param Translate $langs Translate object
* @return bool false if KO, true if OK
*/
function updatePriceNextInvoice(&$langs)
{
foreach ($this->tab_next_situation_invoice as $next_invoice) {
$is_last = $next_invoice->is_last_in_cycle();
if ($next_invoice->brouillon && $is_last != 1) {
$this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref);
return false;
}
$next_invoice->brouillon = 1;
foreach ($next_invoice->lines as $line) {
$result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
if ($result < 0) {
$this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref);
return false;
}
}
break;
// Only the next invoice and not each next invoice
}
return true;
}
示例15: migrate_reload_menu
/**
* Reload menu if dynamic menus, if modified by version
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @param string $versionto Version target
* @return void
*/
function migrate_reload_menu($db, $langs, $conf, $versionto)
{
global $conf;
dolibarr_install_syslog("upgrade2::migrate_reload_menu");
// Define list of menu handlers to initialize
$listofmenuhandler = array();
$versiontoarray = explode('.', $versionto);
// Script for VX (X<2.9) -> V2.9
$afterversionarray = explode('.', '2.8.9');
$beforeversionarray = explode('.', '2.9.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
$listofmenuhandler['auguria'] = 1;
// We set here only dynamic menu handlers
}
// Script for VX (X<3.2) -> V3.2
$afterversionarray = explode('.', '3.1.9');
$beforeversionarray = explode('.', '3.2.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
$listofmenuhandler['auguria'] = 1;
// We set here only dynamic menu handlers
}
foreach ($listofmenuhandler as $key => $val) {
print '<tr><td colspan="4">';
//print "x".$key;
print '<br>';
print '<b>' . $langs->trans('Upgrade') . '</b>: ' . $langs->trans('MenuHandler') . " " . $key . "<br>\n";
// Load sql ini_menu_handler.sql file
$dir = DOL_DOCUMENT_ROOT . "/core/menus/";
$file = 'init_menu_' . $key . '.sql';
if (file_exists($dir . $file)) {
$result = run_sql($dir . $file, 1, '', 1, $key);
}
print '</td></tr>';
}
}