Skip to content

Commit

Permalink
Merge pull request #9 from LibreSign/feature/translate
Browse files Browse the repository at this point in the history
Translate
  • Loading branch information
vitormattos authored Jan 10, 2024
2 parents 14b32a3 + 4b97c38 commit ea74b7c
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 44 deletions.
4 changes: 2 additions & 2 deletions examples/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export default {
name: 'App',
data(){
return {
initFileName: '测试.pdf',
initFileName: 'test.pdf',
initFile :'',
textFields: ['初始文本'],
textFields: ['initial text'],
imageUrls: [],
}
},
Expand Down
4 changes: 2 additions & 2 deletions examples/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Vue from 'vue'
import App from './App.vue'

// 导入组件库
// Import component library
import VuePdfEditor from './../packages/index'
// 注册组件库
// Registered component library
Vue.use(VuePdfEditor)

Vue.config.productionTip = false
Expand Down
17 changes: 9 additions & 8 deletions packages/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
// 导入颜色选择器组件
// Import color picker component
import VuePdfEditor from './vue-pdf-editor'

// 存储组件列表
// Store component list
const components = [
VuePdfEditor
]

// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
// Define the install method, receiving Vue as a parameter. If you use use
// to register a plugin, all components will be registered
const install = function (Vue) {
// 判断是否安装
// Determine whether to install
if (install.installed) return
// 遍历注册全局组件
// Traverse registered global components
components.map(component => Vue.component(component.name, component))
}

// 判断是否是直接引入文件
// Determine whether the file is imported directly
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}

export default {
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
// Exported objects must have install before they can be installed by the Vue.use() method
install,
// 以下是具体的组件列表
// The following is a specific list of components
VuePdfEditor
}
6 changes: 3 additions & 3 deletions packages/vue-pdf-editor/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// 导入组件,组件必须声明 name
// To import components, components must declare name
import VuePdfEditor from './src/VuePdfEditor.vue'
import './style/main.css'

// 为组件提供 install 安装方法,供按需引入
// Provide an INSTALL installation method for the component to introduce it on demand
VuePdfEditor.install = function (Vue) {
Vue.component(VuePdfEditor.name, VuePdfEditor)
}

// 默认导出组件
// Default export component
export default VuePdfEditor

4 changes: 2 additions & 2 deletions packages/vue-pdf-editor/src/DrawingCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"
@click="onClose"
>
取消
Cancel
</button>
<button
class="
Expand All @@ -47,7 +47,7 @@
"
@click="onFinish"
>
完成
Finish
</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-pdf-editor/src/PDFPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
},
watch: {
scale(newScale) {
this.dynamicScale = newScale; // 监听scale属性的变化,并更新动态缩放
this.dynamicScale = newScale; // Monitor changes in the scale attribute and update dynamic scaling
this.render();
},
},
Expand Down
8 changes: 4 additions & 4 deletions packages/vue-pdf-editor/src/TextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@tapout="onBlurTool"
>
<div v-if="showLineSizeSelect" class="mr-2 flex items-center">
<img title="行间距" src="vue-pdf-editor/svg/line_height.svg" class="w-6 mr-2" alt="Line height"/>
<img title="Line spacing" src="vue-pdf-editor/svg/line_height.svg" class="w-6 mr-2" alt="Line height"/>
<input
v-model="lineHeight_"
type="number"
Expand All @@ -33,7 +33,7 @@
/>
</div>
<div v-if="showFontSizeSelect" class="mr-2 flex items-center">
<img title="字号" src="vue-pdf-editor/svg/text.svg" class="w-6 mr-2" alt="Font size"/>
<img title="Font size" src="vue-pdf-editor/svg/text.svg" class="w-6 mr-2" alt="Font size"/>
<input
v-model="size_"
type="number"
Expand All @@ -44,7 +44,7 @@
/>
</div>
<div v-if="showFontSelect" class="mr-2 flex items-center">
<img title="字体" src="vue-pdf-editor/svg/text-family.svg" class="w-4 mr-2" alt="Font family"/>
<img title="font" src="vue-pdf-editor/svg/text-family.svg" class="w-4 mr-2" alt="Font family"/>
<div class="relative w-32 md:w-40">
<select
v-model="fontFamily_"
Expand Down Expand Up @@ -97,7 +97,7 @@
<div
class="w-5 h-5 rounded-full bg-white cursor-pointer"
@click="onDelete">
<img class="w-full h-full" src="vue-pdf-editor/svg/delete.svg" title="移除" alt="delete object"/>
<img class="w-full h-full" src="vue-pdf-editor/svg/delete.svg" title="Remove" alt="delete object"/>
</div>
</tapout-component>
<div
Expand Down
30 changes: 15 additions & 15 deletions packages/vue-pdf-editor/src/VuePdfEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class="whitespace-no-wrap bg-blue-500 hover:bg-blue-700 text-white
font-bold py-1 px-3 md:px-4 rounded mr-3 cursor-pointer md:mr-4"
for="pdf">
选择PDF
Select PDF
</label>
<button v-show="narrowEnlargeShow" class="w-7 h-7 bg-blue-500 hover:bg-blue-700 text-white font-bold flex items-center justify-center mr-3 md:mr-4
rounded-full" @click="narrow">-</button>
Expand All @@ -28,22 +28,22 @@
<div v-if="showCustomizeEditor"
class="relative mr-3 flex h-8 bg-gray-400 rounded-sm overflow-hidden
md:mr-4">
<label title="添加图片" v-if="showCustomizeEditorAddImg"
<label title="add pictures" v-if="showCustomizeEditorAddImg"
class="flex items-center justify-center h-full w-8 hover:bg-gray-500
cursor-pointer"
for="image"
:class="[selectedPageIndex < 0 ?'cursor-not-allowed bg-gray-500':'']">
<img src="vue-pdf-editor/svg/image.svg" alt="An icon for adding images"/>
</label>
<label title="添加文字" v-if="showCustomizeEditorAddText"
<label title="Add text" v-if="showCustomizeEditorAddText"
class="flex items-center justify-center h-full w-8 hover:bg-gray-500
cursor-pointer"
for="text"
:class="[selectedPageIndex < 0 ?'cursor-not-allowed bg-gray-500':'']"
@click="onAddTextField">
<img src="vue-pdf-editor/svg/notes.svg" alt="An icon for adding text"/>
</label>
<label title="添加笔迹" v-if="showCustomizeEditorAddDraw"
<label title="Add a handwriting" v-if="showCustomizeEditorAddDraw"
class="flex items-center justify-center h-full w-8 hover:bg-gray-500
cursor-pointer"
@click="onAddDrawing"
Expand All @@ -53,8 +53,8 @@
</div>
<div v-if="showRename" class="justify-center mr-3 md:mr-4 w-full max-w-xs hidden md:flex">
<img src="vue-pdf-editor/svg/edit.svg" class="mr-2" alt="a pen, edit pdf name" @click="renamePDF($refs.renamePDFInputOne)"/>
<input ref="renamePDFInputOne" title="在此处重命名PDF"
placeholder="在此处重命名PDF"
<input ref="renamePDFInputOne" title="Rename PDF here"
placeholder="Rename PDF here"
type="text"
class="flex-grow bg-transparent"
v-model="pdfName"/>
Expand All @@ -65,7 +65,7 @@
class="w-20 bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-3
md:px-4 mr-3 md:mr-4 rounded"
:class="[(pages.length === 0 || saving || !pdfFile) ?'cursor-not-allowed bg-blue-700':'']">
{{ saving ? '保存中' : '保存' }}
{{ saving ? 'saving' : 'keep' }}
</button>
</div>
<div v-if="addingDrawing">
Expand All @@ -82,16 +82,16 @@
<div v-if="showRename" class="flex justify-center px-5 pt-5 w-full md:hidden">
<div class="flex items-center">
<img src="vue-pdf-editor/svg/edit.svg" class="mr-2 justify-center" alt="a pen, edit pdf name" @click="renamePDF($refs.renamePDFInputTwo)"/>
<input ref="renamePDFInputTwo" style="text-align:center" title="在此处重命名PDF"
placeholder="在此处重命名PDF"
<input ref="renamePDFInputTwo" style="text-align:center" title="Rename PDF here"
placeholder="Rename PDF here"
type="text"
class="flex-grow bg-transparent justify-center"
v-model="pdfName"/>
</div>

</div>

<!-- PDF主体 -->
<!-- PDF main body -->
<div class="w-full" style="text-align: center;">
<div v-for="(page,pIndex) in pages" :key="pIndex" style="display: inline-block;">
<div
Expand Down Expand Up @@ -169,7 +169,7 @@
</div>
<!-- <div v-else>-->
<!-- <div class="w-full flex-grow flex justify-center items-center">-->
<!-- <span class=" font-bold text-3xl text-gray-500">拖入PDF文件</span>-->
<!-- <span class=" font-bold text-3xl text-gray-500">Drag into the PDF file</span>-->
<!-- </div>-->
<!-- </div>-->
</div>
Expand Down Expand Up @@ -315,7 +315,7 @@ export default {
pages: [],
pagesScale: [],
allObjects: [],
currentFont: "宋体",
currentFont: "Song style",
focusId: null,
selectedPageIndex: -1,
saving: false,
Expand Down Expand Up @@ -408,7 +408,7 @@ export default {
this.selectedPageIndex = i;
let y = 0;
if (this.initImageUrls !== null && this.initImageUrls.length !== 0) {
// 需要初始化图片
// Need to initialize pictures
for (let j = 0; j < this.initImageUrls.length; j++) {
if (this.initTextFields.length === 0) {
y = j * 100
Expand All @@ -419,7 +419,7 @@ export default {
}
}
if (this.sealImageShow) {
// 展示印章示例
// Example of display seal
const res = await fetch(this.sealImageUrl);
await this.addImage(await res.blob(), 0, (y+1)*100 ,0.4,true);
}
Expand Down Expand Up @@ -554,7 +554,7 @@ export default {
}
},
addTextField(text = "请在此输入", x = 0, y = 0, currentPage = this.selectedPageIndex) {
addTextField(text = "Please enter here", x = 0, y = 0, currentPage = this.selectedPageIndex) {
const id = this.genID();
fetchFont(this.currentFont);
const object = {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-pdf-editor/utils/PDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function save(pdfFile, objects, name, isUpload=false,callback) {
try {
const pdfBytes = await pdfDoc.save();
if (isUpload) {
// 上传
// Upload
callback(pdfBytes);
return
}
Expand Down
12 changes: 6 additions & 6 deletions packages/vue-pdf-editor/utils/prepareAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,37 @@ const fonts = {
// Available fonts
export const Fonts = {
...fonts,
'宋体': {
'Song style': {
correction(size, lineHeight) {
return (size * lineHeight - size) / 2 + size / 7;
},
src: 'vue-pdf-editor/fonts/SongTi.ttf',
},
'微软雅黑': {
'Microsoft Yahei': {
correction(size, lineHeight) {
return (size * lineHeight - size) / 2 + size / 7;
},
src: 'vue-pdf-editor/fonts/WeiRuanYaHei.ttf',
},
'方正小标宋简': {
'Fang Zheng Xiaoziao Song Jian': {
correction(size, lineHeight) {
return (size * lineHeight - size) / 2 + size / 7;
},
src: 'vue-pdf-editor/fonts/FangZhengXiaoBiaoSongJian.ttf',
},
'楷体': {
'Regular': {
correction(size, lineHeight) {
return (size * lineHeight - size) / 2 + size / 7;
},
src: 'vue-pdf-editor/fonts/KaiTi.ttf',
},
'等线': {
'Equal line': {
correction(size, lineHeight) {
return (size * lineHeight - size) / 2 + size / 7;
},
src: 'vue-pdf-editor/fonts/DengXian.ttf',
},
'黑体': {
'Black body': {
correction(size, lineHeight) {
return (size * lineHeight - size) / 2 + size / 7;
},
Expand Down

0 comments on commit ea74b7c

Please sign in to comment.