https://github.com/jenstornell/kirby-language-switcher-class
A class to help loading the to the correct translation, expecially in a panel field.
Example usage
Field
Here is a simple example of a panel field:
include __DIR__ . DS . 'language-switcher.php';
class YourField extends BaseField {
public function input() {
new LanguageSwitcher();
return l::get('test', 'Translation missing!');
}
}
If the file or translation is missing it will fallback to Translation missing!
in this case.
Language file paths
/my-plugin/languages/en.php
/my-plugin/languages/de.php
/my-plugin/languages/sv.php
Language file content (de.php
)
l::set('test', 'Hello from Germany!');
Namespace
Itβs really recommended to use a namespace or rename the class. Else it might collide with other fields or plugins.
Changelog
0.1
- Initial release
Requirements
- Kirby 2.3
License
MIT