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 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
- if (options.input) {
895
- const input = inputs.value[options.input];
896
- if (input && input in options.locales) locale.value = input;
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);
@@ -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?: string;
5
- input?: string;
4
+ defaultLocale: string;
5
+ input: string;
6
6
  };
7
7
  export type LocaleContext = {
8
8
  locale: State<string | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",