From 428ebd85b8934e8a0b968fb1809b1ecbae4382fd Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 18 Mar 2021 02:01:12 +0800 Subject: [PATCH] custom fields i18n finish --- _db/dbstructure_v1.6.sql | 2 +- lang/chs/lang_catmanage.php | 6 +++++- lang/chs/lang_fields.php | 5 ++--- lang/chs/lang_settings.php | 2 +- lang/cht/lang_catmanage.php | 4 ++++ lang/cht/lang_fields.php | 6 ++---- lang/cht/lang_settings.php | 2 +- lang/en/lang_catmanage.php | 6 +++++- lang/en/lang_fields.php | 29 ++++++++++++++--------------- lang/en/lang_functions.php | 2 +- nexus/Field/Field.php | 30 +++++++++++------------------- public/catmanage.php | 11 +++++------ public/fields.php | 10 +++++----- public/shoutbox.php | 2 +- 14 files changed, 58 insertions(+), 59 deletions(-) diff --git a/_db/dbstructure_v1.6.sql b/_db/dbstructure_v1.6.sql index d84ca72d..b3111550 100644 --- a/_db/dbstructure_v1.6.sql +++ b/_db/dbstructure_v1.6.sql @@ -1705,7 +1705,7 @@ CREATE TABLE `searchbox` ( `catpadding` smallint(5) unsigned NOT NULL DEFAULT '25', `custom_fields` text, `custom_fields_display_name` varchar(255) NOT NULL DEFAULT '', - `custom_fields_display_order` text, + `custom_fields_display` text, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/lang/chs/lang_catmanage.php b/lang/chs/lang_catmanage.php index 29e68fec..b7667522 100644 --- a/lang/chs/lang_catmanage.php +++ b/lang/chs/lang_catmanage.php @@ -75,7 +75,11 @@ $lang_catmanage = array 'std_missing_form_data' => "有必填项目未填写。", 'std_invalid_character_in_filename' => "此文件名包含不合法字符:", 'std_must_define_one_selection' => "你必须至少指定一个选择!", - 'std_invalid_mode_id' => "无效的模式id。" + 'std_invalid_mode_id' => "无效的模式id。", + 'row_enable_custom_field' => '启用自字义字段', + 'row_custom_field_display_name' => '自定义字段展示名称', + 'row_custom_field_display' => '自定义字段展示', + 'row_custom_field_display_help' => '使用特殊的标签代表字段的名称和值,如某字段其 Name 为 artist,则它的名称为:<%artist.label%>,它的值为:<%artist.value%>', ); ?> diff --git a/lang/chs/lang_fields.php b/lang/chs/lang_fields.php index 1f690530..0d135467 100644 --- a/lang/chs/lang_fields.php +++ b/lang/chs/lang_fields.php @@ -9,13 +9,13 @@ $lang_fields = [ 'text_edit' => '编辑', 'col_id' => 'ID', 'col_name' => 'Name', - 'col_name_helptext' => '仅允许数字、字母、下划线', + 'col_name_help' => '仅允许数字、字母、下划线', 'col_label' => '显示标签', 'col_type' => '类型', 'col_required' => '不能为空', 'col_help' => '辅助说明', 'col_options' => '选项', - 'col_options_helptext' => '类型为单选、多选、下拉时必填,一行一个,格式:选项值|选项描述文本', + 'col_options_help' => '类型为单选、多选、下拉时必填,一行一个,格式:选项值|选项描述文本', 'col_action' => '操作', 'col_is_single_row' => '展示时单独一行', 'js_sure_to_delete_this' => '你确信要删除此项目吗?', @@ -26,6 +26,5 @@ $lang_fields = [ 'field_type_checkbox' => '横向多选', 'field_type_select' => '下拉单选', 'field_type_image' => '图片', - 'field_type_file' => '文件', ]; \ No newline at end of file diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index 1be60fc8..653bcd17 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -703,7 +703,7 @@ $lang_settings = array 'row_login_secret_lifetime' => '登录密钥有效期', 'text_login_secret_lifetime_deadline' => '当前密钥有效期至', 'row_enable_technical_info' => '启用技术信息', - 'text_enable_technical_info' => "默认'否'。文件技术信息来自软件 MediaInfo Text 视图的结果", + 'text_enable_technical_info' => "默认'否'。技术信息来自软件 MediaInfo Text 视图的结果", ); ?> diff --git a/lang/cht/lang_catmanage.php b/lang/cht/lang_catmanage.php index 94952c2f..9c88ada3 100644 --- a/lang/cht/lang_catmanage.php +++ b/lang/cht/lang_catmanage.php @@ -76,6 +76,10 @@ $lang_catmanage = array 'std_invalid_character_in_filename' => "此檔名包含不合法字元:", 'std_must_define_one_selection' => "你必須至少指定一個選取!", 'std_invalid_mode_id' => "無效的型態id。", + 'row_enable_custom_field' => '啟用自字義字段', + 'row_custom_field_display_name' => '自定義字段展示名稱', + 'row_custom_field_display' => '自定義字段展示', + 'row_custom_field_display_help' => '使用特殊的標簽代表字段的名稱和值,如某字段其 Name 為 artist,則它的名稱為:<%artist.label%>,它的值為:<%artist.value%>', ); ?> diff --git a/lang/cht/lang_fields.php b/lang/cht/lang_fields.php index 38e70f3a..8e3eea26 100644 --- a/lang/cht/lang_fields.php +++ b/lang/cht/lang_fields.php @@ -9,13 +9,13 @@ $lang_fields = [ 'text_edit' => '編輯', 'col_id' => 'ID', 'col_name' => 'Name', - 'col_name_helptext' => '僅允許數字、字母、下劃線', + 'col_name_help' => '僅允許數字、字母、下劃線', 'col_label' => '顯示標簽', 'col_type' => '類型', 'col_required' => '不能為空', 'col_help' => '輔助說明', 'col_options' => '選項', - 'col_options_helptext' => '類型為單選、多選、下拉時必填,一行一個,格式:選項值|選項描述文本', + 'col_options_help' => '類型為單選、多選、下拉時必填,一行一個,格式:選項值|選項描述文本', 'col_action' => '操作', 'col_is_single_row' => '展示時單獨一行', 'js_sure_to_delete_this' => '你確信要刪除此項目嗎?', @@ -25,7 +25,5 @@ $lang_fields = [ 'field_type_radio' => '橫向單選', 'field_type_checkbox' => '橫向多選', 'field_type_select' => '下拉單選', - 'field_type_image' => '圖片', - 'field_type_file' => '文件', ]; \ No newline at end of file diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php index fa13ed1b..d6b5e527 100644 --- a/lang/cht/lang_settings.php +++ b/lang/cht/lang_settings.php @@ -703,7 +703,7 @@ $lang_settings = array 'row_login_secret_lifetime' => '登錄密鑰有效期', 'text_login_secret_lifetime_deadline' => '當前密鑰有效期至', 'row_enable_technical_info' => '啟用技術信息', - 'text_enable_technical_info' => "默認'否'。文件技術信息來自軟件 MediaInfo Text 視圖的結果", + 'text_enable_technical_info' => "默認'否'。技術信息來自軟件 MediaInfo Text 視圖的結果", ); ?> diff --git a/lang/en/lang_catmanage.php b/lang/en/lang_catmanage.php index 70165ee3..d833338e 100644 --- a/lang/en/lang_catmanage.php +++ b/lang/en/lang_catmanage.php @@ -75,7 +75,11 @@ $lang_catmanage = array 'std_missing_form_data' => "Missing form data.", 'std_invalid_character_in_filename' => "Invalid character in filename ", 'std_must_define_one_selection' => "You must define at least one selection!", - 'std_invalid_mode_id' => "Invalid mode id." + 'std_invalid_mode_id' => "Invalid mode id.", + 'row_enable_custom_field' => 'Enable custom field', + 'row_custom_field_display_name' => 'Custom field display name', + 'row_custom_field_display' => 'Custom field display', + 'row_custom_field_display_help' => "Use 'specific label' to represent custom field's label and value,such as one custom field's name is 'artist',
then it's label:<%artist.label%>,it's value:<%artist.value%>", ); ?> diff --git a/lang/en/lang_fields.php b/lang/en/lang_fields.php index a9d3332b..d3bddc60 100644 --- a/lang/en/lang_fields.php +++ b/lang/en/lang_fields.php @@ -1,7 +1,7 @@ 'Custom field managent', + 'field_management' => 'Custom field management', 'text_manage' => 'Manage', 'text_add' => 'Add', 'text_field' => 'Field', @@ -9,23 +9,22 @@ $lang_fields = [ 'text_edit' => 'Edit', 'col_id' => 'ID', 'col_name' => 'Name', - 'col_name_helptext' => 'Only allow digit, alphabet, underline', + 'col_name_help' => 'Only allow digit, alphabet, underline', 'col_label' => 'Display label', 'col_type' => 'Type', 'col_required' => 'Required', - 'col_help' => 'Helptext', + 'col_help' => 'Help text', 'col_options' => 'Options', - 'col_options_helptext' => '类型为单选、多选、下拉时必填,一行一个,格式:选项值|选项描述文本', - 'col_action' => '操作', - 'col_is_single_row' => '展示时单独一行', - 'js_sure_to_delete_this' => '你确信要删除此项目吗?', - 'submit_submit' => '提交', - 'field_type_text' => '短文本', - 'field_type_textarea' => '长文本', - 'field_type_radio' => '横向单选', - 'field_type_checkbox' => '横向多选', - 'field_type_select' => '下拉单选', - 'field_type_image' => '图片', - 'field_type_file' => '文件', + 'col_options_help' => 'Required when type is radio, checkbox, select. One line, one option, format: value|display text', + 'col_action' => 'Action', + 'col_is_single_row' => 'Display on a single row', + 'js_sure_to_delete_this' => 'Sure to delete?', + 'submit_submit' => 'Submit', + 'field_type_text' => 'Short text', + 'field_type_textarea' => 'Long text', + 'field_type_radio' => 'Horizontal single select', + 'field_type_checkbox' => 'Horizontal multiple select', + 'field_type_select' => 'Vertical single select', + 'field_type_image' => 'Image', ]; \ No newline at end of file diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php index 67c875c9..f88e5d06 100644 --- a/lang/en/lang_functions.php +++ b/lang/en/lang_functions.php @@ -316,7 +316,7 @@ $lang_functions = array 'text_tag_mother_language_subtitle' => 'Mother language subtitle', 'text_required' => 'Required', 'text_invalid' => 'Invalid', - 'text_technical_info' => 'Technical Information', + 'text_technical_info' => 'Technical Info', 'text_technical_info_help_text' => 'Technical Information comes from software MediaInfo,open file, click the view menu > text > right click in the box > select all > copy > past into this box.' ); diff --git a/nexus/Field/Field.php b/nexus/Field/Field.php index 466bb2bf..13fb89ea 100644 --- a/nexus/Field/Field.php +++ b/nexus/Field/Field.php @@ -66,7 +66,7 @@ class Field { $out = []; foreach (self::$types as $key => $value) { - $out[$key] = sprintf('%s(%s)', $this->getTypeHuman($key), $value['text']); + $out[$key] = sprintf('%s(%s)', $value['text'], $this->getTypeHuman($key)); } return $out; } @@ -87,18 +87,18 @@ class Field function buildFieldForm(array $row = []) { global $lang_fields, $lang_functions; - $trName = tr($lang_fields['col_name'] . '*', '  ' . $lang_fields['col_name_helptext'], 1, '', true); + $trName = tr($lang_fields['col_name'] . '*', '  ' . $lang_fields['col_name_help'], 1, '', true); $trLabel = tr($lang_fields['col_label'] . '*', '', 1, '', true); $trType = tr($lang_fields['col_type'] . '*', $this->radio('type', $this->getTypeRadioOptions(), $row['type'] ?? null), 1, '', true); $trRequired = tr($lang_fields['col_required'] . '*', $this->radio('required', ['0' => $lang_functions['text_no'], '1' => $lang_functions['text_yes']], $row['required'] ?? null), 1, '', true); $trHelp = tr($lang_fields['col_help'], '', 1, '', true); - $trOptions = tr($lang_fields['col_options'], '
' . $lang_fields['col_options_helptext'], 1, '', true); + $trOptions = tr($lang_fields['col_options'], '
' . $lang_fields['col_options_help'], 1, '', true); $trIsSingleRow = tr($lang_fields['col_is_single_row'] . '*', $this->radio('is_single_row', ['0' => $lang_functions['text_no'], '1' => $lang_functions['text_yes']], $row['is_single_row'] ?? null), 1, '', true); $id = $row['id'] ?? 0; $form = << -

{$lang_fields['text_field']}

-
+

{$lang_fields['text_field']}

+
@@ -143,24 +143,16 @@ HTML; $row['is_single_row_text'] = $row['is_single_row'] ? $lang_functions['text_yes'] : $lang_functions['text_no']; $row['type_text'] = sprintf('%s(%s)', $this->getTypeHuman($row['type']), $row['type']); $row['action'] = sprintf( - "%s | %s", + "%s | %s", $row['id'], $lang_fields['js_sure_to_delete_this'], $lang_fields['text_delete'], $row['id'], $lang_fields['text_edit'] ); $rows[] = $row; } $head = <<{$lang_fields['field_management']} - +

{$lang_fields['field_management']}

- - {$lang_fields['text_manage']} - - - {$lang_fields['text_add']} + {$lang_fields['text_add']}
HEAD; @@ -252,7 +244,7 @@ HEAD; while ($row = mysql_fetch_assoc($res)) { $checkbox .= sprintf( '', - $name, $row['id'], in_array($row['id'], $current) ? ' checked' : '', "{$row['label']}[{$row['id']}]" + $name, $row['id'], in_array($row['id'], $current) ? ' checked' : '', "{$row['name']}[{$row['label']}]" ); } $checkbox .= ''; @@ -414,9 +406,9 @@ JS; { global $browsecatmode; $displayName = get_searchbox_value($browsecatmode, 'custom_fields_display_name'); - $displayOrder = get_searchbox_value($browsecatmode, 'custom_fields_display_order'); + $display = get_searchbox_value($browsecatmode, 'custom_fields_display'); $customFields = $this->listTorrentCustomField($torrentId); - $mixedRowContent = nl2br($displayOrder); + $mixedRowContent = nl2br($display); $rowByRowHtml = ''; foreach ($customFields as $field) { $content = $this->formatCustomFieldValue($field); diff --git a/public/catmanage.php b/public/catmanage.php index 785f9980..68b87f97 100644 --- a/public/catmanage.php +++ b/public/catmanage.php @@ -236,11 +236,10 @@ function print_category_editor($type, $row='') tr($lang_catmanage['row_items_per_row']."*", " " . $lang_catmanage['text_items_per_row_note'], 1); tr($lang_catmanage['row_padding_between_items']."*", " " . $lang_catmanage['text_padding_between_items_note'], 1); $field = new \Nexus\Field\Field(); - tr('启用自字义字段', $field->buildFieldCheckbox('custom_fields[]', $row['custom_fields'] ?? ''), 1); - tr('自定义字段显示名称', '', 1); - $helpText = '
使用标签代表字段,如某字段其 Name 为 artist,则它的标签为:<%artist%>'; - $helpText .= '
仅针对非单独占一行的字段有效'; - tr('自定义字段显示顺序', '' . $helpText, 1); + tr($lang_catmanage['row_enable_custom_field'], $field->buildFieldCheckbox('custom_fields[]', $row['custom_fields'] ?? ''), 1); + tr($lang_catmanage['row_custom_field_display_name'], '', 1); + $helpText = '
' . $lang_catmanage['row_custom_field_display_help']; + tr($lang_catmanage['row_custom_field_display'], '' . $helpText, 1); } elseif ($type=='caticon') { @@ -708,7 +707,7 @@ elseif($action == 'submit') $updateset[] = "showaudiocodec=".sqlesc($showaudiocodec); $updateset[] = "custom_fields=" . sqlesc(implode(',', $_POST['custom_fields'] ?? [])); $updateset[] = "custom_fields_display_name=" . sqlesc($_POST['custom_fields_display_name'] ?? ''); - $updateset[] = "custom_fields_display_order=" . sqlesc($_POST['custom_fields_display_order'] ?? ''); + $updateset[] = "custom_fields_display=" . sqlesc($_POST['custom_fields_display'] ?? ''); if ($showsource || $showmedium || $showcodec || $showstandard || $showprocessing || $showteam || $showaudiocodec) $updateset[] = "showsubcat=1"; else diff --git a/public/fields.php b/public/fields.php index b066712e..ee8fb12e 100644 --- a/public/fields.php +++ b/public/fields.php @@ -23,20 +23,20 @@ if ($action == 'view') { } elseif ($action == 'submit') { try { $result = $field->save($_REQUEST); - redirect('fields.php?action=view&type='); + redirect('fields.php?action=view'); } catch (\Exception $e) { stderr($lang_fields['field_management']." - ".$lang_fields['text_field'], $e->getMessage()); } } elseif ($action == 'edit') { $id = intval($_GET['id'] ?? 0); if ($id == 0) { - stderr($lang_fields['field_management'], "invalid id"); + stderr($lang_fields['field_management'], "Invalid id"); } $sql = "select * from torrents_custom_fields where id = $id"; $res = sql_query($sql); $row = mysql_fetch_assoc($res); if (empty($row)) { - stderr('', 'invlaid id'); + stderr('', 'Invalid id'); } stdhead($lang_fields['field_management']." - ".$lang_fields['text_edit']); begin_main_frame(); @@ -44,11 +44,11 @@ if ($action == 'view') { } elseif ($action == 'del') { $id = intval($_GET['id'] ?? 0); if ($id == 0) { - stderr($lang_fields['field_management'], "invalid id"); + stderr($lang_fields['field_management'], "Invalid id"); } $sql = "delete from torrents_custom_fields where id = $id"; $res = sql_query($sql); - redirect('fields.php?action=view&type='); + redirect('fields.php?action=view'); } diff --git a/public/shoutbox.php b/public/shoutbox.php index cf0fed57..b7e5073f 100644 --- a/public/shoutbox.php +++ b/public/shoutbox.php @@ -131,7 +131,7 @@ else $time = strftime("%m.%d %H:%M",$arr["date"]); else $time = get_elapsed_time($arr["date"]).$lang_shoutbox['text_ago']; print("\n"); } print("
[".$time."] ". -$del ." ". $username." " . format_comment($arr["text"],true,false,true,true,600,true,false)." +$del ." ". $username." " . format_comment($arr["text"],true,false,true,true,600,false,false)."
");