{"_id":"@aleksejdix/ally-bcp47","_rev":"3-130474bd365d89593d92df549cded173","name":"@aleksejdix/ally-bcp47","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@aleksejdix/ally-bcp47","version":"1.0.0","keywords":["typescript","bcp47","language-tags","accessibility","i18n","internationalization","localization","a11y"],"author":{"name":"Aleksej Dix"},"license":"MIT","_id":"@aleksejdix/ally-bcp47@1.0.0","maintainers":[{"name":"aleksejdix","email":"privat@aleksejdix.com"}],"homepage":"https://github.com/AleksejDix/ally-lang#readme","bugs":{"url":"https://github.com/AleksejDix/ally-lang/issues"},"dist":{"shasum":"e8799cabc760fd1f8394a478db6cbeb95b5d6cdf","tarball":"https://registry.npmjs.org/@aleksejdix/ally-bcp47/-/ally-bcp47-1.0.0.tgz","fileCount":29,"integrity":"sha512-YxGwKc8NZay6FsiwepY1GsDnDvvmYRSRlnc8ve5stmDWrYFMj6Txppk9QSj5CQovZoCWGNhj/eMxRi/e0ZhWuQ==","signatures":[{"sig":"MEUCIQCO+l2uXv62AnZO5nAwDLYeefXbGe8MFByzdvRuw41H5gIgG+9aeZrRzcImET5Ob+5dlxDf/vlSG8plejNkW+RzsRs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122145},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"6af134305ab265cbf3f3467030ae244c659b4e9e","scripts":{"test":"vitest run","build":"tsc","prepare":"npm run build","test:ui":"vitest --ui","demo:ada":"node ./demo-ada-tags.js","docs:dev":"vitepress dev website","test:ada":"vitest run src/tests/ada-compliance.test.ts","docs:build":"vitepress build website","test:ch-de":"node ./demo-test-ch-de.js","test:watch":"vitest","docs:preview":"vitepress preview website","demo:european":"node ./demo-european-tags.js","test:coverage":"vitest run --coverage","test:european":"vitest run src/tests/european-countries.test.ts src/tests/eaa-compliance.test.ts","test:accessibility":"vitest run -t 'Accessibility Extensions'"},"_npmUser":{"name":"aleksejdix","email":"privat@aleksejdix.com"},"repository":{"url":"git+https://github.com/AleksejDix/ally-lang.git","type":"git"},"_npmVersion":"10.9.2","description":"TypeScript package for working with BCP-47 language tags","directories":{},"_nodeVersion":"23.11.0","dependencies":{"undici-types":"^6.21.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","vitest":"^3.1.3","vitepress":"^1.6.3","typescript":"^5.4.3","@types/node":"^20.11.30","@vitest/coverage-v8":"^3.1.3"},"_npmOperationalInternal":{"tmp":"tmp/ally-bcp47_1.0.0_1746824989701_0.22748065296912445","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@aleksejdix/ally-bcp47","version":"1.1.0","keywords":["typescript","bcp47","language-tags","accessibility","i18n","internationalization","localization","a11y"],"author":{"name":"Aleksej Dix"},"license":"MIT","_id":"@aleksejdix/ally-bcp47@1.1.0","maintainers":[{"name":"aleksejdix","email":"privat@aleksejdix.com"}],"homepage":"https://github.com/AleksejDix/ally-bcp47#readme","bugs":{"url":"https://github.com/AleksejDix/ally-bcp47/issues"},"dist":{"shasum":"ba90e2d58984c2d6ad7230a59e4103731717c00b","tarball":"https://registry.npmjs.org/@aleksejdix/ally-bcp47/-/ally-bcp47-1.1.0.tgz","fileCount":29,"integrity":"sha512-4o1nInzo79LibCePu9+nHf35jjlKgaoIh7Uw77NmgMPA4ygyfepmbGYdQi+ijr8q8WnCNUZ/oGtJcU6bxCqr0w==","signatures":[{"sig":"MEUCIQDuRdW3N9cGO3G14TV/I+xQZySTzOcg9aAKDnyJmdoWAAIgbVlR0HOGlxtODrT86ncFj49/Y4rhb99rTrofedjIM7k=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122477},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"a3608c2173a58a6afd015834740441378eefcaa1","scripts":{"test":"vitest run","build":"tsc","prepare":"npm run build","test:ui":"vitest --ui","demo:ada":"node ./demo-ada-tags.js","docs:dev":"vitepress dev website","test:ada":"vitest run src/tests/ada-compliance.test.ts","docs:build":"vitepress build website","test:ch-de":"node ./demo-test-ch-de.js","test:watch":"vitest","docs:preview":"vitepress preview website","demo:european":"node ./demo-european-tags.js","test:coverage":"vitest run --coverage","test:european":"vitest run src/tests/european-countries.test.ts src/tests/eaa-compliance.test.ts","test:accessibility":"vitest run -t 'Accessibility Extensions'"},"_npmUser":{"name":"aleksejdix","email":"privat@aleksejdix.com"},"repository":{"url":"git+https://github.com/AleksejDix/ally-bcp47.git","type":"git"},"_npmVersion":"10.9.2","description":"TypeScript package for working with BCP-47 language tags","directories":{},"_nodeVersion":"23.11.0","dependencies":{"undici-types":"^6.21.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vue":"^3.5.13","vitest":"^3.1.3","vitepress":"^1.6.3","typescript":"^5.4.3","@types/node":"^20.11.30","@vitest/coverage-v8":"^3.1.3"},"_npmOperationalInternal":{"tmp":"tmp/ally-bcp47_1.1.0_1746826824470_0.03719833284837981","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-05-09T21:09:49.622Z","modified":"2025-06-18T11:46:56.389Z","1.0.0":"2025-05-09T21:09:49.918Z","1.1.0":"2025-05-09T21:40:24.697Z"},"bugs":{"url":"https://github.com/AleksejDix/ally-bcp47/issues"},"author":{"name":"Aleksej Dix"},"license":"MIT","homepage":"https://github.com/AleksejDix/ally-bcp47#readme","keywords":["typescript","bcp47","language-tags","accessibility","i18n","internationalization","localization","a11y"],"repository":{"url":"git+https://github.com/AleksejDix/ally-bcp47.git","type":"git"},"description":"TypeScript package for working with BCP-47 language tags","maintainers":[{"email":"privat@aleksejdix.com","name":"allystudio"}],"readme":"# ally-bcp-47\n\n[![npm version](https://img.shields.io/npm/v/@aleksejdix/ally-bcp47.svg)](https://www.npmjs.com/package/@aleksejdix/ally-bcp47)\n\nA comprehensive TypeScript library for validating, parsing, and working with BCP-47 language tags according to [RFC 5646](https://tools.ietf.org/html/rfc5646).\n\n## Links\n\n- [npm package](https://www.npmjs.com/package/@aleksejdix/ally-bcp47)\n- [GitHub repository](https://github.com/AleksejDix/ally-bcp47)\n\n## Features\n\n- **Complete BCP-47 syntax validation** - Validates against the full ABNF grammar\n- **Detailed parsing** - Breaks down language tags into their component subtags\n- **Helpful error messages** - Clear, actionable error reporting\n- **No dependencies** - Lightweight and focused\n- **TypeScript-first** - Full type definitions included\n\n## Installation\n\n```bash\nnpm install @aleksejdix/ally-bcp47\n```\n\n## Usage\n\n### Basic Validation\n\n```typescript\nimport { isValid, isWellFormed } from \"@aleksejdix/ally-bcp47\";\n\n// Check if a tag is well-formed (syntax only)\nisWellFormed(\"en-US\"); // true\nisWellFormed(\"en--US\"); // false\n\n// Check if a tag is valid (syntax + registry validation)\nisValid(\"en-US\"); // true\nisValid(\"xy-ZZ\"); // false (invalid subtags)\n```\n\n### Detailed Validation\n\n```typescript\nimport { validateLanguageTag } from \"@aleksejdix/ally-bcp47\";\n\nconst result = validateLanguageTag(\"en-US\");\nconsole.log(result);\n/* Output:\n{\n  isWellFormed: true,\n  isValid: true,\n  tag: {\n    tag: \"en-us\",\n    language: \"en\",\n    region: \"us\"\n  }\n}\n*/\n\nconst invalidResult = validateLanguageTag(\"en-a\");\nconsole.log(invalidResult);\n/* Output:\n{\n  isWellFormed: false,\n  isValid: false,\n  errors: [{\n    type: \"invalid_extension\",\n    message: \"Extension singleton a must be followed by at least one extension subtag\",\n    subtag: \"a\",\n    subtagType: \"extension\",\n    position: 3\n  }]\n}\n*/\n```\n\n### Parsing Tags\n\n```typescript\nimport { parseTag } from \"@aleksejdix/ally-bcp47\";\n\nconst tag = parseTag(\"zh-Hans-CN-x-private\");\nconsole.log(tag);\n/* Output:\n{\n  tag: \"zh-hans-cn-x-private\",\n  language: \"zh\",\n  script: \"hans\",\n  region: \"cn\",\n  privateuse: [\"private\"]\n}\n*/\n```\n\n## Validation Options\n\nThe `validateLanguageTag` function accepts options to customize the validation:\n\n```typescript\nimport { validateLanguageTag } from \"@aleksejdix/ally-bcp47\";\n\nvalidateLanguageTag(\"en-US\", {\n  checkRegistry: true, // Whether to validate against the registry (default: true)\n  warnOnDeprecated: true, // Whether to return warnings for deprecated subtags (default: true)\n  warnOnRedundantScript: true, // Whether to warn about redundant scripts (default: true)\n});\n```\n\n## Tag Components\n\nThe library breaks down language tags into their component parts:\n\n- `language` - Primary language subtag (e.g., 'en', 'fr')\n- `extlang` - Extended language subtags (e.g., 'cmn')\n- `script` - Script subtag (e.g., 'Latn', 'Cyrl')\n- `region` - Region subtag (e.g., 'US', '001')\n- `variants` - Variant subtags (e.g., '1996')\n- `extensions` - Extension subtags (e.g., 'u-ca-gregory')\n- `privateuse` - Private use subtags (e.g., 'x-private')\n\n## Roadmap\n\n- [ ] Registry validation\n- [ ] Canonicalization\n- [ ] Registry update mechanism\n- [ ] More extensive validation options\n- [ ] Tag generation from components\n\n## European Accessibility Act Compliance\n\nThis library includes comprehensive testing for all European language tags to support compliance with the European Accessibility Act (Directive (EU) 2019/882).\n\n### Features for EAA Compliance\n\n- Validation of all 24 official EU language tags\n- Support for regional and minority language tags\n- Validation of accessibility-related extensions (number formatting, calendar systems, etc.)\n- Specific handling of common errors like country codes used as language codes (e.g., ch-DE)\n\n### Running European-specific Tests\n\n```bash\n# Test all European language tags\nnpm run test:european\n\n# Test accessibility extensions\nnpm run test:accessibility\n\n# Run the ch-DE specific test cases\nnpm run test:ch-de\n\n# Demo of European language tag validation\nnpm run demo:european\n```\n\nFor more details, see the [European Accessibility Act Compliance Documentation](./docs/eaa-compliance.md).\n\n## Americans with Disabilities Act (ADA) Compliance\n\nThis library includes comprehensive testing for US language tags to support compliance with the Americans with Disabilities Act (ADA) requirements for web accessibility.\n\n### Features for ADA Compliance\n\n- Validation of US English and other common US language tags\n- Support for languages commonly spoken in the US\n- Validation of accessibility-related extensions (time formats, number systems, measurement units)\n- Private use extensions for screen readers and assistive technologies\n- Case normalization according to BCP-47 standards\n\n### Running ADA-specific Tests\n\n```bash\n# Test all ADA-related language tags\nnpm run test:ada\n\n# Demo of ADA-related language tag validation\nnpm run demo:ada\n```\n\nFor more details, see the [Americans with Disabilities Act Compliance Documentation](./docs/ada-compliance.md).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}