Allows GetSimple theme designers to have theme-dependent language strings in
a lang folder of their theme.
-
Add
language_functions.php(from this gist) to your current theme's folder. -
Create a
langfolder in your current theme -
Create language files for your theme with file names corresponding to language codes:
// theme/yourtheme/lang/en_US.php $i18n = array( 'LATEST_UPDATE' => 'Latest update', // ... );
The variable
$i18nmust be defined as an associative array. -
In your theme,
includethelanguage_functions.phpfile. -
Call
set_theme_lang($lang)with the base name of the desired language file (e.g.en_US). -
Print out strings using
get_theme_i18n($hash). Return them usingreturn_theme_i18n($hash).// theme/yourtheme/template.php // ... include('language_functions.php'); // Set the language set_theme_lang('en_US'); // Use your language hashes get_theme_i18n('LATEST_UPDATE'); // prints 'Latest update'
Sets the language code to the theme language file $lang.php.
Echos the i18n theme $hash if it exists, {$hash} otherwise.
Returns the i18n theme $hash if it exists, {$hash} otherwise.