services:
translator.default:
class: Symfony\Component\Translation\Translator
arguments:
- '%locale%'
- '@Symfony\Component\Translation\Loader\YamlFileLoader'
tags:
- { name: translator.default }
security:
authentication:
credentials: "Invalid credentials"
denied: "Access denied"
logout: "You have been logged out"
login:
blocked_user: "Your account has been blocked"
incorrect_password: "Incorrect password"
invalid_username: "Invalid username"
not_found: "User not found"
insufficient_authentication: "Insufficient authentication"
api_platform:
# ...
translation_enabled: true
formats:
json: ['application/json']
yaml: ['application/yaml', 'text/yaml']
html: ['text/html']
完成以上步骤后,API Platform将自动使用你所定义的翻译。例如,在英文环境下,尝试身份验证时,将看到“Incorrect password”而不是默认的“Invalid credentials”。