mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 04:00:09 +00:00
Initial commit of eigent-main
This commit is contained in:
commit
723df5a03e
1144 changed files with 103478 additions and 0 deletions
23
package/@stackframe/react/dist/esm/lib/translations.js
vendored
Normal file
23
package/@stackframe/react/dist/esm/lib/translations.js
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// src/lib/translations.tsx
|
||||
import React from "react";
|
||||
import { TranslationContext } from "../providers/translation-provider-client";
|
||||
function useTranslation() {
|
||||
const translationContext = React.useContext(TranslationContext);
|
||||
if (!translationContext) {
|
||||
throw new Error("Translation context not found; did you forget to wrap your app in a <StackProvider />?");
|
||||
}
|
||||
return {
|
||||
t: (str, templateVars) => {
|
||||
const { quetzalKeys, quetzalLocale } = translationContext;
|
||||
let translation = quetzalLocale.get(quetzalKeys.get(str) ?? void 0) ?? str;
|
||||
for (const [key, value] of Object.entries(templateVars || {})) {
|
||||
translation = translation.replace(`{${key}}`, value);
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
useTranslation
|
||||
};
|
||||
//# sourceMappingURL=translations.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue