Switching languages in theme's template.html file Switching languages in theme's template.html file
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Switching languages in theme's template.html file

Started by café, June 09, 2018, 02:43:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

café

Hi Forum,

I'm creating a bilingual gallery with CPG. I'm using a theme which displays a number of custom phrases in English that are defined in the template.html file for the theme rather than from the strings defined in lang/english.php. I thought I could switch between English and Portuguese using PHP to detect the browser language settings but this doesn't work in the template.html file (i think it would need to be a *.php file).

Can anyone please offer a suggestion? I'm testing the page here: http://escuta.org/fotos - see the english titles "Gallery Options" and "User Options", for example.

Sorry, I'm not much good at php...

Thanks,


ron4mac

That is not currently a capability for a theme. But I think it is a useful capability to add and I will put it on the new features list.

ron4mac

#2
Had some time to work out theme language additions.

Replace include/functions.inc.php with the attached.

Create a lang folder in your theme with language files as the following:

english.php
<?php

$theme_lang
['GALLERY_OPTIONS'] = 'Gallery Options';
$theme_lang['USER_OPTIONS'] = 'User Options';


Then, in your theme template, use {THEME_LANG_GALLERY_OPTIONS}, etc.