Last active
August 29, 2015 14:21
-
-
Save nonoesp/38712192bed2196624e8 to your computer and use it in GitHub Desktop.
Partial translation fallback — to fallback_locale — using dimsav/translatable with Laravel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$translatableFallbackLocale = Config::get('translatable::fallback_locale'); | |
$project = Project::find($id); | |
$project_default = $project->translate($translatableFallbackLocale); | |
// Translations | |
if(!$project->title) { | |
$title = $project_default->title; | |
} else { | |
$title = $project->title; | |
} | |
if(!$project->abstract) { | |
$abstract = $project_default->abstract; | |
} else { | |
$abstract = $project->abstract; | |
} | |
if(!$project->text) { | |
$text = $project_default->text; | |
} else { | |
$text = $project->text; | |
} | |
// Render | |
echo '<h1>'.$title.'</h1>' | |
.Markdown::string($abstract) | |
.Markdown::string($text); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment