Skip to content

Commit

Permalink
lang API: Fixup dd83225#diff-9ab5e4fd4c9b654a7843bf0b989f8c4653595e31…
Browse files Browse the repository at this point in the history
…aa0875417172955a6a215464 for the undocumented private variable usage to overwrite lang constants via user theme

I think backend allowance was just an overseen mistake while this commit was a draft commit for splitting up backend and frontend themes for Serendipity 2.0.
It makes no sense to have this anywhere other than for individual user frontend themes. The less it runs through, the less possible regressions it has.
It was done in the early days to allow overwriting certain core constants in themes for frontend templates, e.g. POWERED_BY.
  • Loading branch information
ophian committed Apr 19, 2024
1 parent c3f238a commit 876345c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions include/lang.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,20 @@
$charset = serendipity_getCharset();

// The following variable can be set in serendipity_config_local.inc.php to force your templates being able to use language override includes
if (isset($serendipity['useTemplateLanguage']) && $serendipity['useTemplateLanguage'] === true) {
// An un-promoted private variable set, to first serve template based serendipity lang constants that have higher priority.
// We do not allow this for backend constants and both, the fallback "default" and the standard theme (currently "pure") !
if (isset($serendipity['useTemplateLanguage']) && $serendipity['useTemplateLanguage'] === true && !empty($serendipity['template'])
&& !defined('IN_serendipity_admin') && !in_array($serendipity['template'], ['default', 'default-php', $serendipity['defaultTemplate']])) {
if (defined('S9Y_DATA_PATH')) {
@include_once (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/' . $charset . 'lang_' . $serendipity['lang'] . '.inc.php');
@include_once (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php');

@include_once (S9Y_DATA_PATH . 'templates/' . $serendipity['template_backend'] . '/' . $charset . 'lang_' . $serendipity['lang'] . '.inc.php');
@include_once (S9Y_DATA_PATH . 'templates/' . $serendipity['template_backend'] . '/lang_en.inc.php');
} else {
@include_once (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/' . $charset . 'lang_' . $serendipity['lang'] . '.inc.php');
@include_once (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php');

@include_once (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template_backend'] . '/' . $charset . 'lang_' . $serendipity['lang'] . '.inc.php');
@include_once (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template_backend'] . '/lang_en.inc.php');
}
}

// Try and include preferred language from the configurated setting
// Try and include preferred language from the configured setting

if (@include(S9Y_INCLUDE_PATH . 'lang/' . $charset . 'serendipity_lang_'. $serendipity['lang'] .'.inc.php') ) {
// Only here can we truly say the language is loaded
Expand All @@ -42,9 +39,9 @@
// If no config file is loaded, language includes are not available.
// Now include one. Try to auto-guess the language by looking up the HTTP_ACCEPT_LANGUAGE.
serendipity_detectLang(true);
} //endif
}

// Do fallback to english
// Do fall back to english
if (IS_installed === false || (defined('IS_up2date') && IS_up2date === false)) {
@include_once(S9Y_INCLUDE_PATH . 'lang/' . $charset . 'serendipity_lang_en.inc.php');
}
Expand Down

0 comments on commit 876345c

Please sign in to comment.