Skip to content

Commit

Permalink
feat: comment 国际化
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxiaolu1993 committed Apr 18, 2022
1 parent 6e9e1c1 commit 84d0c96
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/packages/__VUE/comment/components/CmtBottom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</template>
<template v-if="name == 'more'">
<nut-icon name="more-x"></nut-icon>
<view class="nut-comment-bottom__cpx-item-popover" v-if="showPopver" @click="operate('popover')">
我要投诉
</view>
<view class="nut-comment-bottom__cpx-item-popover" v-if="showPopver" @click="operate('popover')">{{
translate('complaintsText')
}}</view>
</template>
</view>
</template>
Expand All @@ -26,7 +26,7 @@
import { ref, watch, onMounted } from 'vue';
import { createComponent } from '../../../utils/create';
const { componentName, create } = createComponent('comment-bottom');
const { componentName, create, translate } = createComponent('comment-bottom');
export default create({
props: {
Expand Down Expand Up @@ -76,7 +76,7 @@ export default create({
emit('handleClick');
};
return { showPopver, operate, mergeOp, handleClick };
return { showPopver, operate, mergeOp, handleClick, translate };
}
});
</script>
8 changes: 4 additions & 4 deletions src/packages/__VUE/comment/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

<view class="nut-comment__follow" v-if="follow && follow.days > 0" @click="handleClick">
<view class="nut-comment__follow-title"
><nut-icon size="14" name="joy-smile" />购买{{ follow.days }}天后追评</view
><nut-icon size="14" name="joy-smile" />{{ translate('additionalReview', follow.days) }}</view
>
<view class="nut-comment__follow-com">{{ follow.content }}</view>
<view class="nut-comment__follow-img" v-if="follow.images && follow.images.length > 0"
>{{ follow.images.length }} 张追评图片 <nut-icon size="12" name="right"
>{{ translate('additionalImages', follow.images.length) }} <nut-icon size="12" name="right"
/></view>
</view>

Expand All @@ -42,7 +42,7 @@
<script lang="ts">
import { ref, onMounted, computed, watch } from 'vue';
import { createComponent } from '../../utils/create';
const { componentName, create } = createComponent('comment');
const { componentName, create, translate } = createComponent('comment');
import CommentHeader from './components/CmtHeader.vue';
import CommentImages from './components/CmtImages.vue';
Expand Down Expand Up @@ -126,7 +126,7 @@ export default create({
emit('clickImages', value);
};
return { classes, conEllipsis, clickOperate, handleClick, clickImages };
return { classes, conEllipsis, clickOperate, handleClick, clickImages, translate };
}
});
</script>
5 changes: 5 additions & 0 deletions src/packages/locale/lang/baseLang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ export interface BaseLang {
deliveryTo: string;
chooseAnotherAddress: string;
};
comment: {
complaintsText: string;
additionalReview: Function;
additionalImages: Function;
};
}
5 changes: 5 additions & 0 deletions src/packages/locale/lang/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ const lang: BaseLang = {
selectRegion: 'Select Region',
deliveryTo: 'Delivery To',
chooseAnotherAddress: 'Choose Another Address'
},
comment: {
complaintsText: 'I have a complaint',
additionalReview: (day: number) => `Review after ${day} days of purchase`,
additionalImages: (length: number) => `There are ${length} follow-up comments`
}
};
export default lang;
5 changes: 5 additions & 0 deletions src/packages/locale/lang/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ const lang: BaseLang = {
selectRegion: '请选择所在地区',
deliveryTo: '配送至',
chooseAnotherAddress: '选择其他地址'
},
comment: {
complaintsText: '我要投诉',
additionalReview: (day: number) => `购买${day}天后追评`,
additionalImages: (length: number) => `${length}张追评图片`
}
};
export default lang;

0 comments on commit 84d0c96

Please sign in to comment.