Internationalization
Pubvana supports six locales. All user-visible strings in your plugin must go through the language system — never hardcode English strings in views or controllers.
Supported Locales
| Code | Language |
|---|---|
en | English |
es | Spanish |
fr | French |
id | Indonesian |
pt | Portuguese |
sk | Slovak |
All six locale files are required. Provide at least English; use English strings as placeholders for untranslated locales.
Directory Structure
plugins/MyPlugin/Language/
├── en/MyPlugin.php
├── es/MyPlugin.php
├── fr/MyPlugin.php
├── id/MyPlugin.php
├── pt/MyPlugin.php
└── sk/MyPlugin.php
Language File Format
<?php
// Language/en/MyPlugin.php
return [
'page_title' => 'My Plugin',
'btn_new' => 'New Item',
'btn_save' => 'Save',
'save_success' => 'Item saved successfully.',
'delete_confirm'=> 'Are you sure you want to delete this item?',
'no_items' => 'No items found.',
// With placeholder: '{0} items found.'
'item_count' => '{0} items found.',
];
Accessing Strings in PHP
$message = lang('MyPlugin.save_success');
// With placeholder
$message = lang('MyPlugin.item_count', [$count]);
Accessing Strings in Templates
{! lang "MyPlugin.read_more" !}
{! lang "MyPlugin.item_count" [count] !}
Key Naming Conventions
- Use
snake_casefor all keys - Prefix related keys:
col_,btn_,val_,status_,msg_ - Never include HTML in language strings
- For untranslated locales, leave the English string rather than leaving a key name