Thank you for considering contributing to CountryKit! We welcome contributions from the community.
- Add/Fix Country Data - Update incorrect information, add missing countries
- Add Flags - Contribute SVG flags for countries
- Improve Documentation - Fix typos, clarify explanations, add examples
- Add Language Packages - Create wrappers for Go, Ruby, Rust, etc.
- Report Bugs - Open issues for data errors or bugs
- Suggest Features - Propose new features or improvements
-
Fork the repository
git clone https://github.com/ProgrammerNomad/CountryKit.git cd CountryKit -
Create a new branch
git checkout -b feature/your-feature-name
-
Make your changes
- Edit the relevant files
- Follow the existing code style and structure
-
Run validation
node scripts/validate.js node test.js
-
Commit your changes
git add . git commit -m "Add: your descriptive commit message"
-
Push to your fork
git push origin feature/your-feature-name
-
Open a Pull Request
- Go to the original repository
- Click "New Pull Request"
- Describe your changes clearly
-
Edit
data/countries.jsondirectly -
Follow the existing structure exactly:
{ "cca2": "US", "cca3": "USA", "ccn3": "840", "name": "United States", "native_name": "United States", "calling_code": "+1", "capital": "Washington, D.C.", "region": "Americas", "subregion": "Northern America", "tld": ".us", "currency": [ { "code": "USD", "name": "United States Dollar", "symbol": "$" } ], "languages": [ { "code": "en", "name": "English" } ], "flag": { "emoji": "🇺🇸", "svg": "flags/US.svg" } } -
Required fields:
cca2,cca3,ccn3(ISO codes)name,native_namecalling_codecurrency(array, at least one)languages(array, at least one)flag.emoji,flag.svg
-
Optional fields:
capital,region,subregion,tld
-
After editing, regenerate dependent files:
node scripts/auto-generate.js
-
Validate your changes:
node scripts/validate.js node test.js
- Place SVG files in the
flags/directory - Name them using ISO2 code:
US.svg,GB.svg, etc. - Ensure SVG is clean and optimized
- Update the country's
flag.svgpath incountries.json
- ISO Codes: Use official ISO 3166-1 codes
- Calling Codes: Follow E.164 format (include
+) - Currency Codes: Use ISO 4217 codes
- Language Codes: Use ISO 639-1 (2-letter) codes
- Native Names: Use the most common official native name
- Accuracy: Verify information from official sources
- Use ES6+ features
- 2 spaces for indentation
- Semicolons required
- Clear variable names
- Add comments for complex logic
- Follow PEP 8
- 4 spaces for indentation
- Use docstrings for functions
- Type hints where appropriate
- Follow PSR-12
- 4 spaces for indentation
- Use type declarations
- DocBlocks for all public methods
Use clear, descriptive commit messages:
Add: <description>- New features or dataFix: <description>- Bug fixes or data correctionsUpdate: <description>- Updates to existing features/dataDocs: <description>- Documentation changesTest: <description>- Test-related changesRefactor: <description>- Code refactoring
Examples:
Add: French Polynesia country data
Fix: Incorrect calling code for Brazil
Update: Currency symbol for Indian Rupee
Docs: Add PHP usage examples to README
- Title: Clear and descriptive
- Description: Explain what changes you made and why
- Testing: Confirm you've run validation and tests
- Screenshots: Include for UI changes (flag-preview.html)
- Breaking Changes: Clearly mark any breaking changes
Before submitting a PR, ensure all tests pass:
# Data validation
node scripts/validate.js
# Data tests
node test.js
# Package tests
node test-package.js
python test-python.py
php test-php.phpTo add a package for a new language (e.g., Go, Ruby, Rust):
- Create
packages/<language>/directory - Follow the same structure as existing packages
- Implement the same helper functions:
- Get country by ISO2/ISO3
- Get countries by calling code, region, currency, language
- Search countries
- Add README with usage examples
- Add test file following
test-<language>.<ext>pattern - Update main README with the new package
If you have questions or need help:
- Open an issue for discussion
- Check existing issues and PRs
- Review the README and package documentation
- Be respectful and constructive
- Welcome newcomers and help them learn
- Focus on what's best for the community
- Accept constructive criticism gracefully
By contributing to CountryKit, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to CountryKit!