i18n ​
File: src/Helpers/i18n.php
Internationalization and translation helpers that extend Laravel's built-in trans() with Modularous-specific JSON fallback, label resolution, and Vue store formatting.
Functions ​
modularousTrans ​
modularousTrans(string $key, array $replace = [], string $locale = null): stringLooks up a translation key in the modularous:: namespace. Returns the raw key if no translation is found, making missing keys visible rather than silently empty.
___ (triple underscore) ​
___(string $key, array $replace = [], string $locale = null): stringThe primary Modularous translation helper. Resolution order:
trans($key)— standard Laravel lookuptrans("{$module}::{$key}")— module-namespaced lookup- JSON translation files for the active locale
- Returns
$keyunchanged if nothing matches
Use ___ instead of __ throughout Modularous controllers and views.
hasUnusualTrans ​
hasUnusualTrans(string $key): boolReturns true if the given key resolves to a different string than the key itself — i.e. a real translation exists.
trans_replacements ​
trans_replacements(string $translation, array $replacements): stringApplies [':KEY' => $value] replacements to an already-translated string. Thin wrapper over Laravel's str_replace replacement pattern.
getLabelFromLocale ​
getLabelFromLocale(string $key, string $locale = null): stringRetrieves the label for $key from the locale-specific translation file rather than the active app locale. Useful for generating labels in a target language during export or email generation.
getCode2LanguageTexts ​
getCode2LanguageTexts(): arrayReturns the full ISO 639-1 language code → language name map as an array (e.g. ['en' => 'English', 'tr' => 'Turkish', ...]). Used to populate language selector dropdowns.
getLanguagesForVueStore ​
getLanguagesForVueStore(): arrayReturns the active application locales formatted for the Vuex/Pinia store:
[
['code' => 'en', 'label' => 'English'],
['code' => 'tr', 'label' => 'Turkish'],
// ...
]Only includes locales listed in config('translatable.locales').