@@ -25,6 +25,7 @@ import {
2525 parseDefaultHeader ,
2626 validateLocale
2727} from './http.ts'
28+ import { warnOnce } from './utils.ts'
2829
2930import type { Context } from 'hono'
3031import type { CookieLocaleOptions , HeaderOptions , PathOptions , QueryOptions } from './http.ts'
@@ -57,6 +58,10 @@ type CookieOptions = Parameters<typeof setCookie>[3] & { name?: string }
5758 * @returns An array of language tags, if you use `accept-language` header and `*` (any language) or empty string is detected, return an empty array.
5859 */
5960export function getHeaderLanguages ( context : Context , options : HeaderOptions = { } ) : string [ ] {
61+ warnOnce (
62+ '`getHeaderLanguages` of `@intlify/utils/hono` is deprecated in v2. Use `getHeaderLanguages` of `@intlify/utils` instead.'
63+ )
64+
6065 const { name = ACCEPT_LANGUAGE_HEADER } = options
6166 return getHeaderLanguagesWithGetter ( ( ) => context . req . header ( name ) , options )
6267}
@@ -87,6 +92,10 @@ export function getHeaderLanguages(context: Context, options: HeaderOptions = {}
8792 * @returns A **first language tag** of header, if header is not exists, or `*` (any language), return empty string.
8893 */
8994export function getHeaderLanguage ( context : Context , options : HeaderOptions = { } ) : string {
95+ warnOnce (
96+ '`getHeaderLanguage` of `@intlify/utils/hono` is deprecated in v2. Use `getHeaderLanguage` of `@intlify/utils` instead.'
97+ )
98+
9099 return getHeaderLanguages ( context , options ) [ 0 ] || ''
91100}
92101
@@ -118,6 +127,10 @@ export function getHeaderLanguage(context: Context, options: HeaderOptions = {})
118127 * @returns Some locales that wrapped from header, if you use `accept-language` header and `*` (any language) or empty string is detected, return an empty array.
119128 */
120129export function getHeaderLocales ( context : Context , options : HeaderOptions = { } ) : Intl . Locale [ ] {
130+ warnOnce (
131+ '`getHeaderLocales` of `@intlify/utils/hono` is deprecated in v2. Use `getHeaderLocales` of `@intlify/utils` instead.'
132+ )
133+
121134 return mapToLocaleFromLanguageTag ( getHeaderLanguages , context , options )
122135}
123136
@@ -135,6 +148,9 @@ export function tryHeaderLocales(
135148 context : Context ,
136149 options : HeaderOptions = { }
137150) : Intl . Locale [ ] | null {
151+ warnOnce (
152+ '`tryHeaderLocales` of `@intlify/utils/hono` is deprecated in v2. Use `tryHeaderLocales` of `@intlify/utils` instead.'
153+ )
138154 try {
139155 return getHeaderLocales ( context , options )
140156 } catch {
@@ -173,6 +189,10 @@ export function getHeaderLocale(
173189 context : Context ,
174190 options : HeaderOptions & { lang ?: string } = { }
175191) : Intl . Locale {
192+ warnOnce (
193+ '`getHeaderLocale` of `@intlify/utils/hono` is deprecated in v2. Use `getHeaderLocale` of `@intlify/utils` instead.'
194+ )
195+
176196 const {
177197 lang = DEFAULT_LANG_TAG ,
178198 name = ACCEPT_LANGUAGE_HEADER ,
@@ -195,6 +215,10 @@ export function tryHeaderLocale(
195215 context : Context ,
196216 options : HeaderOptions & { lang ?: string } = { }
197217) : Intl . Locale | null {
218+ warnOnce (
219+ '`tryHeaderLocale` of `@intlify/utils/hono` is deprecated in v2. Use `tryHeaderLocale` of `@intlify/utils` instead.'
220+ )
221+
198222 try {
199223 return getHeaderLocale ( context , options )
200224 } catch {
@@ -228,6 +252,10 @@ export function tryHeaderLocale(
228252 * @returns The locale that resolved from cookie
229253 */
230254export function getCookieLocale ( context : Context , options : CookieLocaleOptions = { } ) : Intl . Locale {
255+ warnOnce (
256+ '`getCookieLocale` of `@intlify/utils/hono` is deprecated in v2. Use `getCookieLocale` of `@intlify/utils` instead.'
257+ )
258+
231259 const { lang = DEFAULT_LANG_TAG , name = DEFAULT_COOKIE_NAME } = options
232260 return getLocaleWithGetter ( ( ) => getCookie ( context , name ) || lang )
233261}
@@ -246,6 +274,10 @@ export function tryCookieLocale(
246274 context : Context ,
247275 options : CookieLocaleOptions = { }
248276) : Intl . Locale | null {
277+ warnOnce (
278+ '`tryCookieLocale` of `@intlify/utils/hono` is deprecated in v2. Use `tryCookieLocale` of `@intlify/utils` instead.'
279+ )
280+
249281 try {
250282 return getCookieLocale ( context , options )
251283 } catch {
@@ -281,6 +313,10 @@ export function setCookieLocale(
281313 locale : string | Intl . Locale ,
282314 options : CookieOptions = { }
283315) : void {
316+ warnOnce (
317+ '`setCookieLocale` of `@intlify/utils/hono` is deprecated in v2. Use `setCookieLocale` of `@intlify/utils` instead.'
318+ )
319+
284320 const { name = DEFAULT_COOKIE_NAME } = options
285321 validateLocale ( locale )
286322 setCookie ( context , name , locale . toString ( ) , options )
@@ -297,6 +333,10 @@ export function setCookieLocale(
297333 * @returns The locale that resolved from path
298334 */
299335export function getPathLocale ( context : Context , options : PathOptions = { } ) : Intl . Locale {
336+ warnOnce (
337+ '`getPathLocale` of `@intlify/utils/hono` is deprecated in v2. Use `getPathLocale` of `@intlify/utils` instead.'
338+ )
339+
300340 return _getPathLocale ( new URL ( context . req . url ) , options )
301341}
302342
@@ -311,6 +351,10 @@ export function getPathLocale(context: Context, options: PathOptions = {}): Intl
311351 * @returns The locale that resolved from path. if the language in the path, that is not a well-formed BCP 47 language tag, return `null`.
312352 */
313353export function tryPathLocale ( context : Context , options : PathOptions = { } ) : Intl . Locale | null {
354+ warnOnce (
355+ '`tryPathLocale` of `@intlify/utils/hono` is deprecated in v2. Use `tryPathLocale` of `@intlify/utils` instead.'
356+ )
357+
314358 try {
315359 return getPathLocale ( context , options )
316360 } catch {
@@ -329,6 +373,10 @@ export function tryPathLocale(context: Context, options: PathOptions = {}): Intl
329373 * @returns The locale that resolved from query
330374 */
331375export function getQueryLocale ( context : Context , options : QueryOptions = { } ) : Intl . Locale {
376+ warnOnce (
377+ '`getQueryLocale` of `@intlify/utils/hono` is deprecated in v2. Use `getQueryLocale` of `@intlify/utils` instead.'
378+ )
379+
332380 const { lang = DEFAULT_LANG_TAG , name = 'locale' } = options
333381 return _getQueryLocale ( new URL ( context . req . url ) , { lang, name } )
334382}
@@ -344,6 +392,10 @@ export function getQueryLocale(context: Context, options: QueryOptions = {}): In
344392 * @returns The locale that resolved from query. if the language in the query, that is not a well-formed BCP 47 language tag, return `null`.
345393 */
346394export function tryQueryLocale ( context : Context , options : QueryOptions = { } ) : Intl . Locale | null {
395+ warnOnce (
396+ '`tryQueryLocale` of `@intlify/utils/hono` is deprecated in v2. Use `tryQueryLocale` of `@intlify/utils` instead.'
397+ )
398+
347399 const { lang = DEFAULT_LANG_TAG , name = 'locale' } = options
348400 try {
349401 return getQueryLocale ( context , { lang, name } )
0 commit comments