revojs 0.0.71 → 0.0.73
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/dist/index.js +5 -9
- package/dist/locale/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -887,18 +887,14 @@ const ROUTER_CONTEXT = defineContext("ROUTER_CONTEXT");
|
|
|
887
887
|
//#region src/locale/index.ts
|
|
888
888
|
function provideLocaleContext(scope, options) {
|
|
889
889
|
const { inputs } = useRoute(scope);
|
|
890
|
-
const { navigator } = useRouter(scope);
|
|
890
|
+
const { navigator, navigate } = useRouter(scope);
|
|
891
891
|
const locale = createState(options.defaultLocale);
|
|
892
892
|
const messages = createState();
|
|
893
893
|
const fetch$1 = () => {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
if (locale.value) {
|
|
899
|
-
const target = options.locales[locale.value];
|
|
900
|
-
messages.value = target;
|
|
901
|
-
}
|
|
894
|
+
const input = inputs.value[options.input];
|
|
895
|
+
if (input && input in options.locales) locale.value = input;
|
|
896
|
+
else navigate(`/${options.defaultLocale}`);
|
|
897
|
+
if (locale.value) messages.value = options.locales[locale.value];
|
|
902
898
|
};
|
|
903
899
|
fetch$1();
|
|
904
900
|
useEvent(scope, navigator, "afterNavigate", fetch$1);
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Descriptor, Scope, type State } from "../signals";
|
|
2
2
|
export type LocaleOptions = {
|
|
3
3
|
locales: Record<string, Record<string, string>>;
|
|
4
|
-
defaultLocale
|
|
5
|
-
input
|
|
4
|
+
defaultLocale: string;
|
|
5
|
+
input: string;
|
|
6
6
|
};
|
|
7
7
|
export type LocaleContext = {
|
|
8
8
|
locale: State<string | undefined>;
|