From d464c1c7831379ce68aecbf126ca1adf9ff3c8bd Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 18 Jul 2014 09:44:16 -0500 Subject: [PATCH] i18n: Add several forgotten phrases Also add some logic to the POT builder to warn about incorrect arguments to the __() function and friends as well as warn about _() usage. --- include/ajax.tickets.php | 6 +++--- include/class.dynamic_forms.php | 2 +- include/class.forms.php | 5 +++-- include/class.page.php | 2 +- include/class.setup.php | 2 +- include/class.sla.php | 3 ++- include/class.topic.php | 2 +- include/staff/email.inc.php | 6 +++--- include/staff/filter.inc.php | 4 ++-- include/staff/helptopic.inc.php | 2 +- include/staff/staff.inc.php | 8 ++++---- setup/cli/modules/i18n.php | 7 +++++++ 12 files changed, 29 insertions(+), 20 deletions(-) diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 9b324034a..4904163ec 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -251,8 +251,8 @@ class TicketsAjaxAPI extends AjaxController { $uid = md5($_SERVER['QUERY_STRING']); $_SESSION["adv_$uid"] = $tickets; $result['success'] = sprintf(__("Search criteria matched %s"), - sprintf(_N('%d ticket', '%d tickets', count($tickets), - $tickets))) + sprintf(_N('%d ticket', '%d tickets'), count($tickets), + $tickets)) . " - <a href='tickets.php?advsid=$uid'>".__('view')."</a>"; } else { $result['fail']=__('No tickets found matching your search criteria.'); @@ -332,7 +332,7 @@ class TicketsAjaxAPI extends AjaxController { global $thisstaff; if(!$thisstaff || !($ticket=Ticket::lookup($tid)) || !$ticket->checkStaffAccess($thisstaff)) - Http::response(404, _('No such ticket')); + Http::response(404, __('No such ticket')); ob_start(); $resp = ob_get_contents(); diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index f56f65dd6..45fc398c3 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1238,7 +1238,7 @@ class SelectionField extends FormField { if ($this->value && !isset($this->_choices[$this->value])) { $v = DynamicListItem::lookup($this->value); $this->_choices[$v->get('id')] = $v->get('value') - . mb_convert_encoding(__(' (Disabled)'), MB_CASE_TITLE); + . ' ' . __('(disabled)'); } } return $this->_choices; diff --git a/include/class.forms.php b/include/class.forms.php index a80478620..98e7e7ea9 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1084,12 +1084,13 @@ class ChoicesWidget extends Widget { $have_def = isset($choices[$def_key]); if (!$have_def) $def_val = ($config['prompt']) - ? $config['prompt'] : 'Select'; + ? $config['prompt'] : __('Select' + /* Used as a default prompt for a custom drop-down list */); else $def_val = $choices[$def_key]; } else { $def_val = ($config['prompt']) - ? $config['prompt'] : 'Select'; + ? $config['prompt'] : __('Select'); } $value = $this->value; if ($value === null && $have_def) diff --git a/include/class.page.php b/include/class.page.php index 88d91d2cd..c533617d6 100644 --- a/include/class.page.php +++ b/include/class.page.php @@ -269,7 +269,7 @@ class Page { } else { $sql='INSERT INTO '.PAGE_TABLE.' SET '.$sql.', created=NOW()'; if (!db_query($sql) || !($id=db_insert_id())) { - $errors['err']=sprintf(_('Unable to create %s.'), __('this site page')) + $errors['err']=sprintf(__('Unable to create %s.'), __('this site page')) .' '.__('Internal error occurred'); return false; } diff --git a/include/class.setup.php b/include/class.setup.php index 98471d21a..fe70fc10b 100644 --- a/include/class.setup.php +++ b/include/class.setup.php @@ -30,7 +30,7 @@ Class SetupWizard { function SetupWizard(){ $this->errors=array(); - $this->version_verbose = sprintf(_('osTicket %s' /* <%s> is for the version */), + $this->version_verbose = sprintf(__('osTicket %s' /* <%s> is for the version */), THIS_VERSION); } diff --git a/include/class.sla.php b/include/class.sla.php index 81e897cc7..9b3933a53 100644 --- a/include/class.sla.php +++ b/include/class.sla.php @@ -137,7 +137,8 @@ class SLA { $sql='SELECT id, name, isactive, grace_period FROM '.SLA_TABLE.' ORDER BY name'; if(($res=db_query($sql)) && db_num_rows($res)) { while($row=db_fetch_array($res)) - $slas[$row['id']] = sprintf('%s (%d hrs - %s)', + $slas[$row['id']] = sprintf(__('%s (%d hours - %s)' + /* Tokens are <name> (<#> hours - <Active|Disabled>) */), $row['name'], $row['grace_period'], $row['isactive']?'Active':'Disabled'); diff --git a/include/class.topic.php b/include/class.topic.php index bfc1df37f..a334e3b54 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -268,7 +268,7 @@ class Topic { if (!$disabled && $info['disabled']) continue; if ($disabled === self::DISPLAY_DISABLED && $info['disabled']) - $n .= " — (disabled)"; + $n .= " — ".__("(disabled)"); $requested_names[$id] = $n; } diff --git a/include/staff/email.inc.php b/include/staff/email.inc.php index 37d40b0df..9d2e3f89c 100644 --- a/include/staff/email.inc.php +++ b/include/staff/email.inc.php @@ -215,11 +215,11 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </span> </td> </tr> - <tr><td><?php echo _('Mail Box Protocol'); ?></td> + <tr><td><?php echo __('Mail Box Protocol'); ?></td> <td> <span> <select name="mail_proto"> - <option value=''>— <?php __('Select Protocol'); ?> —</option> + <option value=''>— <?php __('Select protocol'); ?> —</option> <?php foreach (MailFetcher::getSupportedProtos() as $proto=>$desc) { ?> <option value="<?php echo $proto; ?>" <?php @@ -236,7 +236,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <tr><td><?php echo __('Fetch Frequency'); ?></td> <td> <span> - <input type="text" name="mail_fetchfreq" size=4 value="<?php echo $info['mail_fetchfreq']?$info['mail_fetchfreq']:''; ?>"> minutes + <input type="text" name="mail_fetchfreq" size=4 value="<?php echo $info['mail_fetchfreq']?$info['mail_fetchfreq']:''; ?>"> <?php echo __('minutes'); ?> <i class="help-tip icon-question-sign" href="#fetch_frequency"></i> <font class="error"> <?php echo $errors['mail_fetchfreq']; ?></font> </span> diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php index 40802ec3b..76e75fb49 100644 --- a/include/staff/filter.inc.php +++ b/include/staff/filter.inc.php @@ -87,7 +87,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); } $sql='SELECT email_id,email,name FROM '.EMAIL_TABLE.' email ORDER by name'; if(($res=db_query($sql)) && db_num_rows($res)) { - echo '<OPTGROUP label="Specific System Email">'; + echo sprintf('<OPTGROUP label="%s">', __('System Emails')); while(list($id,$email,$name)=db_fetch_row($res)) { $selected=($info['email_id'] && $id==$info['email_id'])?'selected="selected"':''; if($name) @@ -218,7 +218,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ? 'selected="selected"' : ''; if (!$isenabled) - $title .= _(' (disabled)'); + $title .= ' ' . __('(disabled)'); echo sprintf('<option value="%d" %s>%s</option>', $id, $selected, $title); diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php index 67a6bb895..91ea1d9cc 100644 --- a/include/staff/helptopic.inc.php +++ b/include/staff/helptopic.inc.php @@ -219,7 +219,7 @@ if ($info['form_id'] == Topic::FORM_USE_PARENT) echo 'selected="selected"'; $selected = ($info['assign']==$k || $info['team_id']==$id)?'selected="selected"':''; if (!$isenabled) - $name .= ' '.mb_convert_encoding(__('(disabled)'), MB_CASE_TITLE); + $name .= ' '.__('(disabled)'); ?> <option value="<?php echo $k; ?>"<?php echo $selected; ?>><?php echo $name; ?></option> <?php diff --git a/include/staff/staff.inc.php b/include/staff/staff.inc.php index ac46767ab..8b73bb557 100644 --- a/include/staff/staff.inc.php +++ b/include/staff/staff.inc.php @@ -133,7 +133,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </th> </tr> <tr> - <td><?php echo _('Authentication Backend'); ?></td> + <td><?php echo __('Authentication Backend'); ?></td> <td> <select name="backend" id="backend-selection" onchange="javascript: if (this.value != '' && this.value != 'local') @@ -141,7 +141,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); else if (!$('#welcome-email').is(':checked')) $('#password-fields').show(); "> - <option value="">— <?php echo ('Use any available backend'); ?> —</option> + <option value="">— <?php echo __('Use any available backend'); ?> —</option> <?php foreach (StaffAuthenticationBackend::allRegistered() as $ab) { if (!$ab->supportsInteractiveAuthentication()) continue; ?> <option value="<?php echo $ab::$id; ?>" <?php @@ -240,7 +240,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); if(($res=db_query($sql)) && db_num_rows($res)){ while(list($id,$name,$isactive)=db_fetch_row($res)){ $sel=($info['group_id']==$id)?'selected="selected"':''; - echo sprintf('<option value="%d" %s>%s %s</option>',$id,$sel,$name,($isactive?'':' (Disabled)')); + echo sprintf('<option value="%d" %s>%s %s</option>',$id,$sel,$name,($isactive?'':__('(disabled)'))); } } ?> @@ -344,7 +344,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); while(list($id,$name,$isactive)=db_fetch_row($res)){ $checked=($info['teams'] && in_array($id,$info['teams']))?'checked="checked"':''; echo sprintf('<tr><td colspan=2><input type="checkbox" name="teams[]" value="%d" %s>%s %s</td></tr>', - $id,$checked,$name,($isactive?'':' (Disabled)')); + $id,$checked,$name,($isactive?'':__('(disabled)'))); } } ?> <tr> diff --git a/setup/cli/modules/i18n.php b/setup/cli/modules/i18n.php index dfa00cc71..e43bbee7e 100644 --- a/setup/cli/modules/i18n.php +++ b/setup/cli/modules/i18n.php @@ -275,6 +275,11 @@ class i18n_Compiler extends Module { } $args['forms'][] = $string['form']; } + elseif ($string) { + $this->stderr->write(sprintf("%s: %s: Too many arguments\n", + $string['line'] ?: '?', $string['form'])); + } + // Add usage and comment info if (!isset($args['line']) && isset($string['line'])) $args['line'] = $string['line']; @@ -432,6 +437,8 @@ class i18n_Compiler extends Module { '_NS' => array('forms'=>2), '_P' => array('context'=>1, 'forms'=>1), '_NP' => array('context'=>1, 'forms'=>2), + // This is an error + '_' => array('forms'=>0), ); $files = Test::getAllScripts(); $strings = array(); -- GitLab