Download the PHP package tourze/gb-t-4880 without Composer
On this page you can find all versions of the php package tourze/gb-t-4880. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package gb-t-4880
GB/T 4880
中文
GB/T 4880 is a PHP package implementing the GB/T 4880.1-2005 language code standard. It provides a comprehensive enum class containing all two-letter language codes defined by the standard, along with their corresponding Chinese labels.
This package is designed for applications that need to work with language codes according to Chinese national standards, offering both the ISO 639-1 compatible codes and localized Chinese names.
Features
- Standards Compliant: Implements the GB/T 4880.1-2005 standard
- Comprehensive: Provides 180+ two-letter language codes
- Localized: Includes corresponding Chinese labels for all languages
- Modern PHP: Utilizes PHP 8.1+ enum features with strict typing
- Framework Ready: Implements
Labelable,Itemable, andSelectableinterfaces for easy integration - Select Options: Built-in support for generating select/dropdown options
- Type Safety: Full type safety with enum-based implementation
Requirements
- PHP 8.1 or higher
- tourze/enum-extra
Installation
Quick Start
Basic Usage
Advanced Usage
Working with All Languages
API Reference
Core Methods
Alpha2Code::from(string $value): Alpha2Code- Create enum instance from language codeAlpha2Code::tryFrom(string $value): ?Alpha2Code- Safe creation, returns null for invalid codesgetLabel(): string- Get the Chinese label for the languagecases(): array- Get all available language codes
Interface Methods
toArray(): array- Convert to associative array with 'value' and 'label' keystoSelectItem(): array- Alias for toArray(), useful for form select optionsgenOptions(): array- Generate array of all languages as select options
Special Cases
- Most language codes follow the ISO 639-1 standard (2 letters)
- Exception: Montenegrin uses 'cnr' (3 letters) as defined by GB/T 4880.1-2005
- All 180+ languages defined by the standard are included
Integration
This package is designed to work seamlessly with the tourze/enum-extra ecosystem:
Testing
Contributing
- Issues and PRs are welcome
- Please follow PSR-12 coding standards
- Ensure all tests pass before submitting
- Add tests for new features
- Update documentation when needed
Standards Reference
- GB/T 4880.1-2005 Standard Information and documentation -- Bibliographic data element directory -- Part 1: 2-letter codes
- ISO 639-1 - Codes for the representation of names of languages
License
MIT
Author
tourze