@koine/i18n 2.0.0-beta.110 → 2.0.0-beta.111

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.
Files changed (3) hide show
  1. package/api.cjs.js +11 -5
  2. package/api.esm.js +11 -5
  3. package/package.json +3 -3
package/api.cjs.js CHANGED
@@ -1947,9 +1947,10 @@ export const I18nLayout = async ({
1947
1947
  export default I18nLayout;
1948
1948
  `);
1949
1949
 
1950
- var i$4 = (({ config: { single: t }, options: { routes: { localeParamName: a } } })=>`
1950
+ var i$4 = (({ config: { single: a }, options: { routes: { localeParamName: t } } })=>`
1951
1951
  /* eslint-disable @typescript-eslint/no-explicit-any */
1952
1952
  import { notFound } from "next/navigation";
1953
+ import type { Metadata } from "next/types";
1953
1954
  import { I18nMetadataSetter } from "./I18nMetadataSetter";
1954
1955
  import { I18nProvider } from "./I18nProvider";
1955
1956
  import { I18nRouteSetter } from "./I18nRouteSetter";
@@ -1964,7 +1965,7 @@ ${getI18nDictionaries_inline()}
1964
1965
  export type I18nPageProps<TRouteId extends I18n.RouteId> =
1965
1966
  React.PropsWithChildren<
1966
1967
  {
1967
- locale${t ? "?" : ""}: I18n.Locale;
1968
+ locale${a ? "?" : ""}: I18n.Locale;
1968
1969
  namespaces?: I18n.TranslateNamespace[];
1969
1970
  } & I18n.RouteArgs<TRouteId>
1970
1971
  >;
@@ -2008,7 +2009,7 @@ function locale(props: I18n.Props): I18n.Locale;
2008
2009
  function locale(paramsOrProps: I18n.Props["params"] | I18n.Props) {
2009
2010
  const params = (paramsOrProps as any)?.params || paramsOrProps;
2010
2011
  if (params) {
2011
- const locale = (params as any).${a};
2012
+ const locale = (params as any).${t};
2012
2013
 
2013
2014
  if (isLocale(locale)) {
2014
2015
  return locale;
@@ -2034,14 +2035,19 @@ I18nPage.locale = locale;
2034
2035
  */
2035
2036
  I18nPage.metadata = <TRouteId extends I18n.RouteId>(
2036
2037
  options: Omit<I18nPageProps<TRouteId>, "namespaces">,
2038
+ metadata?: Metadata,
2037
2039
  ) => {
2040
+ const { alternates: alternatesOverride, ...restMetadata } = metadata || {};
2041
+ const { canonical: canonicalOverride, languages: languagesOverride = {} } =
2042
+ alternatesOverride || {};
2038
2043
  // @ts-expect-error FIXME: route conditional type
2039
2044
  const { alternates, canonical } = getI18nMetadata(options);
2040
2045
 
2041
2046
  return {
2047
+ ...restMetadata,
2042
2048
  alternates: {
2043
- canonical,
2044
- languages: alternates,
2049
+ canonical: canonicalOverride || canonical,
2050
+ languages: { ...alternates, ...languagesOverride },
2045
2051
  },
2046
2052
  };
2047
2053
  };
package/api.esm.js CHANGED
@@ -1925,9 +1925,10 @@ export const I18nLayout = async ({
1925
1925
  export default I18nLayout;
1926
1926
  `);
1927
1927
 
1928
- var i$4 = (({ config: { single: t }, options: { routes: { localeParamName: a } } })=>`
1928
+ var i$4 = (({ config: { single: a }, options: { routes: { localeParamName: t } } })=>`
1929
1929
  /* eslint-disable @typescript-eslint/no-explicit-any */
1930
1930
  import { notFound } from "next/navigation";
1931
+ import type { Metadata } from "next/types";
1931
1932
  import { I18nMetadataSetter } from "./I18nMetadataSetter";
1932
1933
  import { I18nProvider } from "./I18nProvider";
1933
1934
  import { I18nRouteSetter } from "./I18nRouteSetter";
@@ -1942,7 +1943,7 @@ ${getI18nDictionaries_inline()}
1942
1943
  export type I18nPageProps<TRouteId extends I18n.RouteId> =
1943
1944
  React.PropsWithChildren<
1944
1945
  {
1945
- locale${t ? "?" : ""}: I18n.Locale;
1946
+ locale${a ? "?" : ""}: I18n.Locale;
1946
1947
  namespaces?: I18n.TranslateNamespace[];
1947
1948
  } & I18n.RouteArgs<TRouteId>
1948
1949
  >;
@@ -1986,7 +1987,7 @@ function locale(props: I18n.Props): I18n.Locale;
1986
1987
  function locale(paramsOrProps: I18n.Props["params"] | I18n.Props) {
1987
1988
  const params = (paramsOrProps as any)?.params || paramsOrProps;
1988
1989
  if (params) {
1989
- const locale = (params as any).${a};
1990
+ const locale = (params as any).${t};
1990
1991
 
1991
1992
  if (isLocale(locale)) {
1992
1993
  return locale;
@@ -2012,14 +2013,19 @@ I18nPage.locale = locale;
2012
2013
  */
2013
2014
  I18nPage.metadata = <TRouteId extends I18n.RouteId>(
2014
2015
  options: Omit<I18nPageProps<TRouteId>, "namespaces">,
2016
+ metadata?: Metadata,
2015
2017
  ) => {
2018
+ const { alternates: alternatesOverride, ...restMetadata } = metadata || {};
2019
+ const { canonical: canonicalOverride, languages: languagesOverride = {} } =
2020
+ alternatesOverride || {};
2016
2021
  // @ts-expect-error FIXME: route conditional type
2017
2022
  const { alternates, canonical } = getI18nMetadata(options);
2018
2023
 
2019
2024
  return {
2025
+ ...restMetadata,
2020
2026
  alternates: {
2021
- canonical,
2022
- languages: alternates,
2027
+ canonical: canonicalOverride || canonical,
2028
+ languages: { ...alternates, ...languagesOverride },
2023
2029
  },
2024
2030
  };
2025
2031
  };
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@koine/i18n",
3
3
  "sideEffects": false,
4
4
  "dependencies": {
5
- "@koine/node": "2.0.0-beta.110",
6
- "@koine/utils": "2.0.0-beta.110",
5
+ "@koine/node": "2.0.0-beta.111",
6
+ "@koine/utils": "2.0.0-beta.111",
7
7
  "glob": "^10.3.10",
8
8
  "webpack": "^5.90.1",
9
9
  "minimatch": "^9.0.3",
@@ -58,5 +58,5 @@
58
58
  },
59
59
  "module": "./index.esm.js",
60
60
  "main": "./index.cjs.js",
61
- "version": "2.0.0-beta.110"
61
+ "version": "2.0.0-beta.111"
62
62
  }