Development Standards
Code Language Requirements
1. Comments
- All code comments must be in English
- Includes the following (not limited to):
- Function/method comments
- Inline comments
- Code block explanations
- TODO/FIXME comments
2. Logging
- All log output must be in English
- Includes the following (not limited to):
logger.log() info logs
logger.warn() warning logs
logger.error() error logs
console.log() debug output
3. Error Messages
- Error messages must support internationalization (i18n)
- User-facing error messages: Display in the user's selected language (Japanese/Chinese/English) via i18n system
- Debug/development error messages: Display in the user's selected language via i18n system
- Exception messages: Use i18n for internationalized error messages
Examples
Correct Comments and Logs (English + i18n)
// Get embeddings for texts
async getEmbeddings(texts: string[]): Promise<number[][]> {
this.logger.log(`Getting embeddings for ${texts.length} texts`);
try {
// Call API to get embeddings
const response = await this.callEmbeddingAPI(texts);
return response.data;
} catch (error) {
this.logger.error('Failed to get embeddings', error);
// Use i18n for user-facing error messages
throw new Error(this.i18n.t('errors.embeddingGenerationFailed'));
}
}
Using i18n for Error Messages
import { I18nService } from './i18n.service';
async processDocument(file: Express.Multer.File) {
try {
// Process document...
return result;
} catch (error) {
// Error message in user's selected language
throw new Error(this.i18n.t('errors.documentProcessingFailed', {
filename: file.originalname
}));
}
}
Compliance Standards
- During code reviews, always check the language of comments and logs
- New code must follow English comments and logs standards
- When refactoring existing code, update comments and logs to English simultaneously
- All error messages must use the i18n system for internationalization