Theme Helpers
There are multiple helpers available to speed up the development of themes.
Translation
Translation files are loaded from the lang directory of the currently loaded theme, any PHP file located in the folder will be loaded into the translator in a namespaced format.
If you had a theme called Cosmo then all translations should be prefixed with Cosmo::. The namespace is taken from the theme manifest.
trans
The trans method is included by Laravel and it's short hand version __ is available. More examples can be found on Laravel's localization docs
// themes/Cosmo/lang/en/fight.php
return [
"matchLength" => "Match Length"
]
// themes/Cosmo/views/fight.blade.php
trans("Cosmo::fight.matchLength")
// Match Length
__("Cosmo::fight.matchLength")
// Match Length
You can also specify variables within the translations
// themes/Cosmo/lang/en/fight.php
return [
"startDate" => "Started at :date"
]
// themes/Cosmo/views/fight.blade.php
trans("Cosmo::fight.startDate", ["date" => "A long time ago in a galaxy far, far away..." ])
// Started at A long time ago in a galaxy far, far away...
__("Cosmo::fight.startDate", ["date" => "A long time ago in a galaxy far, far away..." ])
// Started at A long time ago in a galaxy far, far away...
translate_ladder
The translate_ladder method converts a ladder column name into its translated name specified in the config, the shorthand version __ladder is also available.
translate_ladder("nodebuff_elo")
// No Debuff
__ladder("nodebuff_elo")
// No Debuff
translate_arena
The translate_arena method converts an arena name into its translated name specified in the config, the shorthand version __arena is also available.
translate_arena("abyss")
// Abyss
__arena("abyss")
// Abyss
Modules
module_enabled
The module_enabled method checks if a module has been enabled such as Fights
@if(module_enabled("Fight"))
Fights are enabled!
@endif
Theme
theme_asset
The theme_asset method gets the public path to an asset
theme_asset("path/to/asset/style.css")
// themes/Cosmo/assets/path/to/asset/style.css