Skip to content

Commit 931e960

Browse files
fix: fixes done
1 parent 56c7c8c commit 931e960

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

example/translation-demo-nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react": "^19.0.0",
2020
"react-dom": "^19.0.0",
2121
"tailwind-merge": "^3.3.0",
22-
"translation-widget": "^1.0.10"
22+
"translation-widget": "^1.0.11"
2323
},
2424
"devDependencies": {
2525
"@eslint/eslintrc": "^3",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "translation-widget",
3-
"version": "1.0.10",
3+
"version": "1.0.11",
44
"description": "Translation widget to automatically translate any website with a single script",
55
"homepage": "https://github.com/JigsawStack/translation-widget",
66
"author": "JigsawStack",

src/constants/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Position } from "../types";
21

32
export const MAX_CACHE_SIZE = 1000;
43
export const BATCH_SIZE = 10;
@@ -7,5 +6,5 @@ export const CACHE_PREFIX = "jss-";
76
export const DEFAULT_CONFIG = {
87
pageLanguage: "en",
98
autoDetectLanguage: false,
10-
position: Position.TopRight,
9+
position: "top-right",
1110
};

src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styles from "./translation-widget.css?inline";
22
import { TranslationWidget } from "./widget";
3-
import type { TranslationConfig, Position } from "./types";
3+
import type { TranslationConfig } from "./types";
44

55
declare global {
66
interface Window {
@@ -36,5 +36,4 @@ const initializeTranslationWidget = (publicKey: string, config?: TranslationConf
3636
}
3737
};
3838

39-
export default initializeTranslationWidget;
40-
export { TranslationWidget, TranslationConfig, Position };
39+
export default initializeTranslationWidget;

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface Language {
88

99
export interface TranslationConfig {
1010
pageLanguage?: string;
11-
position?: Position;
11+
position?: "top-right" | "top-left" | "bottom-left" | "bottom-right";
1212
autoDetectLanguage?: boolean;
1313
theme?: {
1414
baseColor?: string;

src/widget/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { TranslationService } from "../lib/translation/index";
22
import { DocumentNavigator } from "../lib/dom";
33
import { languages } from "../constants/languages";
44
import { BATCH_SIZE, DEFAULT_CONFIG } from "../constants";
5-
import { Language, TranslationConfig, WidgetElements, TranslationResult, Position, LANG_PARAM, LOCALSTORAGE_KEYS, ATTRIBUTES } from "../types";
5+
import { Language, TranslationConfig, WidgetElements, TranslationResult, LANG_PARAM, LOCALSTORAGE_KEYS, ATTRIBUTES } from "../types";
66
import widgetTemplate from "../templates/html/widget.html?raw";
77
import { generateHashForContent, getUserLanguage, removeEmojis, validatePublicApiKey } from "../utils/utils";
88
import { CACHE_PREFIX } from "../constants";
@@ -33,13 +33,13 @@ export class TranslationWidget {
3333
* @param config - The configuration for the translation widget
3434
*/
3535
constructor(publicKey: string, config: Partial<TranslationConfig> = {}) {
36-
const allowedPositions: Position[] = [Position.TopRight, Position.TopLeft, Position.BottomLeft, Position.BottomRight];
36+
const allowedPositions: string[] = ["top-right", "top-left", "bottom-left", "bottom-right"];
3737

3838
let safeConfig = { ...DEFAULT_CONFIG, ...config };
3939

4040
if (safeConfig.position && !allowedPositions.includes(safeConfig.position)) {
4141
console.warn(`Invalid position '${safeConfig.position}' passed to TranslationWidget. Falling back to 'top-right'.`);
42-
safeConfig.position = Position.TopRight;
42+
safeConfig.position = "top-right";
4343
}
4444

4545
this.config = safeConfig as Required<TranslationConfig>;

0 commit comments

Comments
 (0)