Skip to content

Commit

Permalink
feat(caption): support i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
luolonghao committed Oct 30, 2024
1 parent 942b516 commit ebeb8b4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/boxes/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function renderFloatingToolbar(box: Box): void {
name: 'caption',
type: 'button',
icon: icons.get('caption'),
tooltip: 'Caption',
tooltip: locale => locale.image.caption(),
isSelected: () => {
const boxContainer = box.getContainer();
const captionNode = boxContainer.find('.lake-image-caption');
Expand Down Expand Up @@ -286,7 +286,7 @@ function renderCaption(box: Box): void {
return;
}
captionNode.attr('contenteditable', 'true');
captionNode.attr('placeholder', 'Write a caption...');
captionNode.attr('placeholder', editor.locale.image.captionPlaceholder());
const changeHandler = debounce((value: string) => {
editor.selection.updateByRange();
if (editor.isComposing) {
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export default {
originalWidth: 'Original image width',
imageWidth: '{0} image width',
open: 'Open image in new tab',
caption: 'Caption',
captionPlaceholder: 'Write a caption...',
},
file: {
download: 'Download',
Expand All @@ -132,6 +134,6 @@ export default {
equation: {
save: 'Done',
help: 'Supported functions',
placeholder: 'Type a TeX expression',
placeholder: 'Type a TeX expression...',
},
} satisfies BaseTranslation;
4 changes: 3 additions & 1 deletion src/i18n/ja/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export default {
originalWidth: '画像の元のサイズ',
imageWidth: '{0} 画像サイズ',
open: '新しいタブで画像を開く',
caption: 'キャプション',
captionPlaceholder: 'キャプションを入力してください',
},
file: {
download: 'ダウンロード',
Expand All @@ -132,6 +134,6 @@ export default {
equation: {
save: '保存',
help: 'サポートされている機能',
placeholder: 'TeX 数式を入力してください',
placeholder: 'TeX 数式を入力してください',
},
} satisfies Translation;
2 changes: 2 additions & 0 deletions src/i18n/ko/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export default {
originalWidth: '원본 이미지 크기',
imageWidth: '{0} 이미지 크기',
open: '새 탭에서 이미지 열기',
caption: '캡션',
captionPlaceholder: '캡션을 입력하세요',
},
file: {
download: '다운로드',
Expand Down
20 changes: 18 additions & 2 deletions src/i18n/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ type RootTranslation = {
*/
pageWidth: string
/**
* O​r​i​g​i​n​a​l​ ​w​i​d​t​h
* O​r​i​g​i​n​a​l​ ​i​m​a​g​e​ ​w​i​d​t​h
*/
originalWidth: string
/**
Expand All @@ -444,6 +444,14 @@ type RootTranslation = {
* O​p​e​n​ ​i​m​a​g​e​ ​i​n​ ​n​e​w​ ​t​a​b
*/
open: string
/**
* C​a​p​t​i​o​n
*/
caption: string
/**
* W​r​i​t​e​ ​a​ ​c​a​p​t​i​o​n​.​.​.
*/
captionPlaceholder: string
}
file: {
/**
Expand Down Expand Up @@ -916,7 +924,7 @@ export type TranslationFunctions = {
*/
pageWidth: () => LocalizedString
/**
* Original width
* Original image width
*/
originalWidth: () => LocalizedString
/**
Expand All @@ -927,6 +935,14 @@ export type TranslationFunctions = {
* Open image in new tab
*/
open: () => LocalizedString
/**
* Caption
*/
caption: () => LocalizedString
/**
* Write a caption...
*/
captionPlaceholder: () => LocalizedString
}
file: {
/**
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/zh-CN/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export default {
originalWidth: '图片原始大小',
imageWidth: '{0} 图片大小',
open: '在新标签页中打开图片',
caption: '图片描述',
captionPlaceholder: '请输入图片描述',
},
file: {
download: '下载',
Expand Down

0 comments on commit ebeb8b4

Please sign in to comment.