@tagadapay/plugin-sdk 2.7.22 → 2.7.24

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.
@@ -51,10 +51,13 @@ import React, { useCallback, useMemo } from 'react';
51
51
  * ```
52
52
  */
53
53
  export const useTranslation = (options = {}) => {
54
- const { defaultLanguage = 'en' } = options;
54
+ const { defaultLanguage } = options;
55
55
  // Get the current language from query params, browser, or fallback to default
56
56
  const locale = useMemo(() => {
57
57
  // Check for language query parameter
58
+ if (defaultLanguage) {
59
+ return defaultLanguage;
60
+ }
58
61
  if (typeof window !== 'undefined') {
59
62
  const urlParams = new URLSearchParams(window.location.search);
60
63
  const langFromQuery = urlParams.get('locale');
@@ -66,7 +69,7 @@ export const useTranslation = (options = {}) => {
66
69
  const browserLang = navigator.language.split('-')[0]; // e.g., 'en-US' -> 'en'
67
70
  return browserLang;
68
71
  }
69
- return defaultLanguage;
72
+ return 'en';
70
73
  }, [defaultLanguage]);
71
74
  const t = useCallback((text, fallback, params, languageCode) => {
72
75
  // Helper function to interpolate params into the translated string
@@ -160,7 +163,7 @@ export const useTranslation = (options = {}) => {
160
163
  else if (fallback) {
161
164
  translatedText = fallback;
162
165
  }
163
- else if (text[defaultLanguage]) {
166
+ else if (defaultLanguage && text[defaultLanguage]) {
164
167
  translatedText = text[defaultLanguage];
165
168
  }
166
169
  else {
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.24",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",