Skip to content

chore: spelling and linting #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ You can do `import { ... } from '@intlify/utils'` the above utilities
- `tryPathLocale`
- `tryQueryLocale`

The about utilies functions accpet Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser)
The about utilities functions accept Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser)

#### Specialized environments

If you will use Node.js and H3, You can do `import { ... } from '@intlify/utils/{ENV}'` the above utilities.

The namespace `{ENV}` is one of the following:

- `node`: accpet `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module
- `node`: accept `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module
- `h3`: accept `H3Event` by HTTP framework [h3](https://github.com/unjs/h3)
- `hono`: accept `Context` by edge-side web framework [hono](https://github.com/honojs/hono)

Expand Down
4 changes: 2 additions & 2 deletions deno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ You can do `import { ... } from '@intlify/utils'` the above utilities
- `tryPathLocale`
- `tryQueryLocale`

The about utilies functions accpet Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser)
The about utilities functions accept Web APIs such as [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) that is supported by JS environments (such as Deno, Bun, and Browser)

#### Specialized environments

If you will use Node.js and H3, You can do `import { ... } from '@intlify/utils/{ENV}'` the above utilities.

The namespace `{ENV}` is one of the following:

- `node`: accpet `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module
- `node`: accept `IncomingMessage` and `Outgoing` by Node.js [http](https://nodejs.org/api/http.html) module
- `h3`: accept `H3Event` by HTTP framework [h3](https://github.com/unjs/h3)
- `hono`: accept `Context` by edge-side web framework [hono](https://github.com/honojs/hono)

Expand Down
2 changes: 1 addition & 1 deletion deno/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export type ParseScriptSubtag<
> = Result

/**
* paser unicode script subtag (EBNF: = alpha{4};)
* parse unicode script subtag (EBNF: = alpha{4};)
* https://unicode.org/reports/tr35/#unicode_script_subtag
*/
// TODO: Check if the script subtag is in CLDR
Expand Down
6 changes: 3 additions & 3 deletions deno/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export function parseAcceptLanguage(value: string): string[] {
}

/**
* nomralize the language name
* normalize the language name
*
* @description
* This function normalizes the locale name defined in {@link https://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names | gettext(libc) style} to {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag}
*
* @example
* ```ts
* const oldLangName = 'en_US'
* const langTag = nomralizeLanguageName(oldLangName)
* const langTag = normalizeLanguageName(oldLangName)
* conosle.log(langTag) // en-US
* ```
*
Expand Down Expand Up @@ -131,7 +131,7 @@ export let pathLanguageParser: PathLanguageParser = /* #__PURE__*/ createPathInd
/**
* register the path language parser
*
* @description register a parser to be used in the `getPathLanugage` utility function
* @description register a parser to be used in the `getPathLanguage` utility function
*
* @param {PathLanguageParser} parser the path language parser
*/
Expand Down
2 changes: 1 addition & 1 deletion deno/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function getHeaderLanguages(
/**
* get language from header
*
* @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header.
* @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header.
*
* @example
* example for Web API request on Deno:
Expand Down
1 change: 1 addition & 0 deletions playground/browser/browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import test from 'node:test'
import { createServer } from 'node:http'
import playwright from 'playwright'
import handler from 'serve-handler'
import process from 'node:process'

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

Expand Down
2 changes: 1 addition & 1 deletion playground/browser/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
1 change: 1 addition & 0 deletions playground/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createServer } from 'node:http'
import { getHeaderLanguages } from '@intlify/utils/node'
import process from 'node:process'

const server = createServer((req, res) => {
const languages = getHeaderLanguages(req)
Expand Down
1 change: 1 addition & 0 deletions playground/node/node.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import assert from 'node:assert'
import test from 'node:test'
import { spawn } from 'node:child_process'
import { fetch } from 'ofetch'
import process from 'node:process'

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

Expand Down
1 change: 1 addition & 0 deletions scripts/bump-deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import semver from 'semver'
import { readPackageJSON } from 'pkg-types'

import type { ParseError } from 'jsonc-parser'
import process from 'node:process'

async function main() {
const npmPath = resolve(process.cwd(), 'package.json')
Expand Down
1 change: 1 addition & 0 deletions scripts/bump-edge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { execSync } from 'node:child_process'
import { promises as fs } from 'node:fs'
import { resolve } from 'node:path'
import process from 'node:process'

async function main() {
const commit = execSync('git rev-parse --short HEAD').toString('utf-8').trim()
Expand Down
3 changes: 2 additions & 1 deletion scripts/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { isExists } from './utils.ts'
import { readPackageJSON } from 'pkg-types'
import process from 'node:process'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

Expand All @@ -26,7 +27,7 @@ async function main() {
throw new Error(`not found ${destPath}`)
}

console.log('copy some source files to denoland hosting directries 🦕 ...')
console.log('copy some source files to denoland hosting directories 🦕 ...')

// copy docs
for (const p of ['README.md', 'LICENSE']) {
Expand Down
1 change: 1 addition & 0 deletions scripts/playwright-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { readPackageJSON } from 'pkg-types'
import { isExists } from './utils.ts'
import process from 'node:process'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

Expand Down
1 change: 1 addition & 0 deletions scripts/replaceDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { readPackageJSON, writePackageJSON } from 'pkg-types'
import { isExists } from './utils.ts'
import process from 'node:process'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

Expand Down
2 changes: 1 addition & 1 deletion src/h3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function getHeaderLanguages(event: H3Event, {
/**
* get language from header
*
* @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header.
* @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header.
*
* @example
* example for h3:
Expand Down
2 changes: 1 addition & 1 deletion src/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function getHeaderLanguages(context: Context, {
/**
* get language from header
*
* @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header.
* @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header.
*
* @example
* example for Hone:
Expand Down
4 changes: 2 additions & 2 deletions src/locale.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ test('ParseVariantsSubtag', () => {
>()
})

test('ParseUnicodeLangugageId', () => {
test('ParseUnicodeLanguageId', () => {
/**
* Success cases
*/
Expand All @@ -312,7 +312,7 @@ test('ParseUnicodeLangugageId', () => {
]
>()

/** Erros */
/** Errors */
expectTypeOf<ParseUnicodeLanguageId<'a-ana-p-jauer-jauer'>>().toMatchTypeOf<
[
{ lang: never; script: never; region: never; variants: [] },
Expand Down
2 changes: 1 addition & 1 deletion src/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export type ParseScriptSubtag<
> = Result

/**
* paser unicode script subtag (EBNF: = alpha{4};)
* parse unicode script subtag (EBNF: = alpha{4};)
* https://unicode.org/reports/tr35/#unicode_script_subtag
*/
// TODO: Check if the script subtag is in CLDR
Expand Down
2 changes: 1 addition & 1 deletion src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
tryPathLocale,
tryQueryLocale,
} from './node.ts'
import { createServer, IncomingMessage, OutgoingMessage } from 'node:http'
import { createServer, type IncomingMessage, type OutgoingMessage } from 'node:http'
import { DEFAULT_COOKIE_NAME, DEFAULT_LANG_TAG } from './constants.ts'

describe('getHeaderLanguages', () => {
Expand Down
7 changes: 4 additions & 3 deletions src/node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IncomingMessage, OutgoingMessage } from 'node:http'
import type { IncomingMessage, OutgoingMessage } from 'node:http'
import { parse, serialize } from 'cookie-es'
import {
getExistCookies,
Expand All @@ -14,6 +14,7 @@ import { ACCEPT_LANGUAGE_HEADER, DEFAULT_COOKIE_NAME, DEFAULT_LANG_TAG } from '.
import { normalizeLanguageName, pathLanguageParser } from './shared.ts'

import type { CookieOptions, HeaderOptions, PathOptions, QueryOptions } from './http.ts'
import process from 'node:process'

/**
* get languages from header
Expand Down Expand Up @@ -55,7 +56,7 @@ export function getHeaderLanguages(
/**
* get language from header
*
* @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header.
* @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header.
*
* @example
* example for Node.js request:
Expand Down Expand Up @@ -577,7 +578,7 @@ let navigatorLanguage = ''
* @description
* You can get the language tag from system environment variables.
*
* @returns {string} {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag}, if you can't get the language tag, return a enmpty string.
* @returns {string} {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag}, if you can't get the language tag, return a empty string.
*/
function getNavigatorLanguage(): string {
return navigatorLanguage ||
Expand Down
6 changes: 3 additions & 3 deletions src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export function parseAcceptLanguage(value: string): string[] {
}

/**
* nomralize the language name
* normalize the language name
*
* @description
* This function normalizes the locale name defined in {@link https://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names | gettext(libc) style} to {@link https://datatracker.ietf.org/doc/html/rfc4646#section-2.1 | BCP 47 language tag}
*
* @example
* ```ts
* const oldLangName = 'en_US'
* const langTag = nomralizeLanguageName(oldLangName)
* const langTag = normalizeLanguageName(oldLangName)
* conosle.log(langTag) // en-US
* ```
*
Expand Down Expand Up @@ -131,7 +131,7 @@ export let pathLanguageParser: PathLanguageParser = /* #__PURE__*/ createPathInd
/**
* register the path language parser
*
* @description register a parser to be used in the `getPathLanugage` utility function
* @description register a parser to be used in the `getPathLanguage` utility function
*
* @param {PathLanguageParser} parser the path language parser
*/
Expand Down
2 changes: 1 addition & 1 deletion src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function getHeaderLanguages(
/**
* get language from header
*
* @description parse header string, default `accept-language`. if you use `accept-language`, this function retuns the **first language tag** of `accept-language` header.
* @description parse header string, default `accept-language`. if you use `accept-language`, this function returns the **first language tag** of `accept-language` header.
*
* @example
* example for Web API request on Deno:
Expand Down