@tagadapay/plugin-sdk 2.7.22 → 2.7.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ export type TranslationText = {
5
5
  };
6
6
  export interface UseTranslationOptions {
7
7
  defaultLanguage?: string;
8
+ currentLanguage?: string;
8
9
  }
9
10
  export type TranslationParams = {
10
11
  [key: string]: string | number | ((children: ReactNode) => ReactNode);
@@ -51,9 +51,11 @@ import React, { useCallback, useMemo } from 'react';
51
51
  * ```
52
52
  */
53
53
  export const useTranslation = (options = {}) => {
54
- const { defaultLanguage = 'en' } = options;
54
+ const { defaultLanguage = 'en', currentLanguage } = options;
55
55
  // Get the current language from query params, browser, or fallback to default
56
56
  const locale = useMemo(() => {
57
+ if (currentLanguage)
58
+ return currentLanguage;
57
59
  // Check for language query parameter
58
60
  if (typeof window !== 'undefined') {
59
61
  const urlParams = new URLSearchParams(window.location.search);
@@ -152,7 +154,7 @@ export const useTranslation = (options = {}) => {
152
154
  return interpolate(fallback || '', params);
153
155
  if (typeof text === 'string')
154
156
  return interpolate(text, params);
155
- const targetLocale = languageCode || locale;
157
+ const targetLocale = languageCode || currentLanguage || locale;
156
158
  let translatedText = '';
157
159
  if (text[targetLocale]) {
158
160
  translatedText = text[targetLocale];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.7.22",
3
+ "version": "2.7.25",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",