@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.
|
@@ -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];
|