@worldcoin/idkit 2.3.0 → 2.4.0

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.
package/build/index.cjs CHANGED
@@ -33,6 +33,10 @@ __export(src_exports, {
33
33
  IDKitWidget: () => IDKitWidget_default,
34
34
  VerificationLevel: () => import_idkit_core7.VerificationLevel,
35
35
  VerificationState: () => import_idkit_core7.VerificationState,
36
+ getCurrentLanguage: () => getCurrentLanguage,
37
+ getLocalizationConfig: () => getLocalizationConfig,
38
+ getSupportedLanguages: () => getSupportedLanguages,
39
+ setLocalizationConfig: () => setLocalizationConfig,
36
40
  solidityEncode: () => import_hashing.solidityEncode,
37
41
  useIDKit: () => useIDKit_default,
38
42
  useSession: () => useSession,
@@ -43,21 +47,157 @@ module.exports = __toCommonJS(src_exports);
43
47
  // src/hooks/useIDKit.ts
44
48
  var import_react = require("react");
45
49
 
50
+ // src/lang/translations/en.ts
51
+ var en = {
52
+ "All set!": "All set!",
53
+ "Your World ID is now connected": "Your World ID is now connected",
54
+ "Transmitting verification to host app. Please wait...": "Transmitting verification to host app. Please wait...",
55
+ "Something went wrong": "Something went wrong",
56
+ "Verification Declined": "Verification Declined",
57
+ "Request cancelled": "Request cancelled",
58
+ "Connection to your wallet failed. Please try again.": "Connection to your wallet failed. Please try again.",
59
+ "You've cancelled the request in World App.": "You've cancelled the request in World App.",
60
+ "You have already verified the maximum number of times for this action.": "You have already verified the maximum number of times for this action.",
61
+ "It seems you do not have the verification level required by this app.": "It seems you do not have the verification level required by this app.",
62
+ "Invalid network. If you are the app owner, visit docs.world.org/test for details.": "Invalid network. If you are the app owner, visit docs.world.org/test for details.",
63
+ "Your identity is still being registered. Please wait a few minutes and try again.": "Your identity is still being registered. Please wait a few minutes and try again.",
64
+ "We couldn't complete your request. Please try again.": "We couldn't complete your request. Please try again.",
65
+ "Try Again": "Try Again",
66
+ "Open World App": "Open World App",
67
+ "Hide QR Code": "Hide QR Code",
68
+ "Display QR Code": "Display QR Code",
69
+ "QR Code copied": "QR Code copied",
70
+ "Connect your World ID": "Connect your World ID",
71
+ "Use phone camera to scan the QR code": "Use phone camera to scan the QR code",
72
+ "Connecting...": "Connecting...",
73
+ "Please continue in app": "Please continue in app",
74
+ "You will be redirected to the app, please return to this page once you're done": "You will be redirected to the app, please return to this page once you're done",
75
+ "Action cannot be an empty string.": "Action cannot be an empty string.",
76
+ "Invalid IDKitStage :stage.": "Invalid IDKitStage :stage.",
77
+ "Terms & Privacy": "Terms & Privacy"
78
+ };
79
+
80
+ // src/lang/translations/es.ts
81
+ var es = {
82
+ "All set!": "\xA1Todo listo!",
83
+ "Your World ID is now connected": "Tu World ID ahora est\xE1 conectado",
84
+ "Transmitting verification to host app. Please wait...": "Transmitiendo verificaci\xF3n a la aplicaci\xF3n host. Por favor espera...",
85
+ "Something went wrong": "Algo sali\xF3 mal",
86
+ "Verification Declined": "Verificaci\xF3n rechazada",
87
+ "Request cancelled": "Solicitud cancelada",
88
+ "Connection to your wallet failed. Please try again.": "La conexi\xF3n a tu billetera fall\xF3. Por favor intenta de nuevo.",
89
+ "You've cancelled the request in World App.": "Has cancelado la solicitud en World App.",
90
+ "You have already verified the maximum number of times for this action.": "Ya has verificado el n\xFAmero m\xE1ximo de veces para esta acci\xF3n.",
91
+ "It seems you do not have the verification level required by this app.": "Parece que no tienes el nivel de verificaci\xF3n requerido por esta aplicaci\xF3n.",
92
+ "Invalid network. If you are the app owner, visit docs.world.org/test for details.": "Red inv\xE1lida. Si eres el propietario de la aplicaci\xF3n, visita docs.world.org/test para m\xE1s detalles.",
93
+ "Your identity is still being registered. Please wait a few minutes and try again.": "Tu identidad a\xFAn se est\xE1 registrando. Por favor espera unos minutos e intenta de nuevo.",
94
+ "We couldn't complete your request. Please try again.": "No pudimos completar tu solicitud. Por favor intenta de nuevo.",
95
+ "Try Again": "Intentar de nuevo",
96
+ "Open World App": "Abrir World App",
97
+ "Hide QR Code": "Ocultar c\xF3digo QR",
98
+ "Display QR Code": "Mostrar c\xF3digo QR",
99
+ "QR Code copied": "C\xF3digo QR copiado",
100
+ "Connect your World ID": "Conecta tu World ID",
101
+ "Use phone camera to scan the QR code": "Usa la c\xE1mara del tel\xE9fono para escanear el c\xF3digo QR",
102
+ "Connecting...": "Conectando...",
103
+ "Please continue in app": "Por favor contin\xFAa en la aplicaci\xF3n",
104
+ "You will be redirected to the app, please return to this page once you're done": "Ser\xE1s redirigido a la aplicaci\xF3n, por favor regresa a esta p\xE1gina una vez que hayas terminado",
105
+ "Action cannot be an empty string.": "La acci\xF3n no puede ser una cadena vac\xEDa.",
106
+ "Invalid IDKitStage :stage.": "IDKitStage inv\xE1lido :stage.",
107
+ "Terms & Privacy": "T\xE9rminos y privacidad"
108
+ };
109
+
110
+ // src/lang/translations/th.ts
111
+ var th = {
112
+ "All set!": "\u0E40\u0E23\u0E35\u0E22\u0E1A\u0E23\u0E49\u0E2D\u0E22!",
113
+ "Your World ID is now connected": "World ID \u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E41\u0E25\u0E49\u0E27",
114
+ "Transmitting verification to host app. Please wait...": "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E2A\u0E48\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E44\u0E1B\u0E22\u0E31\u0E07\u0E41\u0E2D\u0E1B\u0E42\u0E2E\u0E2A\u0E15\u0E4C \u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E2D\u0E2A\u0E31\u0E01\u0E04\u0E23\u0E39\u0E48...",
115
+ "Something went wrong": "\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14",
116
+ "Verification Declined": "\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E16\u0E39\u0E01\u0E1B\u0E0F\u0E34\u0E40\u0E2A\u0E18",
117
+ "Request cancelled": "\u0E04\u0E33\u0E02\u0E2D\u0E16\u0E39\u0E01\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",
118
+ "Connection to your wallet failed. Please try again.": "\u0E01\u0E32\u0E23\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E01\u0E31\u0E1A\u0E01\u0E23\u0E30\u0E40\u0E1B\u0E4B\u0E32\u0E40\u0E07\u0E34\u0E19\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E25\u0E49\u0E21\u0E40\u0E2B\u0E25\u0E27 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
119
+ "You've cancelled the request in World App.": "\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01\u0E04\u0E33\u0E02\u0E2D\u0E43\u0E19 World App",
120
+ "You have already verified the maximum number of times for this action.": "\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E04\u0E23\u0E1A\u0E08\u0E33\u0E19\u0E27\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E19\u0E35\u0E49\u0E41\u0E25\u0E49\u0E27",
121
+ "It seems you do not have the verification level required by this app.": "\u0E14\u0E39\u0E40\u0E2B\u0E21\u0E37\u0E2D\u0E19\u0E27\u0E48\u0E32\u0E04\u0E38\u0E13\u0E44\u0E21\u0E48\u0E21\u0E35\u0E23\u0E30\u0E14\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E2D\u0E1B\u0E19\u0E35\u0E49\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23",
122
+ "Invalid network. If you are the app owner, visit docs.world.org/test for details.": "\u0E40\u0E04\u0E23\u0E37\u0E2D\u0E02\u0E48\u0E32\u0E22\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 \u0E2B\u0E32\u0E01\u0E04\u0E38\u0E13\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E08\u0E49\u0E32\u0E02\u0E2D\u0E07\u0E41\u0E2D\u0E1B \u0E42\u0E1B\u0E23\u0E14\u0E44\u0E1B\u0E17\u0E35\u0E48 docs.world.org/test \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E23\u0E32\u0E22\u0E25\u0E30\u0E40\u0E2D\u0E35\u0E22\u0E14",
123
+ "Your identity is still being registered. Please wait a few minutes and try again.": "\u0E15\u0E31\u0E27\u0E15\u0E19\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E22\u0E31\u0E07\u0E2D\u0E22\u0E39\u0E48\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E01\u0E32\u0E23\u0E25\u0E07\u0E17\u0E30\u0E40\u0E1A\u0E35\u0E22\u0E19 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E2D\u0E2A\u0E31\u0E01\u0E04\u0E23\u0E39\u0E48\u0E41\u0E25\u0E49\u0E27\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
124
+ "We couldn't complete your request. Please try again.": "\u0E40\u0E23\u0E32\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E15\u0E32\u0E21\u0E04\u0E33\u0E02\u0E2D\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
125
+ "Try Again": "\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
126
+ "Open World App": "\u0E40\u0E1B\u0E34\u0E14 World App",
127
+ "Hide QR Code": "\u0E0B\u0E48\u0E2D\u0E19 QR Code",
128
+ "Display QR Code": "\u0E41\u0E2A\u0E14\u0E07 QR Code",
129
+ "QR Code copied": "\u0E04\u0E31\u0E14\u0E25\u0E2D\u0E01 QR Code \u0E41\u0E25\u0E49\u0E27",
130
+ "Connect your World ID": "\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D World ID \u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13",
131
+ "Use phone camera to scan the QR code": "\u0E43\u0E0A\u0E49\u0E01\u0E25\u0E49\u0E2D\u0E07\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E40\u0E1E\u0E37\u0E48\u0E2D\u0E2A\u0E41\u0E01\u0E19 QR code",
132
+ "Connecting...": "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D...",
133
+ "Please continue in app": "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E15\u0E48\u0E2D\u0E43\u0E19\u0E41\u0E2D\u0E1B",
134
+ "You will be redirected to the app, please return to this page once you're done": "\u0E04\u0E38\u0E13\u0E08\u0E30\u0E16\u0E39\u0E01\u0E19\u0E33\u0E44\u0E1B\u0E22\u0E31\u0E07\u0E41\u0E2D\u0E1B \u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E25\u0E31\u0E1A\u0E21\u0E32\u0E17\u0E35\u0E48\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E40\u0E2A\u0E23\u0E47\u0E08\u0E41\u0E25\u0E49\u0E27",
135
+ "Action cannot be an empty string.": "\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E27\u0E48\u0E32\u0E07\u0E44\u0E14\u0E49",
136
+ "Invalid IDKitStage :stage.": "IDKitStage \u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 :stage.",
137
+ "Terms & Privacy": "\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E41\u0E25\u0E30\u0E04\u0E27\u0E32\u0E21\u0E40\u0E1B\u0E47\u0E19\u0E2A\u0E48\u0E27\u0E19\u0E15\u0E31\u0E27"
138
+ };
139
+
140
+ // src/lang/translations/index.ts
141
+ var translations = {
142
+ en,
143
+ es,
144
+ th
145
+ };
146
+
147
+ // src/lang/localization.ts
148
+ var currentConfig = {};
149
+ var setLocalizationConfig = (config) => {
150
+ currentConfig = config;
151
+ };
152
+ var getLocalizationConfig = () => currentConfig;
153
+ var detectBrowserLanguage = () => {
154
+ for (const lang of navigator.languages) {
155
+ const [language] = lang.split("-");
156
+ const normalizedLang = language.toLowerCase();
157
+ if (normalizedLang in translations) {
158
+ return normalizedLang;
159
+ }
160
+ }
161
+ return void 0;
162
+ };
163
+ var getCurrentLanguage = () => {
164
+ const config = getLocalizationConfig();
165
+ if (config.language && config.language in translations) {
166
+ return config.language;
167
+ }
168
+ const browserLang = detectBrowserLanguage();
169
+ if (browserLang) {
170
+ return browserLang;
171
+ }
172
+ return "en";
173
+ };
174
+ var getTranslations = () => {
175
+ const currentLang = getCurrentLanguage();
176
+ return translations[currentLang];
177
+ };
178
+ var getSupportedLanguages = () => {
179
+ return Object.keys(translations);
180
+ };
181
+
46
182
  // src/lang/index.ts
47
- var translations = {};
48
183
  var getLang = () => {
49
- if (!navigator?.languages) return;
50
- const supportedLang = navigator.languages.find((l) => translations[l] != void 0) ?? "";
51
- return translations[supportedLang];
184
+ return getTranslations();
52
185
  };
53
186
  var replaceParams = (str, params) => {
54
- let replaced = str;
55
- for (const [key, value] of Object.entries(params ?? {})) replaced = str.replace(`:${key}`, value);
56
- return replaced;
187
+ if (!params) return str;
188
+ let result = str;
189
+ for (const [key, value] of Object.entries(params)) {
190
+ result = result.replace(`:${key}`, value);
191
+ }
192
+ return result;
57
193
  };
58
- function __(str, params) {
59
- if (typeof navigator === "undefined") return str;
60
- return replaceParams(getLang()?.[str] ?? str, params);
194
+ function __(str, ...args) {
195
+ const [params] = args;
196
+ if (typeof navigator === "undefined" && typeof window === "undefined") {
197
+ return replaceParams(str, params);
198
+ }
199
+ const translated = getLang()?.[str] ?? str;
200
+ return replaceParams(translated, params);
61
201
  }
62
202
 
63
203
  // src/store/idkit.ts
@@ -1703,25 +1843,36 @@ var WarningIcon_default = WarningIcon;
1703
1843
  // src/components/IDKitWidget/States/ErrorState.tsx
1704
1844
  var import_jsx_runtime6 = require("react/jsx-runtime");
1705
1845
  var getParams = ({ retryFlow, errorState }) => ({ retryFlow, errorState });
1706
- var ERROR_TITLES = {
1707
- [import_idkit_core2.AppErrorCodes.GenericError]: __("Something went wrong"),
1708
- [import_idkit_core2.AppErrorCodes.FailedByHostApp]: __("Verification Declined"),
1709
- [import_idkit_core2.AppErrorCodes.VerificationRejected]: __("Request cancelled")
1846
+ var getErrorTitle = (code) => {
1847
+ switch (code) {
1848
+ case import_idkit_core2.AppErrorCodes.GenericError:
1849
+ return __("Something went wrong");
1850
+ case import_idkit_core2.AppErrorCodes.FailedByHostApp:
1851
+ return __("Verification Declined");
1852
+ case import_idkit_core2.AppErrorCodes.VerificationRejected:
1853
+ return __("Request cancelled");
1854
+ default:
1855
+ return __("Something went wrong");
1856
+ }
1710
1857
  };
1711
- var ERROR_MESSAGES = {
1712
- [import_idkit_core2.AppErrorCodes.ConnectionFailed]: __("Connection to your wallet failed. Please try again."),
1713
- [import_idkit_core2.AppErrorCodes.VerificationRejected]: __("You\u2019ve cancelled the request in World App."),
1714
- [import_idkit_core2.AppErrorCodes.MaxVerificationsReached]: __(
1715
- "You have already verified the maximum number of times for this action."
1716
- ),
1717
- [import_idkit_core2.AppErrorCodes.CredentialUnavailable]: __("It seems you do not have the verification level required by this app."),
1718
- [import_idkit_core2.AppErrorCodes.InvalidNetwork]: __(
1719
- "Invalid network. If you are the app owner, visit docs.world.org/test for details."
1720
- ),
1721
- [import_idkit_core2.AppErrorCodes.InclusionProofPending]: __(
1722
- "Your identity is still being registered. Please wait a few minutes and try again."
1723
- ),
1724
- [import_idkit_core2.AppErrorCodes.GenericError]: __("We couldn't complete your request. Please try again.")
1858
+ var getErrorMessage = (code) => {
1859
+ switch (code) {
1860
+ case import_idkit_core2.AppErrorCodes.ConnectionFailed:
1861
+ return __("Connection to your wallet failed. Please try again.");
1862
+ case import_idkit_core2.AppErrorCodes.VerificationRejected:
1863
+ return __("You've cancelled the request in World App.");
1864
+ case import_idkit_core2.AppErrorCodes.MaxVerificationsReached:
1865
+ return __("You've already verified the maximum number of times for this action.");
1866
+ case import_idkit_core2.AppErrorCodes.CredentialUnavailable:
1867
+ return __("It seems you don't have the verification level required by this app.");
1868
+ case import_idkit_core2.AppErrorCodes.InvalidNetwork:
1869
+ return __("Invalid network. If you are the app owner, visit docs.world.org/test for details.");
1870
+ case import_idkit_core2.AppErrorCodes.InclusionProofPending:
1871
+ return __("Your identity is still being registered. Please wait a few minutes and try again.");
1872
+ case import_idkit_core2.AppErrorCodes.GenericError:
1873
+ default:
1874
+ return __("We couldn't complete your request. Please try again.");
1875
+ }
1725
1876
  };
1726
1877
  var ErrorState = (props) => {
1727
1878
  const { retryFlow, errorState } = idkit_default(getParams);
@@ -1734,8 +1885,8 @@ var ErrorState = (props) => {
1734
1885
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-8", children: [
1735
1886
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: clsx_default("flex items-center justify-center", show_modal ? "-mt-5" : ""), children: errorState?.code == import_idkit_core2.AppErrorCodes.VerificationRejected ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WarningIcon_default, { className: "w-24" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorIcon_default, { className: "w-24" }) }),
1736
1887
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1737
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children: (errorState?.code && ERROR_TITLES[errorState.code]) ?? ERROR_TITLES[import_idkit_core2.AppErrorCodes.GenericError] }),
1738
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-657080", children: (errorState?.code && ERROR_MESSAGES[errorState.code]) ?? ERROR_MESSAGES[import_idkit_core2.AppErrorCodes.GenericError] })
1888
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children: errorState?.code ? getErrorTitle(errorState.code) : getErrorTitle(import_idkit_core2.AppErrorCodes.GenericError) }),
1889
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-657080", children: errorState?.code ? getErrorMessage(errorState.code) : getErrorMessage(import_idkit_core2.AppErrorCodes.GenericError) })
1739
1890
  ] }),
1740
1891
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1741
1892
  "button",
@@ -2245,7 +2396,8 @@ var WorldIDState = (props) => {
2245
2396
  /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: clsx_default(!show_modal ? "hidden" : ""), children: [
2246
2397
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "mb-4 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex size-14 items-center justify-center rounded-full border-[1.2px] border-solid border-[#EBECEF]", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(WorldcoinIcon_default, { className: "size-8 text-0d151d dark:text-white" }) }) }),
2247
2398
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-2xl font-semibold text-gray-900 dark:text-white", children: __("Connect your World ID") }),
2248
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media === "mobile" }), children: __("Use phone camera to scan the QR code") })
2399
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media === "mobile" }), children: __("Use phone camera to scan the QR code") }),
2400
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media !== "mobile" }), children: __("You will be redirected to the app, please return to this page once you're done") })
2249
2401
  ] }),
2250
2402
  /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative w-full", children: [
2251
2403
  verificationState === import_idkit_core4.VerificationState.WaitingForApp && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "absolute inset-0 flex flex-col items-center justify-center space-y-6", children: [
@@ -2303,10 +2455,16 @@ var IDKitWidget = ({
2303
2455
  show_modal = true,
2304
2456
  container_id,
2305
2457
  disable_default_modal_behavior = false,
2458
+ language,
2306
2459
  ...config
2307
2460
  }) => {
2308
2461
  const media = useMedia_default();
2309
2462
  const { isOpen, onOpenChange, stage, setStage, setOptions, setErrorState } = idkit_default(getParams2, import_shallow3.shallow);
2463
+ (0, import_react9.useEffect)(() => {
2464
+ if (language) {
2465
+ setLocalizationConfig({ language });
2466
+ }
2467
+ }, [language]);
2310
2468
  (0, import_react9.useEffect)(() => {
2311
2469
  if (config.action === "") {
2312
2470
  throw new Error(__("Action cannot be an empty string."));
@@ -2324,7 +2482,7 @@ var IDKitWidget = ({
2324
2482
  case "HOST_APP_VERIFICATION" /* HOST_APP_VERIFICATION */:
2325
2483
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HostAppVerificationState_default, {});
2326
2484
  default:
2327
- throw new Error(__("Invalid IDKitStage :stage.", { stage }));
2485
+ throw new Error(__("Invalid IDKitStage :stage.", { s: String(stage) }));
2328
2486
  }
2329
2487
  }, [stage, show_modal]);
2330
2488
  const widgetContent = /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(ShadowHost, { mode: "open", id: "idkit-widget", children: [
@@ -2469,6 +2627,10 @@ function useSession(config) {
2469
2627
  IDKitWidget,
2470
2628
  VerificationLevel,
2471
2629
  VerificationState,
2630
+ getCurrentLanguage,
2631
+ getLocalizationConfig,
2632
+ getSupportedLanguages,
2633
+ setLocalizationConfig,
2472
2634
  solidityEncode,
2473
2635
  useIDKit,
2474
2636
  useSession,
package/build/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { C as Config, W as WidgetProps } from './config-BRFx4nLT.cjs';
1
+ import { C as Config, W as WidgetProps } from './config-SH5TbLYj.cjs';
2
+ export { S as SupportedLanguage, a as getCurrentLanguage, g as getLocalizationConfig, b as getSupportedLanguages, s as setLocalizationConfig } from './config-SH5TbLYj.cjs';
2
3
  import * as react from 'react';
3
4
  export { solidityEncode } from '@worldcoin/idkit-core/hashing';
4
5
  export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
package/build/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { C as Config, W as WidgetProps } from './config-BRFx4nLT.js';
1
+ import { C as Config, W as WidgetProps } from './config-SH5TbLYj.js';
2
+ export { S as SupportedLanguage, a as getCurrentLanguage, g as getLocalizationConfig, b as getSupportedLanguages, s as setLocalizationConfig } from './config-SH5TbLYj.js';
2
3
  import * as react from 'react';
3
4
  export { solidityEncode } from '@worldcoin/idkit-core/hashing';
4
5
  export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
package/build/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import {
2
2
  QRCode_default,
3
3
  __,
4
- idkit_default
5
- } from "./chunk-3HCETHXP.js";
4
+ getCurrentLanguage,
5
+ getLocalizationConfig,
6
+ getSupportedLanguages,
7
+ idkit_default,
8
+ setLocalizationConfig
9
+ } from "./chunk-PWFTYFSZ.js";
6
10
 
7
11
  // src/hooks/useIDKit.ts
8
12
  import { useEffect } from "react";
@@ -1504,25 +1508,36 @@ var WarningIcon_default = WarningIcon;
1504
1508
  // src/components/IDKitWidget/States/ErrorState.tsx
1505
1509
  import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
1506
1510
  var getParams = ({ retryFlow, errorState }) => ({ retryFlow, errorState });
1507
- var ERROR_TITLES = {
1508
- [AppErrorCodes.GenericError]: __("Something went wrong"),
1509
- [AppErrorCodes.FailedByHostApp]: __("Verification Declined"),
1510
- [AppErrorCodes.VerificationRejected]: __("Request cancelled")
1511
+ var getErrorTitle = (code) => {
1512
+ switch (code) {
1513
+ case AppErrorCodes.GenericError:
1514
+ return __("Something went wrong");
1515
+ case AppErrorCodes.FailedByHostApp:
1516
+ return __("Verification Declined");
1517
+ case AppErrorCodes.VerificationRejected:
1518
+ return __("Request cancelled");
1519
+ default:
1520
+ return __("Something went wrong");
1521
+ }
1511
1522
  };
1512
- var ERROR_MESSAGES = {
1513
- [AppErrorCodes.ConnectionFailed]: __("Connection to your wallet failed. Please try again."),
1514
- [AppErrorCodes.VerificationRejected]: __("You\u2019ve cancelled the request in World App."),
1515
- [AppErrorCodes.MaxVerificationsReached]: __(
1516
- "You have already verified the maximum number of times for this action."
1517
- ),
1518
- [AppErrorCodes.CredentialUnavailable]: __("It seems you do not have the verification level required by this app."),
1519
- [AppErrorCodes.InvalidNetwork]: __(
1520
- "Invalid network. If you are the app owner, visit docs.world.org/test for details."
1521
- ),
1522
- [AppErrorCodes.InclusionProofPending]: __(
1523
- "Your identity is still being registered. Please wait a few minutes and try again."
1524
- ),
1525
- [AppErrorCodes.GenericError]: __("We couldn't complete your request. Please try again.")
1523
+ var getErrorMessage = (code) => {
1524
+ switch (code) {
1525
+ case AppErrorCodes.ConnectionFailed:
1526
+ return __("Connection to your wallet failed. Please try again.");
1527
+ case AppErrorCodes.VerificationRejected:
1528
+ return __("You've cancelled the request in World App.");
1529
+ case AppErrorCodes.MaxVerificationsReached:
1530
+ return __("You've already verified the maximum number of times for this action.");
1531
+ case AppErrorCodes.CredentialUnavailable:
1532
+ return __("It seems you don't have the verification level required by this app.");
1533
+ case AppErrorCodes.InvalidNetwork:
1534
+ return __("Invalid network. If you are the app owner, visit docs.world.org/test for details.");
1535
+ case AppErrorCodes.InclusionProofPending:
1536
+ return __("Your identity is still being registered. Please wait a few minutes and try again.");
1537
+ case AppErrorCodes.GenericError:
1538
+ default:
1539
+ return __("We couldn't complete your request. Please try again.");
1540
+ }
1526
1541
  };
1527
1542
  var ErrorState = (props) => {
1528
1543
  const { retryFlow, errorState } = idkit_default(getParams);
@@ -1535,8 +1550,8 @@ var ErrorState = (props) => {
1535
1550
  return /* @__PURE__ */ jsxs3("div", { className: "space-y-8", children: [
1536
1551
  /* @__PURE__ */ jsx6("div", { className: clsx_default("flex items-center justify-center", show_modal ? "-mt-5" : ""), children: errorState?.code == AppErrorCodes.VerificationRejected ? /* @__PURE__ */ jsx6(WarningIcon_default, { className: "w-24" }) : /* @__PURE__ */ jsx6(ErrorIcon_default, { className: "w-24" }) }),
1537
1552
  /* @__PURE__ */ jsxs3("div", { children: [
1538
- /* @__PURE__ */ jsx6("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children: (errorState?.code && ERROR_TITLES[errorState.code]) ?? ERROR_TITLES[AppErrorCodes.GenericError] }),
1539
- /* @__PURE__ */ jsx6("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-657080", children: (errorState?.code && ERROR_MESSAGES[errorState.code]) ?? ERROR_MESSAGES[AppErrorCodes.GenericError] })
1553
+ /* @__PURE__ */ jsx6("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children: errorState?.code ? getErrorTitle(errorState.code) : getErrorTitle(AppErrorCodes.GenericError) }),
1554
+ /* @__PURE__ */ jsx6("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-657080", children: errorState?.code ? getErrorMessage(errorState.code) : getErrorMessage(AppErrorCodes.GenericError) })
1540
1555
  ] }),
1541
1556
  /* @__PURE__ */ jsx6("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx6(
1542
1557
  "button",
@@ -1971,7 +1986,8 @@ var WorldIDState = (props) => {
1971
1986
  /* @__PURE__ */ jsxs9("div", { className: clsx_default(!show_modal ? "hidden" : ""), children: [
1972
1987
  /* @__PURE__ */ jsx13("div", { className: "mb-4 flex items-center justify-center", children: /* @__PURE__ */ jsx13("div", { className: "flex size-14 items-center justify-center rounded-full border-[1.2px] border-solid border-[#EBECEF]", children: /* @__PURE__ */ jsx13(WorldcoinIcon_default, { className: "size-8 text-0d151d dark:text-white" }) }) }),
1973
1988
  /* @__PURE__ */ jsx13("p", { className: "text-2xl font-semibold text-gray-900 dark:text-white", children: __("Connect your World ID") }),
1974
- /* @__PURE__ */ jsx13("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media === "mobile" }), children: __("Use phone camera to scan the QR code") })
1989
+ /* @__PURE__ */ jsx13("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media === "mobile" }), children: __("Use phone camera to scan the QR code") }),
1990
+ /* @__PURE__ */ jsx13("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media !== "mobile" }), children: __("You will be redirected to the app, please return to this page once you're done") })
1975
1991
  ] }),
1976
1992
  /* @__PURE__ */ jsxs9("div", { className: "relative w-full", children: [
1977
1993
  verificationState === VerificationState.WaitingForApp && /* @__PURE__ */ jsxs9("div", { className: "absolute inset-0 flex flex-col items-center justify-center space-y-6", children: [
@@ -2029,10 +2045,16 @@ var IDKitWidget = ({
2029
2045
  show_modal = true,
2030
2046
  container_id,
2031
2047
  disable_default_modal_behavior = false,
2048
+ language,
2032
2049
  ...config
2033
2050
  }) => {
2034
2051
  const media = useMedia_default();
2035
2052
  const { isOpen, onOpenChange, stage, setStage, setOptions, setErrorState } = idkit_default(getParams2, shallow2);
2053
+ useEffect7(() => {
2054
+ if (language) {
2055
+ setLocalizationConfig({ language });
2056
+ }
2057
+ }, [language]);
2036
2058
  useEffect7(() => {
2037
2059
  if (config.action === "") {
2038
2060
  throw new Error(__("Action cannot be an empty string."));
@@ -2050,7 +2072,7 @@ var IDKitWidget = ({
2050
2072
  case "HOST_APP_VERIFICATION" /* HOST_APP_VERIFICATION */:
2051
2073
  return /* @__PURE__ */ jsx15(HostAppVerificationState_default, {});
2052
2074
  default:
2053
- throw new Error(__("Invalid IDKitStage :stage.", { stage }));
2075
+ throw new Error(__("Invalid IDKitStage :stage.", { s: String(stage) }));
2054
2076
  }
2055
2077
  }, [stage, show_modal]);
2056
2078
  const widgetContent = /* @__PURE__ */ jsxs11(ShadowHost, { mode: "open", id: "idkit-widget", children: [
@@ -2194,6 +2216,10 @@ export {
2194
2216
  IDKitWidget_default as IDKitWidget,
2195
2217
  VerificationLevel2 as VerificationLevel,
2196
2218
  VerificationState3 as VerificationState,
2219
+ getCurrentLanguage,
2220
+ getLocalizationConfig,
2221
+ getSupportedLanguages,
2222
+ setLocalizationConfig,
2197
2223
  solidityEncode,
2198
2224
  useIDKit_default as useIDKit,
2199
2225
  useSession,
@@ -33,25 +33,165 @@ __export(internal_exports, {
33
33
  ConfigSource: () => ConfigSource,
34
34
  QRCode: () => QRCode_default,
35
35
  __: () => __,
36
+ getCurrentLanguage: () => getCurrentLanguage,
37
+ getLocalizationConfig: () => getLocalizationConfig,
38
+ getSupportedLanguages: () => getSupportedLanguages,
39
+ setLocalizationConfig: () => setLocalizationConfig,
36
40
  useIDKitStore: () => idkit_default
37
41
  });
38
42
  module.exports = __toCommonJS(internal_exports);
39
43
 
44
+ // src/lang/translations/en.ts
45
+ var en = {
46
+ "All set!": "All set!",
47
+ "Your World ID is now connected": "Your World ID is now connected",
48
+ "Transmitting verification to host app. Please wait...": "Transmitting verification to host app. Please wait...",
49
+ "Something went wrong": "Something went wrong",
50
+ "Verification Declined": "Verification Declined",
51
+ "Request cancelled": "Request cancelled",
52
+ "Connection to your wallet failed. Please try again.": "Connection to your wallet failed. Please try again.",
53
+ "You've cancelled the request in World App.": "You've cancelled the request in World App.",
54
+ "You have already verified the maximum number of times for this action.": "You have already verified the maximum number of times for this action.",
55
+ "It seems you do not have the verification level required by this app.": "It seems you do not have the verification level required by this app.",
56
+ "Invalid network. If you are the app owner, visit docs.world.org/test for details.": "Invalid network. If you are the app owner, visit docs.world.org/test for details.",
57
+ "Your identity is still being registered. Please wait a few minutes and try again.": "Your identity is still being registered. Please wait a few minutes and try again.",
58
+ "We couldn't complete your request. Please try again.": "We couldn't complete your request. Please try again.",
59
+ "Try Again": "Try Again",
60
+ "Open World App": "Open World App",
61
+ "Hide QR Code": "Hide QR Code",
62
+ "Display QR Code": "Display QR Code",
63
+ "QR Code copied": "QR Code copied",
64
+ "Connect your World ID": "Connect your World ID",
65
+ "Use phone camera to scan the QR code": "Use phone camera to scan the QR code",
66
+ "Connecting...": "Connecting...",
67
+ "Please continue in app": "Please continue in app",
68
+ "You will be redirected to the app, please return to this page once you're done": "You will be redirected to the app, please return to this page once you're done",
69
+ "Action cannot be an empty string.": "Action cannot be an empty string.",
70
+ "Invalid IDKitStage :stage.": "Invalid IDKitStage :stage.",
71
+ "Terms & Privacy": "Terms & Privacy"
72
+ };
73
+
74
+ // src/lang/translations/es.ts
75
+ var es = {
76
+ "All set!": "\xA1Todo listo!",
77
+ "Your World ID is now connected": "Tu World ID ahora est\xE1 conectado",
78
+ "Transmitting verification to host app. Please wait...": "Transmitiendo verificaci\xF3n a la aplicaci\xF3n host. Por favor espera...",
79
+ "Something went wrong": "Algo sali\xF3 mal",
80
+ "Verification Declined": "Verificaci\xF3n rechazada",
81
+ "Request cancelled": "Solicitud cancelada",
82
+ "Connection to your wallet failed. Please try again.": "La conexi\xF3n a tu billetera fall\xF3. Por favor intenta de nuevo.",
83
+ "You've cancelled the request in World App.": "Has cancelado la solicitud en World App.",
84
+ "You have already verified the maximum number of times for this action.": "Ya has verificado el n\xFAmero m\xE1ximo de veces para esta acci\xF3n.",
85
+ "It seems you do not have the verification level required by this app.": "Parece que no tienes el nivel de verificaci\xF3n requerido por esta aplicaci\xF3n.",
86
+ "Invalid network. If you are the app owner, visit docs.world.org/test for details.": "Red inv\xE1lida. Si eres el propietario de la aplicaci\xF3n, visita docs.world.org/test para m\xE1s detalles.",
87
+ "Your identity is still being registered. Please wait a few minutes and try again.": "Tu identidad a\xFAn se est\xE1 registrando. Por favor espera unos minutos e intenta de nuevo.",
88
+ "We couldn't complete your request. Please try again.": "No pudimos completar tu solicitud. Por favor intenta de nuevo.",
89
+ "Try Again": "Intentar de nuevo",
90
+ "Open World App": "Abrir World App",
91
+ "Hide QR Code": "Ocultar c\xF3digo QR",
92
+ "Display QR Code": "Mostrar c\xF3digo QR",
93
+ "QR Code copied": "C\xF3digo QR copiado",
94
+ "Connect your World ID": "Conecta tu World ID",
95
+ "Use phone camera to scan the QR code": "Usa la c\xE1mara del tel\xE9fono para escanear el c\xF3digo QR",
96
+ "Connecting...": "Conectando...",
97
+ "Please continue in app": "Por favor contin\xFAa en la aplicaci\xF3n",
98
+ "You will be redirected to the app, please return to this page once you're done": "Ser\xE1s redirigido a la aplicaci\xF3n, por favor regresa a esta p\xE1gina una vez que hayas terminado",
99
+ "Action cannot be an empty string.": "La acci\xF3n no puede ser una cadena vac\xEDa.",
100
+ "Invalid IDKitStage :stage.": "IDKitStage inv\xE1lido :stage.",
101
+ "Terms & Privacy": "T\xE9rminos y privacidad"
102
+ };
103
+
104
+ // src/lang/translations/th.ts
105
+ var th = {
106
+ "All set!": "\u0E40\u0E23\u0E35\u0E22\u0E1A\u0E23\u0E49\u0E2D\u0E22!",
107
+ "Your World ID is now connected": "World ID \u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E41\u0E25\u0E49\u0E27",
108
+ "Transmitting verification to host app. Please wait...": "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E2A\u0E48\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E44\u0E1B\u0E22\u0E31\u0E07\u0E41\u0E2D\u0E1B\u0E42\u0E2E\u0E2A\u0E15\u0E4C \u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E2D\u0E2A\u0E31\u0E01\u0E04\u0E23\u0E39\u0E48...",
109
+ "Something went wrong": "\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14",
110
+ "Verification Declined": "\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E16\u0E39\u0E01\u0E1B\u0E0F\u0E34\u0E40\u0E2A\u0E18",
111
+ "Request cancelled": "\u0E04\u0E33\u0E02\u0E2D\u0E16\u0E39\u0E01\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",
112
+ "Connection to your wallet failed. Please try again.": "\u0E01\u0E32\u0E23\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E01\u0E31\u0E1A\u0E01\u0E23\u0E30\u0E40\u0E1B\u0E4B\u0E32\u0E40\u0E07\u0E34\u0E19\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E25\u0E49\u0E21\u0E40\u0E2B\u0E25\u0E27 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
113
+ "You've cancelled the request in World App.": "\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01\u0E04\u0E33\u0E02\u0E2D\u0E43\u0E19 World App",
114
+ "You have already verified the maximum number of times for this action.": "\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E04\u0E23\u0E1A\u0E08\u0E33\u0E19\u0E27\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E19\u0E35\u0E49\u0E41\u0E25\u0E49\u0E27",
115
+ "It seems you do not have the verification level required by this app.": "\u0E14\u0E39\u0E40\u0E2B\u0E21\u0E37\u0E2D\u0E19\u0E27\u0E48\u0E32\u0E04\u0E38\u0E13\u0E44\u0E21\u0E48\u0E21\u0E35\u0E23\u0E30\u0E14\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E2D\u0E1B\u0E19\u0E35\u0E49\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23",
116
+ "Invalid network. If you are the app owner, visit docs.world.org/test for details.": "\u0E40\u0E04\u0E23\u0E37\u0E2D\u0E02\u0E48\u0E32\u0E22\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 \u0E2B\u0E32\u0E01\u0E04\u0E38\u0E13\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E08\u0E49\u0E32\u0E02\u0E2D\u0E07\u0E41\u0E2D\u0E1B \u0E42\u0E1B\u0E23\u0E14\u0E44\u0E1B\u0E17\u0E35\u0E48 docs.world.org/test \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E23\u0E32\u0E22\u0E25\u0E30\u0E40\u0E2D\u0E35\u0E22\u0E14",
117
+ "Your identity is still being registered. Please wait a few minutes and try again.": "\u0E15\u0E31\u0E27\u0E15\u0E19\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E22\u0E31\u0E07\u0E2D\u0E22\u0E39\u0E48\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E01\u0E32\u0E23\u0E25\u0E07\u0E17\u0E30\u0E40\u0E1A\u0E35\u0E22\u0E19 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E2D\u0E2A\u0E31\u0E01\u0E04\u0E23\u0E39\u0E48\u0E41\u0E25\u0E49\u0E27\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
118
+ "We couldn't complete your request. Please try again.": "\u0E40\u0E23\u0E32\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E15\u0E32\u0E21\u0E04\u0E33\u0E02\u0E2D\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E44\u0E14\u0E49 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
119
+ "Try Again": "\u0E25\u0E2D\u0E07\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07",
120
+ "Open World App": "\u0E40\u0E1B\u0E34\u0E14 World App",
121
+ "Hide QR Code": "\u0E0B\u0E48\u0E2D\u0E19 QR Code",
122
+ "Display QR Code": "\u0E41\u0E2A\u0E14\u0E07 QR Code",
123
+ "QR Code copied": "\u0E04\u0E31\u0E14\u0E25\u0E2D\u0E01 QR Code \u0E41\u0E25\u0E49\u0E27",
124
+ "Connect your World ID": "\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D World ID \u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13",
125
+ "Use phone camera to scan the QR code": "\u0E43\u0E0A\u0E49\u0E01\u0E25\u0E49\u0E2D\u0E07\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E40\u0E1E\u0E37\u0E48\u0E2D\u0E2A\u0E41\u0E01\u0E19 QR code",
126
+ "Connecting...": "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D...",
127
+ "Please continue in app": "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E15\u0E48\u0E2D\u0E43\u0E19\u0E41\u0E2D\u0E1B",
128
+ "You will be redirected to the app, please return to this page once you're done": "\u0E04\u0E38\u0E13\u0E08\u0E30\u0E16\u0E39\u0E01\u0E19\u0E33\u0E44\u0E1B\u0E22\u0E31\u0E07\u0E41\u0E2D\u0E1B \u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E25\u0E31\u0E1A\u0E21\u0E32\u0E17\u0E35\u0E48\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49\u0E40\u0E21\u0E37\u0E48\u0E2D\u0E40\u0E2A\u0E23\u0E47\u0E08\u0E41\u0E25\u0E49\u0E27",
129
+ "Action cannot be an empty string.": "\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E27\u0E48\u0E32\u0E07\u0E44\u0E14\u0E49",
130
+ "Invalid IDKitStage :stage.": "IDKitStage \u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 :stage.",
131
+ "Terms & Privacy": "\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E41\u0E25\u0E30\u0E04\u0E27\u0E32\u0E21\u0E40\u0E1B\u0E47\u0E19\u0E2A\u0E48\u0E27\u0E19\u0E15\u0E31\u0E27"
132
+ };
133
+
134
+ // src/lang/translations/index.ts
135
+ var translations = {
136
+ en,
137
+ es,
138
+ th
139
+ };
140
+
141
+ // src/lang/localization.ts
142
+ var currentConfig = {};
143
+ var setLocalizationConfig = (config) => {
144
+ currentConfig = config;
145
+ };
146
+ var getLocalizationConfig = () => currentConfig;
147
+ var detectBrowserLanguage = () => {
148
+ for (const lang of navigator.languages) {
149
+ const [language] = lang.split("-");
150
+ const normalizedLang = language.toLowerCase();
151
+ if (normalizedLang in translations) {
152
+ return normalizedLang;
153
+ }
154
+ }
155
+ return void 0;
156
+ };
157
+ var getCurrentLanguage = () => {
158
+ const config = getLocalizationConfig();
159
+ if (config.language && config.language in translations) {
160
+ return config.language;
161
+ }
162
+ const browserLang = detectBrowserLanguage();
163
+ if (browserLang) {
164
+ return browserLang;
165
+ }
166
+ return "en";
167
+ };
168
+ var getTranslations = () => {
169
+ const currentLang = getCurrentLanguage();
170
+ return translations[currentLang];
171
+ };
172
+ var getSupportedLanguages = () => {
173
+ return Object.keys(translations);
174
+ };
175
+
40
176
  // src/lang/index.ts
41
- var translations = {};
42
177
  var getLang = () => {
43
- if (!navigator?.languages) return;
44
- const supportedLang = navigator.languages.find((l) => translations[l] != void 0) ?? "";
45
- return translations[supportedLang];
178
+ return getTranslations();
46
179
  };
47
180
  var replaceParams = (str, params) => {
48
- let replaced = str;
49
- for (const [key, value] of Object.entries(params ?? {})) replaced = str.replace(`:${key}`, value);
50
- return replaced;
181
+ if (!params) return str;
182
+ let result = str;
183
+ for (const [key, value] of Object.entries(params)) {
184
+ result = result.replace(`:${key}`, value);
185
+ }
186
+ return result;
51
187
  };
52
- function __(str, params) {
53
- if (typeof navigator === "undefined") return str;
54
- return replaceParams(getLang()?.[str] ?? str, params);
188
+ function __(str, ...args) {
189
+ const [params] = args;
190
+ if (typeof navigator === "undefined" && typeof window === "undefined") {
191
+ return replaceParams(str, params);
192
+ }
193
+ const translated = getLang()?.[str] ?? str;
194
+ return replaceParams(translated, params);
55
195
  }
56
196
 
57
197
  // src/components/QRCode.tsx
@@ -265,5 +405,9 @@ var ConfigSource = /* @__PURE__ */ ((ConfigSource2) => {
265
405
  ConfigSource,
266
406
  QRCode,
267
407
  __,
408
+ getCurrentLanguage,
409
+ getLocalizationConfig,
410
+ getSupportedLanguages,
411
+ setLocalizationConfig,
268
412
  useIDKitStore
269
413
  });