mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
🆙 Added translation to the Catalog Text
This commit is contained in:
@@ -228,16 +228,6 @@ const resolveSupportedLanguage = (value: string, languages: ITranslationLanguage
|
||||
return languages[0].code;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal singleton state + actions hook. Public consumers should
|
||||
* call useTranslationState (read-only) or useTranslationActions
|
||||
* (imperative) instead. useTranslation is the deprecated shim that
|
||||
* composes both.
|
||||
*
|
||||
* Wrapped in useBetween at each public-hook layer so every consumer
|
||||
* in the tree sees the same instance (preserves the previous
|
||||
* useBetween(useTranslationState) behavior).
|
||||
*/
|
||||
const useTranslationStore = () =>
|
||||
{
|
||||
const defaultTargetLanguage = getBrowserLanguageCode();
|
||||
@@ -599,6 +589,7 @@ const useTranslationStore = () =>
|
||||
lastError,
|
||||
updateSettings,
|
||||
ensureSupportedLanguagesLoaded,
|
||||
translateText,
|
||||
translateIncoming,
|
||||
translateOutgoing,
|
||||
enqueueOutgoingTranslation,
|
||||
@@ -607,14 +598,6 @@ const useTranslationStore = () =>
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Read-only slice of the translation store: persisted settings, the
|
||||
* supported languages list, the loading/loaded flags, the last
|
||||
* incoming/outgoing detected language tags, and the last error message
|
||||
* surfaced to the UI.
|
||||
*
|
||||
* Components that only render translation state subscribe here.
|
||||
*/
|
||||
export const useTranslationState = () =>
|
||||
{
|
||||
const {
|
||||
@@ -644,19 +627,13 @@ export const useTranslationState = () =>
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Imperative slice of the translation store: settings mutation,
|
||||
* supported-languages refresh, the translate* helpers, and the
|
||||
* outgoing-queue write/read pair. Stays separate so components that
|
||||
* only invoke actions (e.g. ChatInputActions) don't pull the full
|
||||
* state shape.
|
||||
*/
|
||||
export const useTranslationActions = () =>
|
||||
{
|
||||
const {
|
||||
settings,
|
||||
updateSettings,
|
||||
ensureSupportedLanguagesLoaded,
|
||||
translateText,
|
||||
translateIncoming,
|
||||
translateOutgoing,
|
||||
enqueueOutgoingTranslation,
|
||||
@@ -664,11 +641,10 @@ export const useTranslationActions = () =>
|
||||
} = useBetween(useTranslationStore);
|
||||
|
||||
return {
|
||||
// settings is exposed here too because most action call sites
|
||||
// need `if(settings.enabled)` checks before dispatching.
|
||||
settings,
|
||||
updateSettings,
|
||||
ensureSupportedLanguagesLoaded,
|
||||
translateText,
|
||||
translateIncoming,
|
||||
translateOutgoing,
|
||||
enqueueOutgoingTranslation,
|
||||
@@ -676,10 +652,4 @@ export const useTranslationActions = () =>
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated Prefer `useTranslationState` (read-only) and
|
||||
* `useTranslationActions` (imperative) directly. This shim composes
|
||||
* both into the historical `useTranslation()` shape so the six
|
||||
* existing consumers keep working unchanged.
|
||||
*/
|
||||
export const useTranslation = () => useBetween(useTranslationStore);
|
||||
|
||||
Reference in New Issue
Block a user