added language support for task tooltip
This commit is contained in:
@@ -3,6 +3,10 @@ import { ref, computed, onUnmounted, onMounted, nextTick, watch } from 'vue'
|
||||
import type { Task } from '../models/classes/Task'
|
||||
import { TimelineScale } from '../models/types/TimelineScale'
|
||||
|
||||
|
||||
import { useI18n } from '../composables/useI18n'
|
||||
|
||||
|
||||
interface Props {
|
||||
task: Task
|
||||
rowHeight: number
|
||||
@@ -30,6 +34,12 @@ interface Props {
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const { setLocale, getTranslation } = useI18n()
|
||||
|
||||
const t = (key: string): string => {
|
||||
return getTranslation(key)
|
||||
}
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:task',
|
||||
'bar-mounted',
|
||||
@@ -825,9 +835,9 @@ const handleBubbleMouseDown = (event: MouseEvent) => {
|
||||
|
||||
// 格式化日期显示
|
||||
const formatDisplayDate = (dateStr: string | undefined): string => {
|
||||
if (!dateStr) return '未设置'
|
||||
if (!dateStr) return t('dateNotSet')
|
||||
const date = createLocalDate(dateStr)
|
||||
if (!date) return '未设置'
|
||||
if (!date) return t('dateNotSet')
|
||||
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
@@ -1065,23 +1075,23 @@ const calculatePositionFromTimelineData = (
|
||||
<div class="tooltip-title">{{ task.name }}</div>
|
||||
<div class="tooltip-content">
|
||||
<div class="tooltip-row">
|
||||
<span class="tooltip-label">计划开始:</span>
|
||||
<span class="tooltip-label"> {{ t('startDate') }}:</span>
|
||||
<span class="tooltip-value">{{ formatDisplayDate(task.startDate) }}</span>
|
||||
</div>
|
||||
<div class="tooltip-row">
|
||||
<span class="tooltip-label">计划结束:</span>
|
||||
<span class="tooltip-label">{{ t('endDate') }}:</span>
|
||||
<span class="tooltip-value">{{ formatDisplayDate(task.endDate) }}</span>
|
||||
</div>
|
||||
<div class="tooltip-row">
|
||||
<span class="tooltip-label">计划工时:</span>
|
||||
<span class="tooltip-label">{{ t('estimatedHours') }}:</span>
|
||||
<span class="tooltip-value">{{ workHourInfo.total }}h</span>
|
||||
</div>
|
||||
<div class="tooltip-row">
|
||||
<span class="tooltip-label">已用工时:</span>
|
||||
<span class="tooltip-label"> {{ t('actualHours') }}:</span>
|
||||
<span class="tooltip-value">{{ workHourInfo.used }}h</span>
|
||||
</div>
|
||||
<div class="tooltip-row">
|
||||
<span class="tooltip-label">完成率:</span>
|
||||
<span class="tooltip-label"> {{ t('progress') }}:</span>
|
||||
<span class="tooltip-value">{{ task.progress || 0 }}%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,7 @@ export type Locale = 'zh-CN' | 'en-US'
|
||||
// 多语言配置
|
||||
const messages = {
|
||||
'zh-CN': {
|
||||
dateNotSet: '未设置',
|
||||
// TaskList Header
|
||||
taskName: '任务名称',
|
||||
predecessor: '前置任务',
|
||||
@@ -158,6 +159,7 @@ const messages = {
|
||||
days: '天',
|
||||
},
|
||||
'en-US': {
|
||||
dateNotSet:'Not set',
|
||||
// TaskList Header
|
||||
taskName: 'Task Name',
|
||||
predecessor: 'Predecessor',
|
||||
|
||||
Reference in New Issue
Block a user