Skip to content

Commit bea7193

Browse files
committed
feat(viewer): add missing i18n props
Close #46
1 parent 12d5053 commit bea7193

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,6 @@
9999
},
100100
"optionalDependencies": {
101101
"terminal-kit": "^3.0.1"
102-
}
102+
},
103+
"packageManager": "pnpm@8.15.7+sha256.50783dd0fa303852de2dd1557cd4b9f07cb5b018154a6e76d0f40635d6cee019"
103104
}

src/viewer.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import { isExpandLine, mergeSegments, type InlineRenderInfo } from './utils/segm
1313

1414
interface ExpandLineRendererOptions {
1515
/**
16-
* If this is `true`, you can show a "⬆️ Show xx lines" button
16+
* If this is `true`, you can show a " Show xx lines before" button
1717
*/
1818
hasLinesBefore: boolean;
1919
/**
20-
* If this is `true`, you can show a "⬇️ Show xx lines" button
20+
* If this is `true`, you can show a " Show xx lines after" button
2121
*/
2222
hasLinesAfter: boolean;
2323
/**
@@ -57,7 +57,7 @@ export type HideUnchangedLinesOptions = boolean | {
5757
* default renderer will produce the following buttons in this line:
5858
*
5959
* ```text
60-
* [⬆️ Show 20 lines] [↕️ Show all unchanged lines] [⬇️ Show 20 lines]
60+
* [ Show 20 lines] [ Show all unchanged lines] [ Show 20 lines]
6161
* ```
6262
*/
6363
expandLineRenderer?: (options?: ExpandLineRendererOptions) => JSX.Element;
@@ -115,6 +115,12 @@ export interface ViewerProps {
115115
texts?: {
116116
/** @default 'No change detected' */
117117
noChangeDetected?: string;
118+
/** @default '⭡ Show %d lines before', where %d is the number */
119+
showLinesBefore?: string;
120+
/** @default '⭣ Show %d lines after', where %d is the number */
121+
showLinesAfter?: string;
122+
/** @default '⭥ Show all unchanged lines' */
123+
showAll?: string;
118124
};
119125
/** Extra class names */
120126
className?: string;
@@ -126,6 +132,9 @@ const DEFAULT_INDENT = 2;
126132
const DEFAULT_EXPAND_MORE_LINES_LIMIT = 20;
127133
const DEFAULT_TEXTS = {
128134
noChangeDetected: 'No change detected',
135+
showLinesBefore: '⭡ Show %d lines before',
136+
showLinesAfter: '⭣ Show %d lines after',
137+
showAll: '⭥ Show all unchanged lines',
129138
};
130139

131140
const Viewer: React.FC<ViewerProps> = props => {
@@ -362,17 +371,17 @@ const Viewer: React.FC<ViewerProps> = props => {
362371
{
363372
hasLinesBefore && (
364373
<button onClick={() => onExpandBefore(index)(expandMoreLinesLimit)}>
365-
⭡ Show {expandMoreLinesLimit} lines before
374+
{mergedTexts.showLinesBefore.replaceAll('%d', String(expandMoreLinesLimit))}
366375
</button>
367376
)
368377
}
369378
<button onClick={() => onExpandAll(index)()}>
370-
⭥ Show all unchanged lines
379+
{mergedTexts.showAll}
371380
</button>
372381
{
373382
hasLinesAfter && (
374383
<button onClick={() => onExpandAfter(index)(expandMoreLinesLimit)}>
375-
⭣ Show {expandMoreLinesLimit} lines after
384+
{mergedTexts.showLinesAfter.replaceAll('%d', String(expandMoreLinesLimit))}
376385
</button>
377386
)
378387
}

0 commit comments

Comments
 (0)