Translations

Provide multilingual support for your plugin's user interface.

Translation Files

Create translation files in Resources/translations/ or translations/:

plugins/my-plugin/
└── Resources/
    └── translations/
        ├── messages.en.yaml
        ├── messages.pl.yaml
        └── messages.de.yaml

Translation Domain

Use plugin_{plugin_name} as the translation domain (snake_case!):

  • plugin_my_plugin

  • plugin_hello_world

  • plugin_paypal_payment

English Translations (messages.en.yaml)

Polish Translations (messages.pl.yaml)

Using Translations in Templates

Using Translations in PHP

Parameterized Translations

Pluralization

Translation Keys Organization

Organize keys by component/section:

Language Detection

PteroCA automatically detects user language based on:

  1. User's selected language (from profile)

  2. Browser's Accept-Language header

  3. System default language

Translation Best Practices

  1. Use clear key structure - organize by section/component

  2. Provide all translations - at minimum English

  3. Use parameters for dynamic content

  4. Keep translations short - especially for buttons/labels

  5. Test with different languages - ensure UI layout works

  6. Document translation keys - for other translators

  7. Use consistent terminology - same words for same concepts

  8. Avoid hardcoded text - always use translation keys

Translation File Locations

Two locations are supported:

Option 1: Resources/translations/

Option 2: translations/

Choose one location and be consistent.

Translation Testing

Test translations by changing language:

Last updated