|
| 1 | +# Contributing to asknot-rocky |
| 2 | + |
| 3 | +Thank you for your interest in contributing to asknot-rocky! This guide will help you get started with contributing to the project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Code of Conduct](#code-of-conduct) |
| 8 | +- [Getting Started](#getting-started) |
| 9 | +- [Development Setup](#development-setup) |
| 10 | +- [Making Changes](#making-changes) |
| 11 | +- [Submitting Changes](#submitting-changes) |
| 12 | +- [Code Style](#code-style) |
| 13 | +- [Testing](#testing) |
| 14 | +- [Project Structure](#project-structure) |
| 15 | +- [Contributing Translations](#contributing-translations) |
| 16 | + |
| 17 | +## Code of Conduct |
| 18 | + |
| 19 | +By participating in this project, you are expected to uphold our Code of Conduct, which promotes a respectful and inclusive environment for all contributors. |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +1. Fork the repository on GitHub |
| 24 | +2. Clone your fork locally: |
| 25 | + ```bash |
| 26 | + git clone https://github.com/YOUR-USERNAME/asknot-rocky.git |
| 27 | + cd asknot-rocky |
| 28 | + ``` |
| 29 | +3. Add the upstream repository as a remote: |
| 30 | + ```bash |
| 31 | + git remote add upstream https://github.com/rocky-linux/asknot-rocky.git |
| 32 | + ``` |
| 33 | + |
| 34 | +## Development Setup |
| 35 | + |
| 36 | +1. Ensure you have Node.js installed (latest LTS version recommended) |
| 37 | +2. Install dependencies: |
| 38 | + ```bash |
| 39 | + npm install |
| 40 | + ``` |
| 41 | +3. Start the development server: |
| 42 | + ```bash |
| 43 | + npm run dev |
| 44 | + ``` |
| 45 | +4. Visit `http://localhost:4321` in your browser |
| 46 | + |
| 47 | +## Making Changes |
| 48 | + |
| 49 | +1. Create a new branch for your changes: |
| 50 | + ```bash |
| 51 | + git checkout -b feature/your-feature-name |
| 52 | + ``` |
| 53 | +2. Make your changes |
| 54 | +3. Ensure your changes meet our code quality standards: |
| 55 | + ```bash |
| 56 | + npm run lint # Run ESLint |
| 57 | + npm run format # Run Prettier |
| 58 | + npm run typecheck # Run TypeScript checks |
| 59 | + npm run test # Run tests |
| 60 | + ``` |
| 61 | + |
| 62 | +## Submitting Changes |
| 63 | + |
| 64 | +1. Commit your changes with a clear and descriptive commit message |
| 65 | +2. Push to your fork: |
| 66 | + ```bash |
| 67 | + git push origin feature/your-feature-name |
| 68 | + ``` |
| 69 | +3. Create a Pull Request from your fork to our main repository |
| 70 | +4. Ensure all CI checks pass |
| 71 | +5. Wait for review from maintainers |
| 72 | + |
| 73 | +## Code Style |
| 74 | + |
| 75 | +We use several tools to maintain code quality: |
| 76 | + |
| 77 | +- ESLint for code linting |
| 78 | +- Prettier for code formatting |
| 79 | +- TypeScript for type checking |
| 80 | + |
| 81 | +Our automated workflows will check these when you submit a PR. You can run them locally: |
| 82 | + |
| 83 | +```bash |
| 84 | +npm run lint:fix # Fix linting issues |
| 85 | +npm run format # Format code |
| 86 | +npm run typecheck # Check types |
| 87 | +``` |
| 88 | + |
| 89 | +## Testing |
| 90 | + |
| 91 | +We use Vitest for testing. Write tests for new features and ensure existing tests pass: |
| 92 | + |
| 93 | +```bash |
| 94 | +npm run test # Run tests |
| 95 | +npm run test:coverage # Run tests with coverage report |
| 96 | +``` |
| 97 | + |
| 98 | +## Project Structure |
| 99 | + |
| 100 | +``` |
| 101 | +asknot-rocky/ |
| 102 | +├── src/ # Source files |
| 103 | +│ ├── components/ # React components (Button, QuestionNode, etc.) |
| 104 | +│ ├── i18n/ # Internationalization files and language support |
| 105 | +│ ├── layouts/ # Page layouts |
| 106 | +│ ├── pages/ # Astro pages |
| 107 | +│ ├── questions/ # Question tree logic and configuration |
| 108 | +│ ├── styles/ # Global styles |
| 109 | +│ └── test/ # Test utilities and shared test code |
| 110 | +├── public/ # Static assets |
| 111 | +``` |
| 112 | + |
| 113 | +Key files: |
| 114 | + |
| 115 | +- `src/pages/index.astro` – Main application page |
| 116 | +- `src/components/QuestionNode.tsx` – Core question navigation component |
| 117 | +- `src/questions/questions.ts` – Question tree configuration and types |
| 118 | +- `src/i18n/LanguageContext.tsx` – Internationalization context and logic |
| 119 | +- `src/i18n/{langCode}.json` – Translations |
| 120 | + |
| 121 | +## Contributing Translations |
| 122 | + |
| 123 | +We welcome contributions to make asknot-rocky accessible in more languages! The project currently supports English (en) and Spanish (es), with room for more languages. |
| 124 | + |
| 125 | +### Translation Structure |
| 126 | + |
| 127 | +Translations are stored in JSON files in the `src/i18n` directory, with each language having its own file (e.g., `en.json`, `es.json`). The translation files follow a specific structure defined in `src/i18n/types.ts`. |
| 128 | + |
| 129 | +Key areas that need translation include: |
| 130 | + |
| 131 | +- Home page content |
| 132 | +- Question categories and options |
| 133 | +- Error messages |
| 134 | +- UI elements (footer, language selector) |
| 135 | + |
| 136 | +### Adding a New Language |
| 137 | + |
| 138 | +1. Create a new JSON file in `src/i18n` named with your language code (e.g., `fr.json` for French) |
| 139 | +2. Copy the structure from `en.json` as a template |
| 140 | +3. Add your language code and name to the `LANGUAGE_NAMES` object in `src/i18n/types.ts`: |
| 141 | + ```typescript |
| 142 | + export const LANGUAGE_NAMES: Record<LanguageCode, string> = { |
| 143 | + en: 'English', |
| 144 | + es: 'Español', |
| 145 | + fr: 'Français', // Your new language |
| 146 | + } as const; |
| 147 | + ``` |
| 148 | +4. Update the `LanguageCode` type in `src/i18n/types.ts`: |
| 149 | + ```typescript |
| 150 | + export type LanguageCode = 'en' | 'es' | 'fr'; // Add your language code |
| 151 | + ``` |
| 152 | +5. Translate all strings in your new language file |
| 153 | + |
| 154 | +The language will be automatically loaded and available in the language selector once you've completed these steps. The application uses Vite's dynamic imports to automatically discover and load all language files in the `src/i18n` directory. |
| 155 | + |
| 156 | +### Translation Guidelines |
| 157 | + |
| 158 | +1. Maintain the same JSON structure as the English version |
| 159 | +2. Keep special placeholders and HTML tags intact |
| 160 | +3. Ensure all keys are present and match exactly |
| 161 | +4. Test the UI with your translations to verify layout and formatting |
| 162 | +5. Include regional variations only if necessary (e.g., `pt-BR` vs `pt-PT`) |
| 163 | + |
| 164 | +### Testing Translations |
| 165 | + |
| 166 | +After adding or modifying translations: |
| 167 | + |
| 168 | +1. Run `npm run typecheck` to ensure type safety |
| 169 | +2. Start the development server and test the UI in your language |
| 170 | +3. Verify all interactive elements work correctly |
| 171 | +4. Check text formatting and layout in different screen sizes |
| 172 | + |
| 173 | +## Need Help? |
| 174 | + |
| 175 | +If you need help or have questions, please: |
| 176 | + |
| 177 | +1. Check existing issues on GitHub |
| 178 | +2. Create a new issue if needed |
| 179 | +3. Join the Rocky Linux community channels |
| 180 | + |
| 181 | +Thank you for contributing to asknot-rocky! |
0 commit comments