Sage 9 - extend template hierarchy to look for language version file

I’m using Sage9 with WPML.

I’d like to extend the template loader to first search for a file including the current language code in the filename.

eg. if on german homepage URL https://x.com/de/

First try to load German version: front-page-de.blade.php
… if not found, fall back to normal/English version: front-page.blade.php

Any suggestions how I would do this?

Why not just add this fuctionality in your main layouts file? For example: write some function that gets the language code and then determines which sections to yield.

This would require changes throughout the theme codebase, which is what we’re trying to avoid.

The front-page example is maybe a bit broad, we’re looking to check for language templates whenever blade includes a view, so aiming to extend the template loader so any blade view (partials, etc) can be overridden just by creating a language-specific file, so it operates similarly to Wordpress’ template loading hierarchy.

I have sage’s template loader doing this now, so files such as /resources/views/front-page.blade.php will use a language version if available.

I haven’t yet found a way to extend the blade @include directive, to do the same for blade @includes (partials, etc)