General Translation
This is the core library for General Translation. It is used in gt-react and gt-next.
See our docs for more information including guides, examples, and API references.
Development
Prerequisites
- Node.js (>= 16.0.0)
- npm or yarn
Installation
npm install
Testing
This project uses Vitest for testing with two types of tests:
Test Types
- Unit Tests (
__tests__/): Fast, isolated tests with mocking
Running Tests
npm test
npm test -- __tests__
npm run test:watch
npm test -- __tests__/logging/logger.test.ts
npm test -- -t "should handle translation"
Environment Variables
Required for E2E Tests
Create a .env file in the project root with:
VITE_GT_API_KEY="your-dev-api-key"
VITE_GT_PROJECT_ID="your-project-id"
VITE_GT_RUNTIME_URL="http://localhost:10000"
Note: E2E tests require a running GT runtime server at the specified URL. Without proper configuration, e2e tests will skip gracefully.
Optional: Logger Configuration
_GT_LOG_LEVEL=debug
Test Configuration
- Parallel Execution: Tests run in parallel using 2-4 threads for optimal performance
- Timeout: 15 seconds per test (suitable for network-dependent e2e tests)
- Environment: Node.js environment for testing
Example Test Commands
_GT_LOG_LEVEL=debug npm test --reporter=verbose
npm test -- __tests__
npm test -- -t "logger" --reporter=verbose
npm run test:watch -- __tests__/
Test Structure
__tests__/ # Unit tests with mocking
├── logging/ # Logger functionality tests
└── translate/ # Translation logic tests
Contributing
We welcome any contributions to our libraries. Please submit a pull request!
Development Workflow
- Install dependencies:
npm install
- Set up environment variables (see Testing section)
- Run tests:
npm test
- Make your changes
- Run tests again to ensure everything works
- Submit a pull request