
Translations & i18n
Translation service, domains, locales, YAML/XLIFF files, ICU MessageFormat, pluralization
1Which Symfony service should be used to translate strings in a controller?
Which Symfony service should be used to translate strings in a controller?
Câu trả lời
The TranslatorInterface service is the main service for handling translations in Symfony. It can be injected into controllers, services, or other classes via autowiring. This service loads translation files from the translations/ folder and returns the translation corresponding to the active locale.
2In which folder are translation files stored by default in Symfony?
In which folder are translation files stored by default in Symfony?
Câu trả lời
The translations/ folder at the project root is the default location for translation files in Symfony. Files follow the naming convention domain.locale.format (e.g., messages.fr.yaml). Bundles can also provide their own translations in Resources/translations/.
3What is the correct naming convention for a YAML translation file for the 'messages' domain in French?
What is the correct naming convention for a YAML translation file for the 'messages' domain in French?
Câu trả lời
The Symfony naming convention for translation files is domain.locale.format. For the messages domain in French with YAML format, the file must be named messages.fr.yaml. The default domain is 'messages', but custom domains like validators.fr.yaml or security.fr.yaml can be created.
How to translate text with dynamic parameters using the Translator?
What is the role of a translation domain in Symfony?
+13 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Symfony khác
Modern PHP (8.1+)
Symfony Basics
Routing & Controllers
Twig & Templates
Doctrine ORM Basics
Symfony Forms
Data Validation
Dependency Injection & Services
Security & Authentication
Doctrine Advanced
API Platform
Serializer Component
Events & Event Subscribers
Console & Commands
Messenger Component
HTTP Client
Cache & Performance
Workflow Component
Testing Symfony
Mailer Component
EasyAdmin Bundle
Symfony Architecture
Performance & Optimization
Security Advanced
Custom Bundles
Microservices with Symfony
Real-time & WebSockets
Deployment & DevOps
Nắm vững Symfony cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí