@windrun-huaiin/lib 12.0.1 → 12.1.0

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.
@@ -47,7 +47,7 @@ export declare function createCommonAppConfig(options?: {
47
47
  i18n: {
48
48
  locales: readonly string[];
49
49
  defaultLocale: string;
50
- localPrefixAsNeeded: boolean;
50
+ localePrefixAsNeeded: boolean;
51
51
  localeLabels: {
52
52
  [k: string]: "English" | "简体中文" | "日本語" | "한국어" | "Français" | "Deutsch" | "Español" | "Italiano" | "Português" | "Türkçe" | "Polski" | "Русский" | "العربية" | "हिन्दी" | "ไทย" | "Tiếng Việt";
53
53
  };
@@ -43,7 +43,7 @@ function createCommonAppConfig(options) {
43
43
  i18n: {
44
44
  locales: locales,
45
45
  defaultLocale,
46
- localPrefixAsNeeded: process.env.NEXT_PUBLIC_I18N_LOCALE_PREFIX_AS_NEEDED !== 'false',
46
+ localePrefixAsNeeded: process.env.NEXT_PUBLIC_I18N_LOCALE_PREFIX_AS_NEEDED !== 'false',
47
47
  localeLabels: getLocaleLabels(locales),
48
48
  detector: {
49
49
  storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',
@@ -41,7 +41,7 @@ function createCommonAppConfig(options) {
41
41
  i18n: {
42
42
  locales: locales,
43
43
  defaultLocale,
44
- localPrefixAsNeeded: process.env.NEXT_PUBLIC_I18N_LOCALE_PREFIX_AS_NEEDED !== 'false',
44
+ localePrefixAsNeeded: process.env.NEXT_PUBLIC_I18N_LOCALE_PREFIX_AS_NEEDED !== 'false',
45
45
  localeLabels: getLocaleLabels(locales),
46
46
  detector: {
47
47
  storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',
package/dist/utils.d.ts CHANGED
@@ -4,5 +4,5 @@ export declare function cn(...inputs: ClassValue[]): string;
4
4
  export declare function viewLocalTime(origin: Date | null): string;
5
5
  export declare function formatTimestamp(timestamp: string, formatter: string): string;
6
6
  export declare function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>): void;
7
- export declare function getAsNeededLocalizedUrl(locale: string, path: string, localPrefixAsNeeded?: boolean, defaultLocale?: string): string;
7
+ export declare function getAsNeededLocalizedUrl(locale: string, path: string, localePrefixAsNeeded?: boolean, defaultLocale?: string): string;
8
8
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAI5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,UAEhD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UA4BnE;AAGD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,QAgBxE;AAkBD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,mBAAmB,GAAE,OAAc,EACnC,aAAa,GAAE,MAAa,GAC3B,MAAM,CAyBR"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAI5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,UAEhD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UA4BnE;AAGD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,QAgBxE;AAkBD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,oBAAoB,GAAE,OAAc,EACpC,aAAa,GAAE,MAAa,GAC3B,MAAM,CAyBR"}
package/dist/utils.js CHANGED
@@ -63,7 +63,7 @@ function handlePastePlainText(e) {
63
63
  // - All other paths have no trailing slash: '/blog', '/zh/blog', '/en'
64
64
  // @param locale - Current locale (e.g., 'en', 'zh', 'ja')
65
65
  // @param path - Base path (e.g., '/', '/blog', '/docs', or '' treated as '/')
66
- // @param localPrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
66
+ // @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
67
67
  // @param defaultLocale - The default locale for the application (default: 'en')
68
68
  // @example
69
69
  // getAsNeededLocalizedUrl('en', '/', true, 'en') // Returns '/'
@@ -72,7 +72,7 @@ function handlePastePlainText(e) {
72
72
  // getAsNeededLocalizedUrl('zh', '/blog', true, 'en') // Returns '/zh/blog'
73
73
  // getAsNeededLocalizedUrl('en', '/blog/', true, 'en') // Returns '/blog'
74
74
  // getAsNeededLocalizedUrl('en', '/', false, 'en') // Returns '/en'
75
- function getAsNeededLocalizedUrl(locale, path, localPrefixAsNeeded = true, defaultLocale = 'en') {
75
+ function getAsNeededLocalizedUrl(locale, path, localePrefixAsNeeded = true, defaultLocale = 'en') {
76
76
  // Normalize path: empty string or undefined treated as '/'
77
77
  let normalizedPath = (path || '/').trim();
78
78
  // Ensure path starts with '/'
@@ -84,7 +84,7 @@ function getAsNeededLocalizedUrl(locale, path, localPrefixAsNeeded = true, defau
84
84
  normalizedPath = normalizedPath.replace(/\/+$/, '');
85
85
  }
86
86
  // Return based on locale prefix configuration
87
- if (localPrefixAsNeeded && locale === defaultLocale) {
87
+ if (localePrefixAsNeeded && locale === defaultLocale) {
88
88
  return normalizedPath;
89
89
  }
90
90
  // Add locale prefix, but avoid double trailing slash when path is '/'
package/dist/utils.mjs CHANGED
@@ -61,7 +61,7 @@ function handlePastePlainText(e) {
61
61
  // - All other paths have no trailing slash: '/blog', '/zh/blog', '/en'
62
62
  // @param locale - Current locale (e.g., 'en', 'zh', 'ja')
63
63
  // @param path - Base path (e.g., '/', '/blog', '/docs', or '' treated as '/')
64
- // @param localPrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
64
+ // @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
65
65
  // @param defaultLocale - The default locale for the application (default: 'en')
66
66
  // @example
67
67
  // getAsNeededLocalizedUrl('en', '/', true, 'en') // Returns '/'
@@ -70,7 +70,7 @@ function handlePastePlainText(e) {
70
70
  // getAsNeededLocalizedUrl('zh', '/blog', true, 'en') // Returns '/zh/blog'
71
71
  // getAsNeededLocalizedUrl('en', '/blog/', true, 'en') // Returns '/blog'
72
72
  // getAsNeededLocalizedUrl('en', '/', false, 'en') // Returns '/en'
73
- function getAsNeededLocalizedUrl(locale, path, localPrefixAsNeeded = true, defaultLocale = 'en') {
73
+ function getAsNeededLocalizedUrl(locale, path, localePrefixAsNeeded = true, defaultLocale = 'en') {
74
74
  // Normalize path: empty string or undefined treated as '/'
75
75
  let normalizedPath = (path || '/').trim();
76
76
  // Ensure path starts with '/'
@@ -82,7 +82,7 @@ function getAsNeededLocalizedUrl(locale, path, localPrefixAsNeeded = true, defau
82
82
  normalizedPath = normalizedPath.replace(/\/+$/, '');
83
83
  }
84
84
  // Return based on locale prefix configuration
85
- if (localPrefixAsNeeded && locale === defaultLocale) {
85
+ if (localePrefixAsNeeded && locale === defaultLocale) {
86
86
  return normalizedPath;
87
87
  }
88
88
  // Add locale prefix, but avoid double trailing slash when path is '/'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/lib",
3
- "version": "12.0.1",
3
+ "version": "12.1.0",
4
4
  "description": "Common utilities and configuration",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -58,7 +58,7 @@ export function createCommonAppConfig(options?: {
58
58
  i18n: {
59
59
  locales: locales as readonly string[],
60
60
  defaultLocale,
61
- localPrefixAsNeeded: process.env.NEXT_PUBLIC_I18N_LOCALE_PREFIX_AS_NEEDED !== 'false',
61
+ localePrefixAsNeeded: process.env.NEXT_PUBLIC_I18N_LOCALE_PREFIX_AS_NEEDED !== 'false',
62
62
  localeLabels: getLocaleLabels(locales),
63
63
  detector: {
64
64
  storageKey: process.env.NEXT_PUBLIC_I18N_STORAGE_KEY || 'language-preference-status',
package/src/utils.ts CHANGED
@@ -67,7 +67,7 @@ export function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>) {
67
67
  // - All other paths have no trailing slash: '/blog', '/zh/blog', '/en'
68
68
  // @param locale - Current locale (e.g., 'en', 'zh', 'ja')
69
69
  // @param path - Base path (e.g., '/', '/blog', '/docs', or '' treated as '/')
70
- // @param localPrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
70
+ // @param localePrefixAsNeeded - Whether localePrefix is set to 'as-needed' (default: true)
71
71
  // @param defaultLocale - The default locale for the application (default: 'en')
72
72
  // @example
73
73
  // getAsNeededLocalizedUrl('en', '/', true, 'en') // Returns '/'
@@ -79,7 +79,7 @@ export function handlePastePlainText(e: React.ClipboardEvent<HTMLElement>) {
79
79
  export function getAsNeededLocalizedUrl(
80
80
  locale: string,
81
81
  path: string,
82
- localPrefixAsNeeded: boolean = true,
82
+ localePrefixAsNeeded: boolean = true,
83
83
  defaultLocale: string = 'en'
84
84
  ): string {
85
85
  // Normalize path: empty string or undefined treated as '/'
@@ -96,7 +96,7 @@ export function getAsNeededLocalizedUrl(
96
96
  }
97
97
 
98
98
  // Return based on locale prefix configuration
99
- if (localPrefixAsNeeded && locale === defaultLocale) {
99
+ if (localePrefixAsNeeded && locale === defaultLocale) {
100
100
  return normalizedPath;
101
101
  }
102
102